diff options
author | Rafal Szczesniak <mimir@samba.org> | 2006-09-19 00:27:49 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:19:00 -0500 |
commit | 07fb9f2f048a79445dc75cbe2c1061d9796fca67 (patch) | |
tree | 954dbda327add10bd708175d41637fc3014c4746 | |
parent | 1ba24e868072e45e435c246b7b0c8782f5da9386 (diff) | |
download | samba-07fb9f2f048a79445dc75cbe2c1061d9796fca67.tar.gz samba-07fb9f2f048a79445dc75cbe2c1061d9796fca67.tar.bz2 samba-07fb9f2f048a79445dc75cbe2c1061d9796fca67.zip |
r18658: make the test change fields sequentially each one in turn.
now to multiple changes...
rafal
(This used to be commit 6df2c04e03ac6b7d518edfee7fd6a5de299bf9d4)
-rw-r--r-- | source4/torture/libnet/libnet_user.c | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c index 1a8f4345f2..e70060b8c9 100644 --- a/source4/torture/libnet/libnet_user.c +++ b/source4/torture/libnet/libnet_user.c @@ -330,6 +330,7 @@ done: continue; \ } +const int fields_num = 15; enum test_fields { none = 0, account_name, full_name, description, home_directory, home_drive, comment, logon_script, profile_path, acct_expiry, allow_password_change, force_password_change, last_logon, last_logoff, last_password_change }; @@ -337,7 +338,6 @@ enum test_fields { none = 0, account_name, full_name, description, home_director static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r, int num_changes, char **user_name, enum test_fields req_change) { - const int num_fields = 14; 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:" }; @@ -349,10 +349,10 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r, i printf("Fields to change: ["); - for (i = 0; i < num_changes && i < num_fields; i++) { + for (i = 0; i < num_changes && i < fields_num; i++) { const char *fldname; - testfld = (req_change == none) ? (random() % num_fields) : req_change; + testfld = (req_change == none) ? (random() % fields_num) : req_change; /* get one in case we hit time field this time */ gettimeofday(&now, NULL); @@ -485,6 +485,7 @@ BOOL torture_modifyuser(struct torture_context *torture) char *name; struct libnet_context *ctx; struct libnet_ModifyUser req; + int fld; BOOL ret = True; prep_mem_ctx = talloc_init("prepare test_deleteuser"); @@ -522,19 +523,41 @@ BOOL torture_modifyuser(struct torture_context *torture) goto done; } - ZERO_STRUCT(req); - req.in.domain_name = lp_workgroup(); - req.in.user_name = name; - - printf("Testing change of a single field\n"); - set_test_changes(mem_ctx, &req, 1, &name, none); - - status = libnet_ModifyUser(ctx, mem_ctx, &req); - if (!NT_STATUS_IS_OK(status)) { - printf("libnet_ModifyUser call failed: %s\n", nt_errstr(status)); - talloc_free(mem_ctx); - ret = False; - goto done; + printf("Testing change of all fields - each single one in turn\n"); + + for (fld = 1; fld < fields_num; fld++) { + ZERO_STRUCT(req); + req.in.domain_name = lp_workgroup(); + req.in.user_name = name; + + set_test_changes(mem_ctx, &req, 1, &name, fld); + + status = libnet_ModifyUser(ctx, mem_ctx, &req); + if (!NT_STATUS_IS_OK(status)) { + printf("libnet_ModifyUser call failed: %s\n", nt_errstr(status)); + talloc_free(mem_ctx); + ret = False; + goto done; + } + + if (fld == account_name) { + /* restore original testing username - it's useful when test fails + because it prevents from problems with recreating account */ + ZERO_STRUCT(req); + req.in.domain_name = lp_workgroup(); + req.in.user_name = name; + req.in.account_name = TEST_USERNAME; + + status = libnet_ModifyUser(ctx, mem_ctx, &req); + if (!NT_STATUS_IS_OK(status)) { + printf("libnet_ModifyUser call failed: %s\n", nt_errstr(status)); + talloc_free(mem_ctx); + ret = False; + goto done; + } + + name = TEST_USERNAME; + } } if (!test_cleanup(ctx->samr.pipe, mem_ctx, &ctx->samr.handle, name)) { |