s4-smbtorture: while testing PrinterDataEx also compare Get and Enum results.
[Samba/nascimento.git] / source4 / torture / rpc / browser.c
blobc9bb9d7ff086ed10ce0d1054f2aa99300e6201b6
1 /*
2 Unix SMB/CIFS implementation.
4 test suite for browser rpc operations
6 Copyright (C) Stefan Metzmacher 2008
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "librpc/gen_ndr/ndr_browser_c.h"
24 #include "torture/rpc/rpc.h"
26 bool test_BrowserrQueryOtherDomains(struct torture_context *tctx,
27 struct dcerpc_pipe *p)
29 struct BrowserrQueryOtherDomains r;
30 struct BrowserrSrvInfo info;
31 struct BrowserrSrvInfo100Ctr ctr100;
32 struct srvsvc_NetSrvInfo100 entries100[1];
33 struct BrowserrSrvInfo101Ctr ctr101;
34 struct srvsvc_NetSrvInfo101 entries101[1];
35 uint32_t total_entries;
36 NTSTATUS status;
38 torture_comment(tctx, "dcerpc_BrowserrQueryOtherDomains\n");
40 ZERO_STRUCT(r);
41 ZERO_STRUCT(info);
42 ZERO_STRUCT(ctr100);
43 ZERO_STRUCT(entries100);
44 ZERO_STRUCT(ctr101);
45 ZERO_STRUCT(entries101);
46 total_entries = 0;
48 r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
49 r.in.info = &info;
50 r.out.info = &info;
51 r.out.total_entries = &total_entries;
53 info.level = 100;
54 info.info.info100 = &ctr100;
56 status = dcerpc_BrowserrQueryOtherDomains(p, tctx, &r);
57 torture_assert_ntstatus_ok(tctx, status, "BrowserrQueryOtherDomains failed");
58 torture_assert_werr_ok(tctx, r.out.result, "BrowserrQueryOtherDomains failed");
59 torture_assert_int_equal(tctx, *r.out.total_entries, 0, "BrowserrQueryOtherDomains");
61 info.info.info100 = &ctr100;
62 ctr100.entries_read = ARRAY_SIZE(entries100);
63 ctr100.entries = entries100;
65 status = dcerpc_BrowserrQueryOtherDomains(p, tctx, &r);
66 torture_assert_ntstatus_ok(tctx, status, "BrowserrQueryOtherDomains failed");
67 torture_assert_werr_ok(tctx, r.out.result, "BrowserrQueryOtherDomains failed");
68 torture_assert_int_equal(tctx, *r.out.total_entries, 0, "BrowserrQueryOtherDomains");
70 info.info.info100 = NULL;
71 status = dcerpc_BrowserrQueryOtherDomains(p, tctx, &r);
72 torture_assert_ntstatus_ok(tctx, status, "BrowserrQueryOtherDomains failed");
73 torture_assert_werr_equal(tctx, WERR_INVALID_PARAM, r.out.result,
74 "BrowserrQueryOtherDomains failed");
76 info.level = 101;
77 info.info.info101 = &ctr101;
79 status = dcerpc_BrowserrQueryOtherDomains(p, tctx, &r);
80 torture_assert_ntstatus_ok(tctx, status, "BrowserrQueryOtherDomains failed");
81 torture_assert_werr_equal(tctx, WERR_UNKNOWN_LEVEL, r.out.result,
82 "BrowserrQueryOtherDomains");
84 info.info.info101 = &ctr101;
85 ctr101.entries_read = ARRAY_SIZE(entries101);
86 ctr101.entries = entries101;
88 status = dcerpc_BrowserrQueryOtherDomains(p, tctx, &r);
89 torture_assert_ntstatus_ok(tctx, status, "BrowserrQueryOtherDomains failed");
90 torture_assert_werr_equal(tctx, WERR_UNKNOWN_LEVEL, r.out.result,
91 "BrowserrQueryOtherDomains");
93 info.info.info101 = NULL;
94 status = dcerpc_BrowserrQueryOtherDomains(p, tctx, &r);
95 torture_assert_ntstatus_ok(tctx, status, "BrowserrQueryOtherDomains failed");
96 torture_assert_werr_equal(tctx, WERR_UNKNOWN_LEVEL, r.out.result,
97 "BrowserrQueryOtherDomains");
99 info.level = 102;
100 status = dcerpc_BrowserrQueryOtherDomains(p, tctx, &r);
101 torture_assert_ntstatus_ok(tctx, status, "BrowserrQueryOtherDomains failed");
102 torture_assert_werr_equal(tctx, WERR_UNKNOWN_LEVEL, r.out.result,
103 "BrowserrQueryOtherDomains");
105 info.level = 0;
106 status = dcerpc_BrowserrQueryOtherDomains(p, tctx, &r);
107 torture_assert_ntstatus_ok(tctx, status, "BrowserrQueryOtherDomains failed");
108 torture_assert_werr_equal(tctx, WERR_UNKNOWN_LEVEL, r.out.result,
109 "BrowserrQueryOtherDomains");
111 return true;
114 struct torture_suite *torture_rpc_browser(TALLOC_CTX *mem_ctx)
116 struct torture_suite *suite = torture_suite_create(mem_ctx, "BROWSER");
117 struct torture_rpc_tcase *tcase = torture_suite_add_rpc_iface_tcase(suite, "browser", &ndr_table_browser);
119 torture_rpc_tcase_add_test(tcase, "BrowserrQueryOtherDomains", test_BrowserrQueryOtherDomains);
121 return suite;