diff options
author | Günther Deschner <gd@samba.org> | 2007-11-27 11:04:51 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2007-12-21 05:46:26 +0100 |
commit | 65c35b80e2c70e03756a5cb305b10c00cd8ac8b3 (patch) | |
tree | bc9929d785655805ecf8c0cec5c552845ffc3cd4 /source4/torture/rpc | |
parent | 238862649cfa2f667915ef6475be54fb1ebff82d (diff) | |
download | samba-65c35b80e2c70e03756a5cb305b10c00cd8ac8b3.tar.gz samba-65c35b80e2c70e03756a5cb305b10c00cd8ac8b3.tar.bz2 samba-65c35b80e2c70e03756a5cb305b10c00cd8ac8b3.zip |
r26153: Add torture test for NetrAddAlternateComputerName() and
NetrRemoveAlternateComputerName().
Guenther
(This used to be commit 77f0b962d6e4eaade039604ad224d802c2302435)
Diffstat (limited to 'source4/torture/rpc')
-rw-r--r-- | source4/torture/rpc/wkssvc.c | 107 |
1 files changed, 105 insertions, 2 deletions
diff --git a/source4/torture/rpc/wkssvc.c b/source4/torture/rpc/wkssvc.c index 7486e8cde5..215ea7546e 100644 --- a/source4/torture/rpc/wkssvc.c +++ b/source4/torture/rpc/wkssvc.c @@ -25,6 +25,7 @@ #include "lib/cmdline/popt_common.h" #include "param/param.h" +#define SMBTORTURE_ALTERNATE_NAME "smbtrt_altname" #define SMBTORTURE_TRANSPORT_NAME "\\Device\\smbtrt_transport_name" #define SMBTORTURE_USE_NAME "S:" @@ -506,11 +507,14 @@ static bool test_NetrLogonDomainNameDel(struct torture_context *tctx, static bool test_NetrEnumerateComputerNames_level(struct torture_context *tctx, struct dcerpc_pipe *p, - uint16_t level) + uint16_t level, + const char ***names, + int *num_names) { NTSTATUS status; struct wkssvc_NetrEnumerateComputerNames r; struct wkssvc_ComputerNamesCtr *ctr; + int i; ctr = talloc_zero(tctx, struct wkssvc_ComputerNamesCtr); @@ -535,6 +539,20 @@ static bool test_NetrEnumerateComputerNames_level(struct torture_context *tctx, return false; } + if (names && num_names) { + *num_names = 0; + *names = NULL; + for (i=0; i<ctr->count; i++) { + if (!add_string_to_array(tctx, + ctr->computer_name[i].string, + names, + num_names)) + { + return false; + } + } + } + return true; } @@ -548,7 +566,8 @@ static bool test_NetrEnumerateComputerNames(struct torture_context *tctx, if (!test_NetrEnumerateComputerNames_level(tctx, p, - levels[i])) + levels[i], + NULL, NULL)) { return false; } @@ -617,6 +636,86 @@ static bool test_NetrValidateName2(struct torture_context *tctx, return true; } +static bool test_NetrAddAlternateComputerName(struct torture_context *tctx, + struct dcerpc_pipe *p) +{ + NTSTATUS status; + struct wkssvc_NetrAddAlternateComputerName r; + const char **names = NULL; + int num_names = 0; + int i; + + r.in.server_name = dcerpc_server_name(p); + r.in.NewAlternateMachineName = SMBTORTURE_ALTERNATE_NAME; + r.in.Account = NULL; + r.in.EncryptedPassword = NULL; + r.in.Reserved = 0; + + torture_comment(tctx, "testing NetrAddAlternateComputerName\n"); + + status = dcerpc_wkssvc_NetrAddAlternateComputerName(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, + "NetrAddAlternateComputerName failed"); + torture_assert_werr_ok(tctx, r.out.result, + "NetrAddAlternateComputerName failed"); + + if (!test_NetrEnumerateComputerNames_level(tctx, p, + NetAlternateComputerNames, + &names, &num_names)) + { + return false; + } + + for (i=0; i<num_names; i++) { + if (strequal(names[i], SMBTORTURE_ALTERNATE_NAME)) { + return true; + } + } + + torture_comment(tctx, "new alternate name not set\n"); + + return false; +} + +static bool test_NetrRemoveAlternateComputerName(struct torture_context *tctx, + struct dcerpc_pipe *p) +{ + NTSTATUS status; + struct wkssvc_NetrRemoveAlternateComputerName r; + const char **names = NULL; + int num_names = 0; + int i; + + r.in.server_name = dcerpc_server_name(p); + r.in.AlternateMachineNameToRemove = SMBTORTURE_ALTERNATE_NAME; + r.in.Account = NULL; + r.in.EncryptedPassword = NULL; + r.in.Reserved = 0; + + torture_comment(tctx, "testing NetrRemoveAlternateComputerName\n"); + + status = dcerpc_wkssvc_NetrRemoveAlternateComputerName(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, + "NetrRemoveAlternateComputerName failed"); + torture_assert_werr_ok(tctx, r.out.result, + "NetrRemoveAlternateComputerName failed"); + + if (!test_NetrEnumerateComputerNames_level(tctx, p, + NetAlternateComputerNames, + &names, &num_names)) + { + return false; + } + + for (i=0; i<num_names; i++) { + if (strequal(names[i], SMBTORTURE_ALTERNATE_NAME)) { + return false; + } + } + + return true; +} + struct torture_suite *torture_rpc_wkssvc(TALLOC_CTX *mem_ctx) { struct torture_suite *suite; @@ -658,6 +757,10 @@ struct torture_suite *torture_rpc_wkssvc(TALLOC_CTX *mem_ctx) test_NetrLogonDomainNameDel); torture_rpc_tcase_add_test(tcase, "NetrLogonDomainNameAdd", test_NetrLogonDomainNameAdd); + torture_rpc_tcase_add_test(tcase, "NetrRemoveAlternateComputerName", + test_NetrRemoveAlternateComputerName); + torture_rpc_tcase_add_test(tcase, "NetrAddAlternateComputerName", + test_NetrAddAlternateComputerName); torture_rpc_tcase_add_test(tcase, "NetrEnumerateComputerNames", test_NetrEnumerateComputerNames); |