Fix up the libnet tests.
authorAndrew Bartlett <abartlet@samba.org>
Wed, 27 Feb 2008 23:32:06 +0000 (10:32 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 27 Feb 2008 23:32:06 +0000 (10:32 +1100)
These tests still do not pass against windows, but at least now it
doesn't reset acct_flags to 0.

This is enough to have Samba4 pass it's own tests for the moment.

Andrew Bartlett

source/torture/libnet/libnet_user.c
source/torture/libnet/userman.c

index 94711c1dead968eba847ee8088ce66743e6f82ba..31300a793774606eb9d1781a7e1de348d74d495c 100644 (file)
@@ -339,6 +339,9 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r,
        const char* logon_scripts[] = { "start_login.cmd", "login.bat", "start.cmd" };
        const char* home_dirs[] = { "\\\\srv\\home", "\\\\homesrv\\home\\user", "\\\\pdcsrv\\domain" };
        const char* home_drives[] = { "H:", "z:", "I:", "J:", "n:" };
+       const uint32_t flags[] = { (ACB_DISABLED | ACB_NORMAL),
+                                  (ACB_NORMAL | ACB_PWNOEXP),
+                                  (ACB_NORMAL) };
        const char *homedir, *homedrive, *logonscript;
        struct timeval now;
        int i, testfld;
@@ -380,14 +383,14 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r,
 
                case home_directory:
                        continue_if_field_set(r->in.home_directory);
-                       homedir = home_dirs[random() % (sizeof(home_dirs)/sizeof(char*))];
+                       homedir = home_dirs[random() % ARRAY_SIZE(home_dirs)];
                        r->in.home_directory = talloc_strdup(mem_ctx, homedir);
                        fldname = "home_dir";
                        break;
 
                case home_drive:
                        continue_if_field_set(r->in.home_drive);
-                       homedrive = home_drives[random() % (sizeof(home_drives)/sizeof(char*))];
+                       homedrive = home_drives[random() % ARRAY_SIZE(home_drives)];
                        r->in.home_drive = talloc_strdup(mem_ctx, homedrive);
                        fldname = "home_drive";
                        break;
@@ -401,7 +404,7 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r,
 
                case logon_script:
                        continue_if_field_set(r->in.logon_script);
-                       logonscript = logon_scripts[random() % (sizeof(logon_scripts)/sizeof(char*))];
+                       logonscript = logon_scripts[random() % ARRAY_SIZE(logon_scripts)];
                        r->in.logon_script = talloc_strdup(mem_ctx, logonscript);
                        fldname = "logon_script";
                        break;
@@ -420,6 +423,12 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r,
                        fldname = "acct_expiry";
                        break;
 
+               case acct_flags:
+                       continue_if_field_set(r->in.acct_flags);
+                       r->in.acct_flags = flags[random() % ARRAY_SIZE(flags)];
+                       fldname = "acct_flags";
+                       break;
+
                default:
                        fldname = "unknown_field";
                }
index 0d08284a9f955e2220bd1ac36221093fd3b84023..1d630e5ecdb3c08ea86a17a9e7a8076ac33e2f22 100644 (file)
@@ -189,7 +189,7 @@ static bool test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
 
                case acct_flags:
                        continue_if_field_set(mod->in.change.acct_flags);
-                       mod->in.change.acct_flags = flags[random() % (sizeof(flags)/sizeof(uint32_t))];
+                       mod->in.change.acct_flags = flags[random() % ARRAY_SIZE(flags)];
                        mod->in.change.fields |= USERMOD_FIELD_ACCT_FLAGS;
                        fldname = "acct_flags";
                        break;