diff options
author | Rafal Szczesniak <mimir@samba.org> | 2006-10-02 06:00:14 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:20:29 -0500 |
commit | 94bc020f84c6e53552a2c0dba01ae81c69983196 (patch) | |
tree | e319c3b19b2d16e638d6a841f10419ad925e4797 | |
parent | 89e4387a08fd90176161d0139ed3b4c3c2c1289c (diff) | |
download | samba-94bc020f84c6e53552a2c0dba01ae81c69983196.tar.gz samba-94bc020f84c6e53552a2c0dba01ae81c69983196.tar.bz2 samba-94bc020f84c6e53552a2c0dba01ae81c69983196.zip |
r19025: - remove read-only and policy dependent fields and flags
- do not stop NET-API-USERMODIFY test when a single field fails
- add account flags to the fields tested
- separate "cleanup" step from closing domain at the end
rafal
(This used to be commit 16fde3b8e2c93ec10e43bb09334bf460db8ac70b)
-rw-r--r-- | source4/torture/libnet/libnet_user.c | 105 | ||||
-rw-r--r-- | source4/torture/libnet/userman.c | 64 | ||||
-rw-r--r-- | source4/torture/libnet/usertest.h | 5 |
3 files changed, 81 insertions, 93 deletions
diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c index 10522d21c1..231afd6a0d 100644 --- a/source4/torture/libnet/libnet_user.c +++ b/source4/torture/libnet/libnet_user.c @@ -343,11 +343,11 @@ void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r, int num_ case account_name: continue_if_field_set(r->in.account_name); r->in.account_name = talloc_asprintf(mem_ctx, TEST_CHG_ACCOUNTNAME, - (int)random()); + (int)(random() % 100)); fldname = "account_name"; /* update the test's user name in case it's about to change */ - *user_name = r->in.account_name; + *user_name = talloc_strdup(mem_ctx, r->in.account_name); break; case full_name: @@ -406,41 +406,6 @@ void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r, int num_ fldname = "acct_expiry"; break; - case allow_password_change: - continue_if_field_set(r->in.allow_password_change); - now = timeval_add(&now, (random() % (31*24*60*60)), 0); - r->in.allow_password_change = talloc_memdup(mem_ctx, &now, sizeof(now)); - fldname = "allow_password_change"; - break; - - case force_password_change: - continue_if_field_set(r->in.force_password_change); - now = timeval_add(&now, (random() % (31*24*60*60)), 0); - r->in.force_password_change = talloc_memdup(mem_ctx, &now, sizeof(now)); - fldname = "force_password_change"; - break; - - case last_logon: - continue_if_field_set(r->in.last_logon); - now = timeval_add(&now, (random() % (31*24*60*60)), 0); - r->in.last_logon = talloc_memdup(mem_ctx, &now, sizeof(now)); - fldname = "last_logon"; - break; - - case last_logoff: - continue_if_field_set(r->in.last_logoff); - now = timeval_add(&now, (random() % (31*24*60*60)), 0); - r->in.last_logoff = talloc_memdup(mem_ctx, &now, sizeof(now)); - fldname = "last_logoff"; - break; - - case last_password_change: - continue_if_field_set(r->in.last_password_change); - now = timeval_add(&now, (random() % (31*24*60*60)), 0); - r->in.last_password_change = talloc_memdup(mem_ctx, &now, sizeof(now)); - fldname = "last_password_change"; - break; - default: fldname = "unknown_field"; } @@ -455,6 +420,28 @@ void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r, int num_ } +#define TEST_STR_FLD(fld) \ + if (!strequal(req.in.fld, user_req.out.fld)) { \ + printf("failed to change '%s'\n", #fld); \ + ret = False; \ + goto cleanup; \ + } + +#define TEST_TIME_FLD(fld) \ + if (timeval_compare(req.in.fld, user_req.out.fld)) { \ + printf("failed to change '%s'\n", #fld); \ + ret = False; \ + goto cleanup; \ + } + +#define TEST_NUM_FLD(fld) \ + if (req.in.fld != user_req.out.fld) { \ + printf("failed to change '%s'\n", #fld); \ + ret = False; \ + goto cleanup; \ + } + + BOOL torture_modifyuser(struct torture_context *torture) { NTSTATUS status; @@ -467,6 +454,7 @@ BOOL torture_modifyuser(struct torture_context *torture) char *name; struct libnet_context *ctx; struct libnet_ModifyUser req; + struct libnet_UserInfo user_req; int fld; BOOL ret = True; @@ -507,7 +495,7 @@ BOOL torture_modifyuser(struct torture_context *torture) printf("Testing change of all fields - each single one in turn\n"); - for (fld = 1; fld < FIELDS_NUM; fld++) { + for (fld = 1; fld < FIELDS_NUM - 1; fld++) { ZERO_STRUCT(req); req.in.domain_name = lp_workgroup(); req.in.user_name = name; @@ -517,9 +505,43 @@ BOOL torture_modifyuser(struct torture_context *torture) 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; + continue; + } + + ZERO_STRUCT(user_req); + user_req.in.domain_name = lp_workgroup(); + user_req.in.user_name = name; + + status = libnet_UserInfo(ctx, mem_ctx, &user_req); + if (!NT_STATUS_IS_OK(status)) { + printf("libnet_UserInfo call failed: %s\n", nt_errstr(status)); + continue; + } + + switch (fld) { + case account_name: TEST_STR_FLD(account_name); + break; + case full_name: TEST_STR_FLD(full_name); + break; + case comment: TEST_STR_FLD(comment); + break; + case description: TEST_STR_FLD(description); + break; + case home_directory: TEST_STR_FLD(home_directory); + break; + case home_drive: TEST_STR_FLD(home_drive); + break; + case logon_script: TEST_STR_FLD(logon_script); + break; + case profile_path: TEST_STR_FLD(profile_path); + break; + case acct_expiry: TEST_TIME_FLD(acct_expiry); + break; + case acct_flags: TEST_NUM_FLD(acct_flags); + break; + default: + break; } if (fld == account_name) { @@ -538,10 +560,11 @@ BOOL torture_modifyuser(struct torture_context *torture) goto done; } - name = TEST_USERNAME; + name = talloc_strdup(mem_ctx, TEST_USERNAME); } } +cleanup: if (!test_cleanup(ctx->samr.pipe, mem_ctx, &ctx->samr.handle, name)) { printf("cleanup failed\n"); ret = False; diff --git a/source4/torture/libnet/userman.c b/source4/torture/libnet/userman.c index d163d00da3..654994fdc3 100644 --- a/source4/torture/libnet/userman.c +++ b/source4/torture/libnet/userman.c @@ -262,6 +262,9 @@ static BOOL test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char* home_dirs[] = { "\\\\srv\\home", "\\\\homesrv\\home\\user", "\\\\pdcsrv\\domain" }; const char* home_drives[] = { "H:", "z:", "I:", "J:", "n:" }; const char *homedir, *homedrive, *logonscript; + const uint32_t flags[] = { (ACB_DISABLED | ACB_NORMAL), + (ACB_NORMAL | ACB_PWNOEXP), + (ACB_NORMAL | ACB_PW_EXPIRED) }; NTSTATUS status; struct timeval now; @@ -278,10 +281,10 @@ static BOOL test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("fields to change: ["); - for (i = 0; i < num_changes && i < FIELDS_NUM; i++) { + for (i = 0; i < num_changes && i < FIELDS_NUM - 1; i++) { const char *fldname; - testfld = random() % (FIELDS_NUM - 1); + testfld = (random() % (FIELDS_NUM - 1)) + 1; gettimeofday(&now, NULL); @@ -359,44 +362,11 @@ static BOOL test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, fldname = "acct_expiry"; break; - case allow_password_change: - continue_if_field_set(mod->in.change.allow_password_change); - now = timeval_add(&now, (random() % (31*24*60*60)), 0); - mod->in.change.allow_password_change = talloc_memdup(mem_ctx, &now, sizeof(now)); - mod->in.change.fields |= USERMOD_FIELD_ALLOW_PASS_CHG; - fldname = "allow_password_change"; - break; - - case force_password_change: - continue_if_field_set(mod->in.change.force_password_change); - now = timeval_add(&now, (random() % (31*24*60*60)), 0); - mod->in.change.force_password_change = talloc_memdup(mem_ctx, &now, sizeof(now)); - mod->in.change.fields |= USERMOD_FIELD_FORCE_PASS_CHG; - fldname = "force_password_change"; - break; - - case last_logon: - continue_if_field_set(mod->in.change.last_logon); - now = timeval_add(&now, (random() % (31*24*60*60)), 0); - mod->in.change.last_logon = talloc_memdup(mem_ctx, &now, sizeof(now)); - mod->in.change.fields |= USERMOD_FIELD_LAST_LOGON; - fldname = "last_logon"; - break; - - case last_logoff: - continue_if_field_set(mod->in.change.last_logoff); - now = timeval_add(&now, (random() % (31*24*60*60)), 0); - mod->in.change.last_logoff = talloc_memdup(mem_ctx, &now, sizeof(now)); - mod->in.change.fields |= USERMOD_FIELD_LAST_LOGOFF; - fldname = "last_logoff"; - break; - - case last_password_change: - continue_if_field_set(mod->in.change.last_password_change); - now = timeval_add(&now, (random() % (31*24*60*60)), 0); - mod->in.change.last_password_change = talloc_memdup(mem_ctx, &now, sizeof(now)); - mod->in.change.fields |= USERMOD_FIELD_LAST_PASS_CHG; - fldname = "last_password_change"; + 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.fields |= USERMOD_FIELD_ACCT_EXPIRY; + fldname = "acct_flags"; break; default: @@ -500,11 +470,6 @@ static BOOL test_compare(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, CMP_LSA_STRING_FLD(home_directory, USERMOD_FIELD_HOME_DIRECTORY); CMP_LSA_STRING_FLD(home_drive, USERMOD_FIELD_HOME_DRIVE); CMP_TIME_FLD(acct_expiry, USERMOD_FIELD_ACCT_EXPIRY); - CMP_TIME_FLD(allow_password_change, USERMOD_FIELD_ALLOW_PASS_CHG); - CMP_TIME_FLD(force_password_change, USERMOD_FIELD_FORCE_PASS_CHG); - CMP_TIME_FLD(last_logon, USERMOD_FIELD_LAST_LOGON); - CMP_TIME_FLD(last_logoff, USERMOD_FIELD_LAST_LOGOFF); - CMP_TIME_FLD(last_password_change, USERMOD_FIELD_LAST_PASS_CHG); CMP_NUM_FLD(acct_flags, USERMOD_FIELD_ACCT_FLAGS) return True; @@ -650,21 +615,22 @@ BOOL torture_usermod(struct torture_context *torture) ret = False; goto done; } - - for (i = 1; i < 8; i++) { + + for (i = 1; i < FIELDS_NUM; i++) { struct libnet_rpc_usermod m; if (!test_usermod(p, mem_ctx, &h, i, &m, &name)) { ret = False; - goto done; + goto cleanup; } if (!test_compare(p, mem_ctx, &h, &m, name)) { ret = False; - goto done; + goto cleanup; } } +cleanup: if (!test_cleanup(p, mem_ctx, &h, name)) { ret = False; goto done; diff --git a/source4/torture/libnet/usertest.h b/source4/torture/libnet/usertest.h index 8da32d70aa..717c1e6578 100644 --- a/source4/torture/libnet/usertest.h +++ b/source4/torture/libnet/usertest.h @@ -27,10 +27,9 @@ } -#define FIELDS_NUM 15 +#define FIELDS_NUM 11 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 }; + comment, logon_script, profile_path, acct_expiry, acct_flags }; #define TEST_CHG_ACCOUNTNAME "newlibnetusertest%02d" |