diff options
author | Stefan Metzmacher <metze@samba.org> | 2005-09-12 10:06:22 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:38:05 -0500 |
commit | 5c7de96d2c9e2985c750c69d3b73eb9e30037d07 (patch) | |
tree | e4812bd0540bbfb66b3becc7dbff4ef200f4aaad | |
parent | 3818f7793b2d63d3a6deeae881dc19482602b1c0 (diff) | |
download | samba-5c7de96d2c9e2985c750c69d3b73eb9e30037d07.tar.gz samba-5c7de96d2c9e2985c750c69d3b73eb9e30037d07.tar.bz2 samba-5c7de96d2c9e2985c750c69d3b73eb9e30037d07.zip |
r10164: - add first assoc_ctx test
- handle the case where we're no valid pull partner of the tested server
metze
(This used to be commit d2e62dc205dd450ce57b9566c29e82878eb8471b)
-rw-r--r-- | source4/torture/nbt/winsreplication.c | 82 |
1 files changed, 80 insertions, 2 deletions
diff --git a/source4/torture/nbt/winsreplication.c b/source4/torture/nbt/winsreplication.c index 1cf78f215c..c60419a534 100644 --- a/source4/torture/nbt/winsreplication.c +++ b/source4/torture/nbt/winsreplication.c @@ -41,6 +41,61 @@ }} while (0) /* + test how assoc_ctx's are only usable on the connection + they are created on. +*/ +static BOOL test_assoc_ctx1(TALLOC_CTX *mem_ctx, const char *address) +{ + BOOL ret = True; + struct wrepl_request *req; + struct wrepl_socket *wrepl_socket1; + struct wrepl_associate associate1; + struct wrepl_socket *wrepl_socket2; + struct wrepl_associate associate2; + struct wrepl_pull_table pull_table; + NTSTATUS status; + + printf("Test if assoc_ctx is only valid on the conection it was created on\n"); + + wrepl_socket1 = wrepl_socket_init(mem_ctx, NULL); + wrepl_socket2 = wrepl_socket_init(mem_ctx, NULL); + + printf("Setup 2 wrepl connections\n"); + status = wrepl_connect(wrepl_socket1, address); + CHECK_STATUS(status, NT_STATUS_OK); + + status = wrepl_connect(wrepl_socket2, address); + CHECK_STATUS(status, NT_STATUS_OK); + + printf("Send a start association request (conn1)\n"); + status = wrepl_associate(wrepl_socket1, &associate1); + CHECK_STATUS(status, NT_STATUS_OK); + + printf("association context (conn1): 0x%x\n", associate1.out.assoc_ctx); + + printf("Send a start association request (conn2)\n"); + status = wrepl_associate(wrepl_socket2, &associate2); + CHECK_STATUS(status, NT_STATUS_OK); + + printf("association context (conn2): 0x%x\n", associate2.out.assoc_ctx); + + printf("Send a replication table query, with assoc 1 (conn2), should be ignored\n"); + pull_table.in.assoc_ctx = associate1.out.assoc_ctx; + req = wrepl_pull_table_send(wrepl_socket2, &pull_table); + talloc_free(req); + + printf("Send a association request (conn2), to make sure the last request was ignored\n"); + status = wrepl_associate(wrepl_socket2, &associate2); + CHECK_STATUS(status, NT_STATUS_OK); + +done: + printf("Close 2 wrepl connections\n"); + talloc_free(wrepl_socket1); + talloc_free(wrepl_socket2); + return ret; +} + +/* display a replication entry */ static void display_entry(TALLOC_CTX *mem_ctx, struct wrepl_name *name) @@ -57,7 +112,7 @@ static void display_entry(TALLOC_CTX *mem_ctx, struct wrepl_name *name) /* test a full replication dump from a WINS server */ -static BOOL nbt_test_wins_replication(TALLOC_CTX *mem_ctx, const char *address) +static BOOL test_wins_replication(TALLOC_CTX *mem_ctx, const char *address) { BOOL ret = True; struct wrepl_socket *wrepl_socket; @@ -67,8 +122,11 @@ static BOOL nbt_test_wins_replication(TALLOC_CTX *mem_ctx, const char *address) struct wrepl_pull_table pull_table; struct wrepl_pull_names pull_names; + printf("Test one pull replication cycle\n"); + wrepl_socket = wrepl_socket_init(mem_ctx, NULL); + printf("Setup wrepl connections\n"); status = wrepl_connect(wrepl_socket, address); CHECK_STATUS(status, NT_STATUS_OK); @@ -83,6 +141,23 @@ static BOOL nbt_test_wins_replication(TALLOC_CTX *mem_ctx, const char *address) pull_table.in.assoc_ctx = associate.out.assoc_ctx; status = wrepl_pull_table(wrepl_socket, mem_ctx, &pull_table); + if (NT_STATUS_EQUAL(NT_STATUS_NETWORK_ACCESS_DENIED,status)) { + struct wrepl_packet packet; + struct wrepl_request *req; + + printf("We are not a valid pull partner for the server\n"); + + ZERO_STRUCT(packet); + packet.opcode = WREPL_OPCODE_BITS; + packet.assoc_ctx = associate.out.assoc_ctx; + packet.mess_type = WREPL_STOP_ASSOCIATION; + packet.message.stop.reason = 0; + + req = wrepl_request_send(wrepl_socket, &packet); + talloc_free(req); + ret = False; + goto done; + } CHECK_STATUS(status, NT_STATUS_OK); printf("Found %d replication partners\n", pull_table.out.num_partners); @@ -109,6 +184,7 @@ static BOOL nbt_test_wins_replication(TALLOC_CTX *mem_ctx, const char *address) } done: + printf("Close wrepl connections\n"); talloc_free(wrepl_socket); return ret; } @@ -135,7 +211,9 @@ BOOL torture_nbt_winsreplication(void) return False; } - ret &= nbt_test_wins_replication(mem_ctx, address); + ret &= test_assoc_ctx1(mem_ctx, address); + + ret &= test_wins_replication(mem_ctx, address); talloc_free(mem_ctx); |