r14402: Generate seperate headers for RPC client functions.
[samba.git] / source4 / torture / rpc / remact.c
1 /* 
2    Unix SMB/CIFS implementation.
3    test suite for remoteactivation operations
4
5    Copyright (C) Jelmer Vernooij 2004
6    
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 2 of the License, or
10    (at your option) any later version.
11    
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.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #include "includes.h"
23 #include "torture/torture.h"
24 #include "librpc/gen_ndr/ndr_remact.h"
25 #include "librpc/gen_ndr/ndr_remact_c.h"
26 #include "librpc/gen_ndr/ndr_epmapper.h"
27 #include "librpc/gen_ndr/ndr_epmapper_c.h"
28 #include "torture/rpc/rpc.h"
29
30 #define CLSID_IMAGEDOC "02B01C80-E03D-101A-B294-00DD010F2BF9"
31
32 static int test_RemoteActivation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
33 {
34         struct RemoteActivation r;
35         NTSTATUS status;
36         struct GUID iids[1];
37         uint16_t protseq[3] = { EPM_PROTOCOL_TCP, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID };
38
39         ZERO_STRUCT(r.in);
40         r.in.this.version.MajorVersion = 5;
41         r.in.this.version.MinorVersion = 1;
42         r.in.this.cid = GUID_random();
43         GUID_from_string(CLSID_IMAGEDOC, &r.in.Clsid);
44         r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY;
45         r.in.num_protseqs = 3;
46         r.in.protseq = protseq;
47         r.in.Interfaces = 1;
48         GUID_from_string(DCERPC_IUNKNOWN_UUID, &iids[0]);
49         r.in.pIIDs = iids;
50
51         status = dcerpc_RemoteActivation(p, mem_ctx, &r);
52         if(NT_STATUS_IS_ERR(status)) {
53                 printf("RemoteActivation: %s\n", nt_errstr(status));
54                 return 0;
55         }
56
57         if(!W_ERROR_IS_OK(r.out.result)) {
58                 printf("RemoteActivation: %s\n", win_errstr(r.out.result));
59                 return 0;
60         }
61
62         if(!W_ERROR_IS_OK(r.out.hr)) {
63                 printf("RemoteActivation: %s\n", win_errstr(r.out.hr));
64                 return 0;
65         }
66
67         if(!W_ERROR_IS_OK(r.out.results[0])) {
68                 printf("RemoteActivation: %s\n", win_errstr(r.out.results[0]));
69                 return 0;
70         }
71
72         GUID_from_string(DCERPC_ICLASSFACTORY_UUID, &iids[0]);
73         r.in.Interfaces = 1;
74         r.in.Mode = MODE_GET_CLASS_OBJECT;
75
76         status = dcerpc_RemoteActivation(p, mem_ctx, &r);
77         if(NT_STATUS_IS_ERR(status)) {
78                 printf("RemoteActivation(GetClassObject): %s\n", nt_errstr(status));
79                 return 0;
80         }
81
82         if(!W_ERROR_IS_OK(r.out.result)) {
83                 printf("RemoteActivation(GetClassObject): %s\n", win_errstr(r.out.result));
84                 return 0;
85         }
86
87         if(!W_ERROR_IS_OK(r.out.hr)) {
88                 printf("RemoteActivation(GetClassObject): %s\n", win_errstr(r.out.hr));
89                 return 0;
90         }
91
92         if(!W_ERROR_IS_OK(r.out.results[0])) {
93                 printf("RemoteActivation(GetClassObject): %s\n", win_errstr(r.out.results[0]));
94                 return 0;
95         }
96
97         return 1;
98 }
99
100 BOOL torture_rpc_remact(void)
101 {
102         NTSTATUS status;
103         struct dcerpc_pipe *p;
104         TALLOC_CTX *mem_ctx;
105         BOOL ret = True;
106
107         mem_ctx = talloc_init("torture_rpc_remact");
108
109         status = torture_rpc_connection(mem_ctx,
110                                         &p, 
111                                         &dcerpc_table_IRemoteActivation);
112
113         if (!NT_STATUS_IS_OK(status)) {
114                 talloc_free(mem_ctx);
115                 return False;
116         }
117
118         if(!test_RemoteActivation(p, mem_ctx))
119                 ret = False;
120
121         talloc_free(mem_ctx);
122
123         return ret;
124 }