2 Unix SMB/CIFS implementation.
4 test suite for dcerpc alter_context operations
6 Copyright (C) Andrew Tridgell 2005
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/>.
23 #include "librpc/gen_ndr/ndr_lsa.h"
24 #include "librpc/gen_ndr/ndr_dssetup.h"
25 #include "torture/rpc/torture_rpc.h"
27 bool torture_rpc_alter_context(struct torture_context
*torture
)
30 struct dcerpc_pipe
*p
, *p2
, *p3
;
31 struct policy_handle
*handle
;
32 struct ndr_interface_table tmptbl
;
33 struct ndr_syntax_id syntax
;
34 struct ndr_syntax_id transfer_syntax
;
37 torture_comment(torture
, "opening LSA connection\n");
38 status
= torture_rpc_connection(torture
, &p
, &ndr_table_lsarpc
);
39 torture_assert_ntstatus_ok(torture
, status
, "connecting");
41 torture_comment(torture
, "Testing change of primary context\n");
42 status
= dcerpc_alter_context(p
, torture
, &p
->syntax
, &p
->transfer_syntax
);
43 torture_assert_ntstatus_ok(torture
, status
, "dcerpc_alter_context failed");
45 if (!test_lsa_OpenPolicy2(p
->binding_handle
, torture
, &handle
)) {
49 torture_comment(torture
, "Testing change of primary context\n");
50 status
= dcerpc_alter_context(p
, torture
, &p
->syntax
, &p
->transfer_syntax
);
51 torture_assert_ntstatus_ok(torture
, status
, "dcerpc_alter_context failed");
53 torture_comment(torture
, "Opening secondary DSSETUP context\n");
54 status
= dcerpc_secondary_context(p
, &p2
, &ndr_table_dssetup
);
55 torture_assert_ntstatus_ok(torture
, status
, "dcerpc_alter_context failed");
57 torture_comment(torture
, "Testing change of primary context\n");
58 status
= dcerpc_alter_context(p2
, torture
, &p2
->syntax
, &p2
->transfer_syntax
);
59 torture_assert_ntstatus_ok(torture
, status
, "dcerpc_alter_context failed");
61 tmptbl
= ndr_table_dssetup
;
62 tmptbl
.syntax_id
.if_version
+= 100;
63 torture_comment(torture
, "Opening bad secondary connection\n");
64 status
= dcerpc_secondary_context(p
, &p3
, &tmptbl
);
65 torture_assert_ntstatus_equal(torture
, status
, NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX
,
66 "dcerpc_alter_context with wrong version should fail");
68 torture_comment(torture
, "Testing DSSETUP pipe operations\n");
69 ret
&= test_DsRoleGetPrimaryDomainInformation(torture
, p2
);
72 ret
&= test_lsa_Close(p
->binding_handle
, torture
, handle
);
76 transfer_syntax
= p
->transfer_syntax
;
78 torture_comment(torture
, "Testing change of primary context\n");
79 status
= dcerpc_alter_context(p
, torture
, &p
->syntax
, &p
->transfer_syntax
);
80 torture_assert_ntstatus_ok(torture
, status
, "dcerpc_alter_context failed");
82 ret
&= test_lsa_OpenPolicy2(p
->binding_handle
, torture
, &handle
);
85 ret
&= test_lsa_Close(p
->binding_handle
, torture
, handle
);
88 torture_comment(torture
, "Testing change of primary context\n");
89 status
= dcerpc_alter_context(p
, torture
, &p2
->syntax
, &p2
->transfer_syntax
);
90 if (NT_STATUS_EQUAL(status
, NT_STATUS_RPC_PROTOCOL_ERROR
)) {
92 ret
&= test_lsa_OpenPolicy2_ex(p
->binding_handle
, torture
, &handle
,
93 NT_STATUS_PIPE_DISCONNECTED
);
96 torture_assert_ntstatus_ok(torture
, status
, "dcerpc_alter_context failed");
98 torture_comment(torture
, "Testing DSSETUP pipe operations - should fault\n");
99 ret
&= test_DsRoleGetPrimaryDomainInformation_ext(torture
, p
, NT_STATUS_RPC_BAD_STUB_DATA
);
101 ret
&= test_lsa_OpenPolicy2(p
->binding_handle
, torture
, &handle
);
104 ret
&= test_lsa_Close(p
->binding_handle
, torture
, handle
);
107 torture_comment(torture
, "Testing DSSETUP pipe operations\n");
109 ret
&= test_DsRoleGetPrimaryDomainInformation(torture
, p2
);