summaryrefslogtreecommitdiff
path: root/source4/torture/rpc/epmapper.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2011-01-12 17:41:05 +0100
committerGünther Deschner <gd@samba.org>2011-01-27 14:41:41 +0100
commitdd9feec3df4d4b6c8070467b5a1c85d54f6d7c8e (patch)
tree45272d04edd0c6d3fbf05c7df7c883916149073b /source4/torture/rpc/epmapper.c
parentc3c650623a70f3ccc47c235a52eafc92751afd0e (diff)
downloadsamba-dd9feec3df4d4b6c8070467b5a1c85d54f6d7c8e.tar.gz
samba-dd9feec3df4d4b6c8070467b5a1c85d54f6d7c8e.tar.bz2
samba-dd9feec3df4d4b6c8070467b5a1c85d54f6d7c8e.zip
s4-torture: Added a clean test_Map_simple.
Diffstat (limited to 'source4/torture/rpc/epmapper.c')
-rw-r--r--source4/torture/rpc/epmapper.c94
1 files changed, 77 insertions, 17 deletions
diff --git a/source4/torture/rpc/epmapper.c b/source4/torture/rpc/epmapper.c
index 00bdbb5792..c42f7456f9 100644
--- a/source4/torture/rpc/epmapper.c
+++ b/source4/torture/rpc/epmapper.c
@@ -40,51 +40,54 @@ static void display_tower(struct torture_context *tctx, struct epm_tower *twr)
torture_comment(tctx, "\n");
}
-
static bool test_Map(struct dcerpc_binding_handle *b,
- TALLOC_CTX *mem_ctx,
+ struct torture_context *tctx,
struct epm_twr_t *twr)
{
NTSTATUS status;
struct epm_Map r;
struct GUID uuid;
struct policy_handle handle;
- int i;
struct ndr_syntax_id syntax;
uint32_t num_towers;
+ uint32_t i;
ZERO_STRUCT(uuid);
ZERO_STRUCT(handle);
r.in.object = &uuid;
r.in.map_tower = twr;
- r.in.entry_handle = &handle;
+ r.in.entry_handle = &handle;
r.out.entry_handle = &handle;
- r.in.max_towers = 100;
+ r.in.max_towers = 10;
r.out.num_towers = &num_towers;
dcerpc_floor_get_lhs_data(&twr->tower.floors[0], &syntax);
- printf("epm_Map results for '%s':\n",
- ndr_interface_name(&syntax.uuid, syntax.if_version));
+ torture_comment(tctx,
+ "epm_Map results for '%s':\n",
+ ndr_interface_name(&syntax.uuid, syntax.if_version));
+ /* RPC protocol identifier */
twr->tower.floors[2].lhs.protocol = EPM_PROTOCOL_NCACN;
twr->tower.floors[2].lhs.lhs_data = data_blob(NULL, 0);
twr->tower.floors[2].rhs.ncacn.minor_version = 0;
+ /* Port address */
twr->tower.floors[3].lhs.protocol = EPM_PROTOCOL_TCP;
twr->tower.floors[3].lhs.lhs_data = data_blob(NULL, 0);
twr->tower.floors[3].rhs.tcp.port = 0;
+ /* Transport */
twr->tower.floors[4].lhs.protocol = EPM_PROTOCOL_IP;
twr->tower.floors[4].lhs.lhs_data = data_blob(NULL, 0);
twr->tower.floors[4].rhs.ip.ipaddr = "0.0.0.0";
- status = dcerpc_epm_Map_r(b, mem_ctx, &r);
+ status = dcerpc_epm_Map_r(b, tctx, &r);
if (NT_STATUS_IS_OK(status) && r.out.result == 0) {
for (i=0;i<*r.out.num_towers;i++) {
if (r.out.towers[i].twr) {
- display_tower(mem_ctx, &r.out.towers[i].twr->tower);
+ display_tower(tctx, &r.out.towers[i].twr->tower);
}
}
}
@@ -93,11 +96,11 @@ static bool test_Map(struct dcerpc_binding_handle *b,
twr->tower.floors[3].lhs.lhs_data = data_blob(NULL, 0);
twr->tower.floors[3].rhs.http.port = 0;
- status = dcerpc_epm_Map_r(b, mem_ctx, &r);
+ status = dcerpc_epm_Map_r(b, tctx, &r);
if (NT_STATUS_IS_OK(status) && r.out.result == 0) {
for (i=0;i<*r.out.num_towers;i++) {
if (r.out.towers[i].twr) {
- display_tower(mem_ctx, &r.out.towers[i].twr->tower);
+ display_tower(tctx, &r.out.towers[i].twr->tower);
}
}
}
@@ -106,11 +109,11 @@ static bool test_Map(struct dcerpc_binding_handle *b,
twr->tower.floors[3].lhs.lhs_data = data_blob(NULL, 0);
twr->tower.floors[3].rhs.http.port = 0;
- status = dcerpc_epm_Map_r(b, mem_ctx, &r);
+ status = dcerpc_epm_Map_r(b, tctx, &r);
if (NT_STATUS_IS_OK(status) && r.out.result == 0) {
for (i=0;i<*r.out.num_towers;i++) {
if (r.out.towers[i].twr) {
- display_tower(mem_ctx, &r.out.towers[i].twr->tower);
+ display_tower(tctx, &r.out.towers[i].twr->tower);
}
}
}
@@ -123,17 +126,70 @@ static bool test_Map(struct dcerpc_binding_handle *b,
twr->tower.floors[4].lhs.lhs_data = data_blob(NULL, 0);
twr->tower.floors[4].rhs.netbios.name = "";
- status = dcerpc_epm_Map_r(b, mem_ctx, &r);
+ status = dcerpc_epm_Map_r(b, tctx, &r);
if (NT_STATUS_IS_OK(status) && r.out.result == 0) {
- for (i=0;i<*r.out.num_towers;i++) {
+ for (i = 0; i < *r.out.num_towers; i++) {
if (r.out.towers[i].twr) {
- display_tower(mem_ctx, &r.out.towers[i].twr->tower);
+ display_tower(tctx, &r.out.towers[i].twr->tower);
}
}
}
/* FIXME: Extend to do other protocols as well (ncacn_unix_stream, ncalrpc) */
-
+
+ return true;
+}
+
+static bool test_Map_simple(struct torture_context *tctx,
+ struct dcerpc_pipe *p)
+{
+ NTSTATUS status;
+ struct epm_Lookup r;
+ struct policy_handle entry_handle;
+ uint32_t num_ents = 0;
+ struct dcerpc_binding_handle *h = p->binding_handle;
+
+ ZERO_STRUCT(entry_handle);
+
+ torture_comment(tctx, "Testing epm_Map\n");
+
+ /* get all elements */
+ r.in.inquiry_type = RPC_C_EP_ALL_ELTS;
+ r.in.object = NULL;
+ r.in.interface_id = NULL;
+ r.in.vers_option = RPC_C_VERS_ALL;
+
+ r.in.entry_handle = &entry_handle;
+ r.in.max_ents = 10;
+
+ r.out.entry_handle = &entry_handle;
+ r.out.num_ents = &num_ents;
+
+ do {
+ int i;
+
+ status = dcerpc_epm_Lookup_r(h, tctx, &r);
+ if (!NT_STATUS_IS_OK(status) ||
+ r.out.result != EPMAPPER_STATUS_OK) {
+ break;
+ }
+
+ for (i = 0; i < *r.out.num_ents; i++) {
+ if (r.out.entries[i].tower->tower.num_floors == 5) {
+ test_Map(h, tctx, r.out.entries[i].tower);
+ }
+ }
+ } while (NT_STATUS_IS_OK(status) &&
+ r.out.result == EPMAPPER_STATUS_OK &&
+ *r.out.num_ents == r.in.max_ents &&
+ !policy_handle_empty(&entry_handle));
+
+ torture_assert_ntstatus_ok(tctx, status, "epm_Map_simple failed");
+
+ torture_assert(tctx,
+ policy_handle_empty(&entry_handle),
+ "epm_Map_simple failed - The policy handle should be emtpy.");
+
return true;
}
@@ -402,6 +458,10 @@ struct torture_suite *torture_rpc_epmapper(TALLOC_CTX *mem_ctx)
torture_rpc_tcase_add_test(tcase,
"Lookup_simple",
test_Lookup_simple);
+ torture_rpc_tcase_add_test(tcase,
+ "Map_simple",
+ test_Map_simple);
+
return suite;
}