RPC-ALTERCONTEXT: let the test pass against w2k3 and w2k8
authorStefan Metzmacher <metze@samba.org>
Fri, 9 Apr 2010 07:03:43 +0000 (09:03 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 9 Apr 2010 14:28:31 +0000 (16:28 +0200)
The behavior between w2k3 and w2k8 differs:
- w2k3 just ignores alter_context requests which try to change
  an existing presentation context.
- w2k8 returns DERPC_NCA_S_PROTO_ERROR and closes the transport
  connection.

metze

source4/torture/rpc/alter_context.c

index 08d938ebbb0d9e0e2dde611002b183e6d7434d00..c3a992b05fd9c14eb994e3d80fdeb818c9a979d4 100644 (file)
@@ -38,14 +38,26 @@ bool torture_rpc_alter_context(struct torture_context *torture)
        status = torture_rpc_connection(torture, &p, &ndr_table_lsarpc);
        torture_assert_ntstatus_ok(torture, status, "connecting");
 
+       torture_comment(torture, "Testing change of primary context\n");
+       status = dcerpc_alter_context(p, torture, &p->syntax, &p->transfer_syntax);
+       torture_assert_ntstatus_ok(torture, status, "dcerpc_alter_context failed");
+
        if (!test_lsa_OpenPolicy2(p->binding_handle, torture, &handle)) {
                ret = false;
        }
 
+       torture_comment(torture, "Testing change of primary context\n");
+       status = dcerpc_alter_context(p, torture, &p->syntax, &p->transfer_syntax);
+       torture_assert_ntstatus_ok(torture, status, "dcerpc_alter_context failed");
+
        torture_comment(torture, "Opening secondary DSSETUP context\n");
        status = dcerpc_secondary_context(p, &p2, &ndr_table_dssetup);
        torture_assert_ntstatus_ok(torture, status, "dcerpc_alter_context failed");
 
+       torture_comment(torture, "Testing change of primary context\n");
+       status = dcerpc_alter_context(p2, torture, &p2->syntax, &p2->transfer_syntax);
+       torture_assert_ntstatus_ok(torture, status, "dcerpc_alter_context failed");
+
        tmptbl = ndr_table_dssetup;
        tmptbl.syntax_id.if_version += 100;
        torture_comment(torture, "Opening bad secondary connection\n");
@@ -63,8 +75,26 @@ bool torture_rpc_alter_context(struct torture_context *torture)
        syntax = p->syntax;
        transfer_syntax = p->transfer_syntax;
 
+       torture_comment(torture, "Testing change of primary context\n");
+       status = dcerpc_alter_context(p, torture, &p->syntax, &p->transfer_syntax);
+       torture_assert_ntstatus_ok(torture, status, "dcerpc_alter_context failed");
+
+       ret &= test_lsa_OpenPolicy2(p->binding_handle, torture, &handle);
+
+       if (handle) {
+               ret &= test_lsa_Close(p->binding_handle, torture, handle);
+       }
+
        torture_comment(torture, "Testing change of primary context\n");
        status = dcerpc_alter_context(p, torture, &p2->syntax, &p2->transfer_syntax);
+       if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
+               torture_assert_int_equal(torture, p->last_fault_code, DCERPC_NCA_S_PROTO_ERROR,
+                                        "dcerpc_alter_context should generate a proto error");
+
+               ret &= test_lsa_OpenPolicy2_ex(p->binding_handle, torture, &handle,
+                                              NT_STATUS_PIPE_DISCONNECTED);
+               return ret;
+       }
        torture_assert_ntstatus_ok(torture, status, "dcerpc_alter_context failed");
 
        torture_comment(torture, "testing DSSETUP pipe operations - should fault\n");