s3:rpc_transport_np: handle trans rdata like the output of a normal read
[Samba/cd1.git] / source4 / torture / rpc / oxidresolve.c
blob0008d9d9db0262dd1dc554e54952394b9b82fb06
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 "librpc/gen_ndr/ndr_oxidresolver_c.h"
23 #include "librpc/gen_ndr/ndr_remact_c.h"
24 #include "librpc/gen_ndr/epmapper.h"
25 #include "torture/rpc/rpc.h"
27 #define CLSID_IMAGEDOC "02B01C80-E03D-101A-B294-00DD010F2BF9"
29 const struct GUID IUnknown_uuid = {
30 0x00000000,0x0000,0x0000,{0xc0,0x00},{0x00,0x00,0x00,0x00,0x00,0x46}
33 static bool test_RemoteActivation(struct torture_context *tctx,
34 uint64_t *oxid, struct GUID *oid)
36 struct RemoteActivation r;
37 NTSTATUS status;
38 struct GUID iids[2];
39 uint16_t protseq[3] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID };
40 struct dcerpc_pipe *p;
42 status = torture_rpc_connection(tctx, &p,
43 &ndr_table_IRemoteActivation);
45 if (!NT_STATUS_IS_OK(status)) {
46 return false;
49 ZERO_STRUCT(r.in);
50 r.in.this_object.version.MajorVersion = 5;
51 r.in.this_object.version.MinorVersion = 1;
52 r.in.this_object.cid = GUID_random();
53 GUID_from_string(CLSID_IMAGEDOC, &r.in.Clsid);
54 r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY;
55 r.in.num_protseqs = 3;
56 r.in.protseq = protseq;
57 r.in.Interfaces = 1;
58 iids[0] = IUnknown_uuid;
59 r.in.pIIDs = iids;
60 r.out.pOxid = oxid;
61 r.out.ipidRemUnknown = oid;
63 status = dcerpc_RemoteActivation(p, tctx, &r);
64 if(NT_STATUS_IS_ERR(status)) {
65 fprintf(stderr, "RemoteActivation: %s\n", nt_errstr(status));
66 return false;
69 if(!W_ERROR_IS_OK(r.out.result)) {
70 fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.result));
71 return false;
74 if(!W_ERROR_IS_OK(*r.out.hr)) {
75 fprintf(stderr, "RemoteActivation: %s\n", win_errstr(*r.out.hr));
76 return false;
79 if(!W_ERROR_IS_OK(r.out.results[0])) {
80 fprintf(stderr, "RemoteActivation: %s\n", win_errstr(r.out.results[0]));
81 return false;
84 return true;
87 static bool test_SimplePing(struct torture_context *tctx,
88 struct dcerpc_pipe *p)
90 struct SimplePing r;
91 NTSTATUS status;
92 uint64_t setid;
94 r.in.SetId = &setid;
96 status = dcerpc_SimplePing(p, tctx, &r);
97 torture_assert_ntstatus_ok(tctx, status, "SimplePing");
98 torture_assert_werr_ok(tctx, r.out.result, "SimplePing");
100 return true;
103 static bool test_ComplexPing(struct torture_context *tctx,
104 struct dcerpc_pipe *p)
106 struct ComplexPing r;
107 NTSTATUS status;
108 uint64_t setid;
109 struct GUID oid;
110 uint64_t oxid;
112 if (!test_RemoteActivation(tctx, &oxid, &oid))
113 return false;
115 setid = 0;
116 ZERO_STRUCT(r.in);
118 r.in.SequenceNum = 0;
119 r.in.SetId = &setid;
120 r.in.cAddToSet = 1;
121 r.in.AddToSet = &oid;
123 status = dcerpc_ComplexPing(p, tctx, &r);
124 if(NT_STATUS_IS_ERR(status)) {
125 fprintf(stderr, "ComplexPing: %s\n", nt_errstr(status));
126 return 0;
129 if(!W_ERROR_IS_OK(r.out.result)) {
130 fprintf(stderr, "ComplexPing: %s\n", win_errstr(r.out.result));
131 return 0;
136 return 1;
139 static bool test_ServerAlive(struct torture_context *tctx,
140 struct dcerpc_pipe *p)
142 struct ServerAlive r;
143 NTSTATUS status;
145 status = dcerpc_ServerAlive(p, tctx, &r);
146 torture_assert_ntstatus_ok(tctx, status, "ServerAlive");
147 torture_assert_werr_ok(tctx, r.out.result, "ServerAlive");
149 return true;
152 static bool test_ResolveOxid(struct torture_context *tctx,
153 struct dcerpc_pipe *p)
155 struct ResolveOxid r;
156 NTSTATUS status;
157 uint16_t protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB };
158 uint64_t oxid;
159 struct GUID oid;
161 if (!test_RemoteActivation(tctx, &oxid, &oid))
162 return false;
164 r.in.pOxid = oxid;
165 r.in.cRequestedProtseqs = 2;
166 r.in.arRequestedProtseqs = protseq;
168 status = dcerpc_ResolveOxid(p, tctx, &r);
169 torture_assert_ntstatus_ok(tctx, status, "ResolveOxid");
170 torture_assert_werr_ok(tctx, r.out.result, "ResolveOxid");
172 return true;
175 static bool test_ResolveOxid2(struct torture_context *tctx,
176 struct dcerpc_pipe *p)
178 struct ResolveOxid2 r;
179 NTSTATUS status;
180 uint16_t protseq[2] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB };
181 uint64_t oxid;
182 struct GUID oid;
184 if (!test_RemoteActivation(tctx, &oxid, &oid))
185 return false;
187 r.in.pOxid = oxid;
188 r.in.cRequestedProtseqs = 2;
189 r.in.arRequestedProtseqs = protseq;
191 status = dcerpc_ResolveOxid2(p, tctx, &r);
192 torture_assert_ntstatus_ok(tctx, status, "ResolveOxid2");
194 torture_assert_werr_ok(tctx, r.out.result, "ResolveOxid2");
196 torture_comment(tctx, "Remote server versions: %d, %d\n", r.out.ComVersion->MajorVersion, r.out.ComVersion->MinorVersion);
198 return true;
201 static bool test_ServerAlive2(struct torture_context *tctx,
202 struct dcerpc_pipe *p)
204 struct ServerAlive2 r;
205 NTSTATUS status;
207 status = dcerpc_ServerAlive2(p, tctx, &r);
208 torture_assert_ntstatus_ok(tctx, status, "ServerAlive2");
209 torture_assert_werr_ok(tctx, r.out.result, "ServerAlive2");
211 return true;
214 struct torture_suite *torture_rpc_oxidresolve(TALLOC_CTX *mem_ctx)
216 struct torture_suite *suite = torture_suite_create(mem_ctx,
217 "OXIDRESOLVE");
218 struct torture_rpc_tcase *tcase;
220 tcase = torture_suite_add_rpc_iface_tcase(suite, "oxidresolver",
221 &ndr_table_IOXIDResolver);
223 torture_rpc_tcase_add_test(tcase, "ServerAlive", test_ServerAlive);
225 torture_rpc_tcase_add_test(tcase, "ServerAlive2", test_ServerAlive2);
227 torture_rpc_tcase_add_test(tcase, "ComplexPing", test_ComplexPing);
229 torture_rpc_tcase_add_test(tcase, "SimplePing", test_SimplePing);
231 torture_rpc_tcase_add_test(tcase, "ResolveOxid", test_ResolveOxid);
233 torture_rpc_tcase_add_test(tcase, "ResolveOxid2", test_ResolveOxid2);
235 return suite;