2 Unix SMB/CIFS implementation.
3 test suite for rpc ntsvcs operations
5 Copyright (C) Guenther Deschner 2008
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, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "torture/rpc/torture_rpc.h"
24 #include "librpc/gen_ndr/ndr_ntsvcs_c.h"
26 static bool test_PNP_GetVersion(struct torture_context
*tctx
,
27 struct dcerpc_pipe
*p
)
29 struct dcerpc_binding_handle
*b
= p
->binding_handle
;
31 struct PNP_GetVersion r
;
34 r
.out
.version
= &version
;
36 status
= dcerpc_PNP_GetVersion_r(b
, tctx
, &r
);
38 torture_assert_ntstatus_ok(tctx
, status
, "PNP_GetVersion");
39 torture_assert_werr_ok(tctx
, r
.out
.result
, "PNP_GetVersion");
40 torture_assert_int_equal(tctx
, version
, 0x400, "invalid version");
45 static bool test_PNP_GetDeviceListSize(struct torture_context
*tctx
,
46 struct dcerpc_pipe
*p
)
48 struct dcerpc_binding_handle
*b
= p
->binding_handle
;
49 struct PNP_GetDeviceListSize r
;
52 r
.in
.devicename
= NULL
;
53 r
.in
.flags
= CM_GETIDLIST_FILTER_SERVICE
;
56 torture_assert_ntstatus_ok(tctx
,
57 dcerpc_PNP_GetDeviceListSize_r(b
, tctx
, &r
),
58 "PNP_GetDeviceListSize");
59 torture_assert_werr_equal(tctx
, r
.out
.result
, WERR_CM_INVALID_POINTER
,
60 "PNP_GetDeviceListSize");
62 r
.in
.devicename
= "Spooler";
64 torture_assert_ntstatus_ok(tctx
,
65 dcerpc_PNP_GetDeviceListSize_r(b
, tctx
, &r
),
66 "PNP_GetDeviceListSize");
67 torture_assert_werr_ok(tctx
, r
.out
.result
,
68 "PNP_GetDeviceListSize");
73 static bool test_PNP_GetDeviceList(struct torture_context
*tctx
,
74 struct dcerpc_pipe
*p
)
76 struct dcerpc_binding_handle
*b
= p
->binding_handle
;
77 struct PNP_GetDeviceList r
;
78 uint16_t *buffer
= NULL
;
81 buffer
= talloc_array(tctx
, uint16_t, 0);
84 r
.in
.flags
= CM_GETIDLIST_FILTER_SERVICE
;
85 r
.in
.length
= &length
;
86 r
.out
.length
= &length
;
87 r
.out
.buffer
= buffer
;
89 torture_assert_ntstatus_ok(tctx
,
90 dcerpc_PNP_GetDeviceList_r(b
, tctx
, &r
),
91 "PNP_GetDeviceList failed");
92 torture_assert_werr_equal(tctx
, r
.out
.result
, WERR_CM_INVALID_POINTER
,
93 "PNP_GetDeviceList failed");
95 r
.in
.filter
= "Spooler";
97 torture_assert_ntstatus_ok(tctx
,
98 dcerpc_PNP_GetDeviceList_r(b
, tctx
, &r
),
99 "PNP_GetDeviceList failed");
101 if (W_ERROR_EQUAL(r
.out
.result
, WERR_CM_BUFFER_SMALL
)) {
102 struct PNP_GetDeviceListSize s
;
104 s
.in
.devicename
= "Spooler";
105 s
.in
.flags
= CM_GETIDLIST_FILTER_SERVICE
;
106 s
.out
.size
= &length
;
108 torture_assert_ntstatus_ok(tctx
,
109 dcerpc_PNP_GetDeviceListSize_r(b
, tctx
, &s
),
110 "PNP_GetDeviceListSize failed");
111 torture_assert_werr_ok(tctx
, s
.out
.result
,
112 "PNP_GetDeviceListSize failed");
115 buffer
= talloc_array(tctx
, uint16_t, length
);
117 r
.in
.length
= &length
;
118 r
.out
.length
= &length
;
119 r
.out
.buffer
= buffer
;
121 torture_assert_ntstatus_ok(tctx
,
122 dcerpc_PNP_GetDeviceList_r(b
, tctx
, &r
),
123 "PNP_GetDeviceList failed");
125 torture_assert_werr_ok(tctx
, r
.out
.result
,
126 "PNP_GetDeviceList failed");
131 static bool test_PNP_GetDeviceRegProp(struct torture_context
*tctx
,
132 struct dcerpc_pipe
*p
)
134 struct dcerpc_binding_handle
*b
= p
->binding_handle
;
136 struct PNP_GetDeviceRegProp r
;
138 enum winreg_Type reg_data_type
= REG_NONE
;
139 uint32_t buffer_size
= 0;
143 buffer
= talloc(tctx
, uint8_t);
145 r
.in
.devicepath
= "ACPI\\ACPI0003\\1";
146 r
.in
.property
= DEV_REGPROP_DESC
;
148 r
.in
.reg_data_type
= ®_data_type
;
149 r
.in
.buffer_size
= &buffer_size
;
150 r
.in
.needed
= &needed
;
151 r
.out
.buffer
= buffer
;
152 r
.out
.reg_data_type
= ®_data_type
;
153 r
.out
.buffer_size
= &buffer_size
;
154 r
.out
.needed
= &needed
;
156 status
= dcerpc_PNP_GetDeviceRegProp_r(b
, tctx
, &r
);
157 torture_assert_ntstatus_ok(tctx
, status
, "PNP_GetDeviceRegProp");
159 if (W_ERROR_EQUAL(r
.out
.result
, WERR_CM_BUFFER_SMALL
)) {
161 buffer
= talloc_array(tctx
, uint8_t, needed
);
162 r
.in
.buffer_size
= &needed
;
164 status
= dcerpc_PNP_GetDeviceRegProp_r(b
, tctx
, &r
);
165 torture_assert_ntstatus_ok(tctx
, status
, "PNP_GetDeviceRegProp");
171 struct torture_suite
*torture_rpc_ntsvcs(TALLOC_CTX
*mem_ctx
)
173 struct torture_rpc_tcase
*tcase
;
174 struct torture_suite
*suite
= torture_suite_create(mem_ctx
, "ntsvcs");
175 struct torture_test
*test
;
177 tcase
= torture_suite_add_rpc_iface_tcase(suite
, "ntsvcs",
180 test
= torture_rpc_tcase_add_test(tcase
, "PNP_GetDeviceRegProp",
181 test_PNP_GetDeviceRegProp
);
182 test
= torture_rpc_tcase_add_test(tcase
, "PNP_GetDeviceList",
183 test_PNP_GetDeviceList
);
184 test
= torture_rpc_tcase_add_test(tcase
, "PNP_GetDeviceListSize",
185 test_PNP_GetDeviceListSize
);
186 test
= torture_rpc_tcase_add_test(tcase
, "PNP_GetVersion",
187 test_PNP_GetVersion
);