2 Unix SMB/CIFS implementation.
3 test suite for rpc bind operations
5 Copyright (C) Guenther Deschner 2010
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_lsa_c.h"
25 #include "lib/cmdline/popt_common.h"
27 static bool test_openpolicy(struct torture_context
*tctx
,
28 struct dcerpc_pipe
*p
)
30 struct dcerpc_binding_handle
*b
= p
->binding_handle
;
31 struct policy_handle
*handle
;
34 test_lsa_OpenPolicy2(b
, tctx
, &handle
),
35 "failed to open policy");
38 test_lsa_Close(b
, tctx
, handle
),
39 "failed to close policy");
44 static bool test_bind(struct torture_context
*tctx
,
45 const void *private_data
)
47 struct dcerpc_binding
*binding
;
48 struct dcerpc_pipe
*p
;
50 const uint32_t *flags
= (const uint32_t *)private_data
;
52 torture_assert_ntstatus_ok(tctx
,
53 torture_rpc_binding(tctx
, &binding
),
54 "failed to parse binding string");
56 status
= dcerpc_binding_set_flags(binding
, *flags
, DCERPC_AUTH_OPTIONS
);
57 torture_assert_ntstatus_ok(tctx
, status
, "set flags");
59 torture_assert_ntstatus_ok(tctx
,
60 dcerpc_pipe_connect_b(tctx
, &p
, binding
,
62 popt_get_cmdline_credentials(),
65 "failed to connect pipe");
68 test_openpolicy(tctx
, p
),
69 "failed to test openpolicy");
76 static void test_bind_op(struct torture_suite
*suite
,
80 uint32_t *flags_p
= talloc(suite
, uint32_t);
84 torture_suite_add_simple_tcase_const(suite
, name
, test_bind
, flags_p
);
88 struct torture_suite
*torture_rpc_bind(TALLOC_CTX
*mem_ctx
)
90 struct torture_suite
*suite
= torture_suite_create(mem_ctx
, "bind");
92 const char *test_name
;
96 .test_name
= "ntlm,sign",
97 .flags
= DCERPC_AUTH_NTLM
| DCERPC_SIGN
99 .test_name
= "ntlm,sign,seal",
100 .flags
= DCERPC_AUTH_NTLM
| DCERPC_SIGN
| DCERPC_SEAL
102 .test_name
= "spnego,sign",
103 .flags
= DCERPC_AUTH_SPNEGO
| DCERPC_SIGN
105 .test_name
= "spnego,sign,seal",
106 .flags
= DCERPC_AUTH_SPNEGO
| DCERPC_SIGN
| DCERPC_SEAL
111 for (i
=0; i
< ARRAY_SIZE(tests
); i
++) {
112 test_bind_op(suite
, tests
[i
].test_name
, tests
[i
].flags
);
114 for (i
=0; i
< ARRAY_SIZE(tests
); i
++) {
115 test_bind_op(suite
, talloc_asprintf(suite
, "bigendian,%s", tests
[i
].test_name
), tests
[i
].flags
| DCERPC_PUSH_BIGENDIAN
);