ESAPI-C 1.0
The OWASP Enterprise Security API for C

test/src/user_test.c

Go to the documentation of this file.
00001 #include <string.h>
00002 
00003 #include "user.h"
00004 #include "minunit.h"
00005 
00006 int tests_run = 0;
00007 
00008 void test_user(void)
00009 {
00010    user my_user;  // local version
00011 
00012    (void)fprintf(stdout,"Running test %s\n", __func__);
00013 
00014    init_user(&my_user);  // set local user structure to the initial value
00015 
00016    TEST(my_user.id == 0);
00017    TEST(get_current_id(&my_user) == 0l);
00018    TEST(strcmp(my_user.name, "UNKNOWN") == 0);
00019    TEST(strcmp(set_current_user(&my_user, 0), "UNKNOWN") == 0);
00020    TEST(strcmp(set_current_user(&my_user, "Tester"), "Tester") == 0);
00021    TEST(my_user.locked == 0);
00022    TEST(lock_user(&my_user) == 1);
00023    TEST(lock_user(&my_user) == 0);
00024    TEST(lock_user(0) == -1);
00025    TEST(unlock_user(&my_user) == 1);
00026    TEST(unlock_user(&my_user) == 0);
00027    TEST(unlock_user(0) == -1);
00028 }
00029 
00030 int main(void)
00031 {
00032   test_user();
00033 
00034 
00035   (void)fprintf(stderr,"%s: Pass <%i>, Fail <%i>\n",__FILE__, passed, failed);
00036 
00037    return(EXIT_SUCCESS);
00038 } 
 All Data Structures Files Functions Variables Typedefs Defines