--- libaitcfg/example/test_pwd.c 2012/09/19 12:35:10 1.1.2.7 +++ libaitcfg/example/test_pwd.c 2012/09/19 12:43:12 1.1.2.8 @@ -68,39 +68,25 @@ int main() u = (struct tagUser *) cfg_getPasswd(&db, PWD_CRIT_NAME, ""); printf("cfg_getPasswd %p NAME \"\"\n", u); - printf("cfg_setPasswd %p\n", cfg_setPasswd(&db, 3, "use", "alabala", 101, 0, + printf("\n----------\n"); + + /* unit test set */ + printf("cfg_setPasswd %p\n", cfg_setPasswd(&db, 4, "use", "alabala", 101, 4, NULL, 0, 0, NULL, NULL, NULL)); - printf("cfg_setPasswd %p\n", cfg_setPasswd(&db, 4, "use", "alabala", 101, 0, + printf("cfg_setPasswd %p\n", cfg_setPasswd(&db, 3, "use", "alabala", 101, 3, NULL, 0, 0, NULL, NULL, NULL)); + printf("cfg_setPasswd %p\n", cfg_setPasswd(&db, 3, "user_l", "pliok", 999, 3, + NULL, 0, 0, NULL, NULL, NULL)); + printf("cfg_setPasswd %p\n", cfg_setPasswd(&db, 2, "use1", "WC_00", 0, 0, + NULL, 0, 0, NULL, NULL, NULL)); + printf("cfg_setPasswd %p\n", cfg_setPasswd(&db, 0, "USE1", "WC_00", 10000, 20, + NULL, 0, 0, "TEST for use", "/home/USE1", "/bin/sh")); + printf("cfg_setPasswd %p\n", cfg_setPasswd(&db, 0, "USE2", "WC_!!", 10001, 20, + NULL, 0, 0, "TEST for use", "/home/USE2", NULL)); -#if 0 - /* unit test set */ - printf("attr=%d set %d NULL\n", ALL, pwd_SetAttribute(&db, ALL, NULL)); - printf("attr=%d set %d w/ empty\n", ALL, pwd_SetAttribute(&db, ALL, ddd)); - pwdSetValue(&ddd, ALL, "use"); - pwdSetValue(&ddd, Password, "alabala"); - pwdSetValue(&ddd, UID, "101"); - pwdGetValue(ddd, Password, str, 256); - printf("attr=%d set %d use getvalue=%s\n", ALL, pwd_SetAttribute(&db, ALL, ddd), str); - pwdFreeValue(&ddd, ALL); + printf("\n----------\n"); - pwdSetValue(&ddd, ALL, "user_l"); - pwdSetValue(&ddd, UID, "999"); - pwdSetValue(&ddd, Password, "pliok"); - pwdGetValue(ddd, Username, str, 256); - printf("attr=%d %s db=%p ddd=%p set %d\n", ALL, str, db, ddd, pwd_SetAttribute(&db, ALL, ddd)); - pwdSetValue(&ddd, Username, "use"); - pwdSetValue(&ddd, Password, "WC_00"); - printf("2.attr=%d %s db=%p ddd=%p set %d\n", Password, str, db, ddd, pwd_SetAttribute(&db, Password, ddd)); - printf("get fail.attr=%d %s db=%p ddd=%p set %d\n", Password, str, db, ddd, pwd_GetAttribute(db, Password, ddd)); - pwdFreeValue(&ddd, ALL); - /* unit end set */ - /* unit test get */ - pwdSetValue(&ddd, ALL, "user_l"); - printf("GET attr=%d %s db=%p ddd=%p set %d\n", Password, ddd->psPass, db, ddd, pwd_GetAttribute(db, Password, ddd)); - pwdFreeValue(&ddd, ALL); - /* unit end set */ - +#if 0 /* unit test unset */ pwdSetValue(&ddd, ALL, "ttt"); printf("attr=%d Count of array %d w/ NULL \n", Username, pwd_FindAttribute(db, Username, ddd->psUser)); @@ -128,12 +114,12 @@ int main() printf("Access granted - user found at position %d\n", ret); } pwdFreeValue(&ddd, ALL); +#endif - if (CreatePasswd("test4e.pwd", &db)) { - printf("Error #%d - %s\n", pwd_GetErrno(), pwd_GetError()); + if (cfgCreatePasswd("test4e.pwd", &db)) { + printf("Error #%d - %s\n", cfg_GetErrno(), cfg_GetError()); return 2; } -#endif cfgUnloadPasswd(&db); return 0;