s3 swat: Allow getting the user's HTTP auth password
[Samba.git] / source4 / torture / rpc / oxidresolve.c
blob8e334f453951efe412008407dde1319e77c53ba8
1 /*
2 Unix SMB/CIFS implementation.
3 test suite for oxidresolve operations
5 Copyright (C) Jelmer Vernooij 2004
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "torture/torture.h"
23 #include "librpc/gen_ndr/ndr_oxidresolver_c.h"
24 #include "librpc/gen_ndr/ndr_remact_c.h"
25 #include "librpc/gen_ndr/epmapper.h"
26 #include "torture/rpc/rpc.h"
28 #define CLSID_IMAGEDOC "02B01C80-E03D-101A-B294-00DD010F2BF9"
30 const struct GUID IUnknown_uuid = {
31 0x00000000,0x0000,0x0000,{0xc0,0x00},{0x00,0x00,0x00,0x00,0x00,0x46}
34 static bool test_RemoteActivation(struct torture_context *tctx,
35 uint64_t *oxid, struct GUID *oid)
37 struct RemoteActivation r;
38 NTSTATUS status;
39 struct GUID iids[2];
40 uint16_t protseq[3] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID };
41 struct dcerpc_pipe *p;
43 status = torture_rpc_connection(tctx, &p,
44 &ndr_table_IRemoteActivation);
46 if (!NT_STATUS_IS_OK(status)) {
47 return false;
50 ZERO_STRUCT(r.in);
51 r.in.this_object.version.MajorVersion = 5;
52 r.in.this_object.version.MinorVersion = 1;
53 r.in.this_object.cid = GUID_random();
54 GUID_from_string(CLSID_IMAGEDOC, &r.in.Clsid);
55 r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY;
56 r.in.num_protseqs = 3;
57 r.in.protseq = protseq;
58 r.in.Interfaces = 1;
59 iids[0] = IUnknown_uuid;
60 r.in.pIIDs = iids;
61 r.out.pOxid = oxid;
62 r.out.ipidRemUnknown = oid;
64 status = dcerpc_RemoteActivation(p, tctx, &r);
65 if(NT_STATUS_IS_ERR(status)) {
66 fprintf(stderr, "RemoteActivation: %s\n", nt_errstr(status));
67 return false;
70 if(!W_ERROR_IS_OK(r.out.result)) {
71 fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.result));
72 return false;
75 if(!W_ERROR_IS_OK(*r.out.hr)) {
76 fprintf(stderr, "RemoteActivation: %s\n", win_errstr(*r.out.hr));
77 return false;
80 if(!W_ERROR_IS_OK(r.out.results[0])) {
81 fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.results[0]));
82 return false;
85 return true;
88 static bool test_SimplePing(struct torture_context *tctx,
89 struct dcerpc_pipe *p)
91 struct SimplePing r;
92 NTSTATUS status;
93 uint64_t setid;
95 r.in.SetId = &setid;
97 status = dcerpc_SimplePing(p, tctx, &r);
98 torture_assert_ntstatus_ok(tctx, status, "SimplePing");
99 torture_assert_werr_ok(tctx, r.out.result, "SimplePing");
101 return true;
104 static bool test_ComplexPing(struct torture_context *tctx,
105 struct dcerpc_pipe *p)
107 struct ComplexPing r;
108 NTSTATUS status;
109 uint64_t setid;
110 struct GUID oid;
111 uint64_t oxid;
113 if (!test_RemoteActivation(tctx, &oxid, &oid))
114 return false;
116 setid = 0;
117 ZERO_STRUCT(r.in);
119 r.in.SequenceNum = 0;
120 r.in.SetId = &setid;
121 r.in.cAddToSet = 1;
122 r.in.AddToSet = &oid;
124 status = dcerpc_ComplexPing(p, tctx, &r);
125 if(NT_STATUS_IS_ERR(status)) {
126 fprintf(stderr, "ComplexPing: %s\n", nt_errstr(status));
127 return 0;
130 if(!W_ERROR_IS_OK(r.out.result)) {
131 fprintf(stderr, "ComplexPing: %s\n", win_errstr(r.out.result));
132 return 0;
137 return 1;
140 static bool test_ServerAlive(struct torture_context *tctx,
141 struct dcerpc_pipe *p)
143 struct ServerAlive r;
144 NTSTATUS status;
146 status = dcerpc_ServerAlive(p, tctx, &r);
147 torture_assert_ntstatus_ok(tctx, status, "ServerAlive");
148 torture_assert_werr_ok(tctx, r.out.result, "ServerAlive");
150 return true;
153 static bool test_ResolveOxid(struct torture_context *tctx,
154 struct dcerpc_pipe *p)
156 struct ResolveOxid r;
157 NTSTATUS status;
158 uint16_t protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB };
159 uint64_t oxid;
160 struct GUID oid;
162 if (!test_RemoteActivation(tctx, &oxid, &oid))
163 return false;
165 r.in.pOxid = oxid;
166 r.in.cRequestedProtseqs = 2;
167 r.in.arRequestedProtseqs = protseq;
169 status = dcerpc_ResolveOxid(p, tctx, &r);
170 torture_assert_ntstatus_ok(tctx, status, "ResolveOxid");
171 torture_assert_werr_ok(tctx, r.out.result, "ResolveOxid");
173 return true;
176 static bool test_ResolveOxid2(struct torture_context *tctx,
177 struct dcerpc_pipe *p)
179 struct ResolveOxid2 r;
180 NTSTATUS status;
181 uint16_t protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB };
182 uint64_t oxid;
183 struct GUID oid;
185 if (!test_RemoteActivation(tctx, &oxid, &oid))
186 return false;
188 r.in.pOxid = oxid;
189 r.in.cRequestedProtseqs = 2;
190 r.in.arRequestedProtseqs = protseq;
192 status = dcerpc_ResolveOxid2(p, tctx, &r);
193 torture_assert_ntstatus_ok(tctx, status, "ResolveOxid2");
195 torture_assert_werr_ok(tctx, r.out.result, "ResolveOxid2");
197 torture_comment(tctx, "Remote server versions: %d, %d\n", r.out.ComVersion->MajorVersion, r.out.ComVersion->MinorVersion);
199 return true;
202 static bool test_ServerAlive2(struct torture_context *tctx,
203 struct dcerpc_pipe *p)
205 struct ServerAlive2 r;
206 NTSTATUS status;
208 status = dcerpc_ServerAlive2(p, tctx, &r);
209 torture_assert_ntstatus_ok(tctx, status, "ServerAlive2");
210 torture_assert_werr_ok(tctx, r.out.result, "ServerAlive2");
212 return true;
215 struct torture_suite *torture_rpc_oxidresolve(TALLOC_CTX *mem_ctx)
217 struct torture_suite *suite = torture_suite_create(mem_ctx,
218 "OXIDRESOLVE");
219 struct torture_rpc_tcase *tcase;
221 tcase = torture_suite_add_rpc_iface_tcase(suite, "oxidresolver",
222 &ndr_table_IOXIDResolver);
224 torture_rpc_tcase_add_test(tcase, "ServerAlive", test_ServerAlive);
226 torture_rpc_tcase_add_test(tcase, "ServerAlive2", test_ServerAlive2);
228 torture_rpc_tcase_add_test(tcase, "ComplexPing", test_ComplexPing);
230 torture_rpc_tcase_add_test(tcase, "SimplePing", test_SimplePing);
232 torture_rpc_tcase_add_test(tcase, "ResolveOxid", test_ResolveOxid);
234 torture_rpc_tcase_add_test(tcase, "ResolveOxid2", test_ResolveOxid2);
236 return suite;