svn commit: samba r22566 - in branches/SAMBA_4_0/source/torture/libnet: .

mimir at samba.org mimir at samba.org
Sun Apr 29 12:32:18 GMT 2007


Author: mimir
Date: 2007-04-29 12:32:17 +0000 (Sun, 29 Apr 2007)
New Revision: 22566

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22566

Log:
add a simple test of libnet_DomainList function.


rafal


Modified:
   branches/SAMBA_4_0/source/torture/libnet/libnet.c
   branches/SAMBA_4_0/source/torture/libnet/libnet_domain.c


Changeset:
Modified: branches/SAMBA_4_0/source/torture/libnet/libnet.c
===================================================================
--- branches/SAMBA_4_0/source/torture/libnet/libnet.c	2007-04-29 12:31:09 UTC (rev 22565)
+++ branches/SAMBA_4_0/source/torture/libnet/libnet.c	2007-04-29 12:32:17 UTC (rev 22566)
@@ -52,6 +52,7 @@
 	torture_suite_add_simple_test(suite, "API-DOMOPENSAMR", torture_domain_open_samr);
 	torture_suite_add_simple_test(suite, "API-DOMCLOSESAMR", torture_domain_close_samr);
 	torture_suite_add_simple_test(suite, "API-BECOME-DC", torture_net_become_dc);
+	torture_suite_add_simple_test(suite, "API-DOMLIST", torture_domain_list);
 
 	suite->description = talloc_strdup(suite, "libnet convenience interface tests");
 

Modified: branches/SAMBA_4_0/source/torture/libnet/libnet_domain.c
===================================================================
--- branches/SAMBA_4_0/source/torture/libnet/libnet_domain.c	2007-04-29 12:31:09 UTC (rev 22565)
+++ branches/SAMBA_4_0/source/torture/libnet/libnet_domain.c	2007-04-29 12:32:17 UTC (rev 22566)
@@ -312,7 +312,7 @@
 {
 	BOOL ret = True;
 	NTSTATUS status;
-	TALLOC_CTX *mem_ctx=NULL;
+	TALLOC_CTX *mem_ctx = NULL;
 	struct libnet_context *ctx;
 	struct lsa_String domain_name;
 	struct dcerpc_binding *binding;
@@ -340,7 +340,7 @@
 
 	mem_ctx = talloc_init("torture_domain_close_samr");
 	status = dcerpc_pipe_connect(mem_ctx, &p, bindstr, &dcerpc_table_samr,
-				     cmdline_credentials, NULL);
+				     ctx->cred, NULL);
 	if (!NT_STATUS_IS_OK(status)) {
 		d_printf("failed to connect to server %s: %s\n", bindstr,
 			 nt_errstr(status));
@@ -361,7 +361,8 @@
 	ctx->samr.access_mask = access_mask;
 	ctx->samr.handle      = h;
 	/* we have to use pipe's event context, otherwise the call will
-	   hang indefinately */
+	   hang indefinitely - this wouldn't be the case if pipe was opened
+	   by means of libnet call */
 	ctx->event_ctx       = p->conn->event_ctx;
 
 	ZERO_STRUCT(r);
@@ -379,3 +380,56 @@
 	talloc_free(ctx);
 	return ret;
 }
+
+
+BOOL torture_domain_list(struct torture_context *torture)
+{
+	BOOL ret = True;
+	NTSTATUS status;
+	TALLOC_CTX *mem_ctx = NULL;
+	const char *bindstr;
+	struct dcerpc_binding *binding;
+	struct libnet_context *ctx;
+	struct libnet_DomainList r;
+	int i;
+
+	bindstr = torture_setting_string(torture, "binding", NULL);
+	status = dcerpc_parse_binding(torture, bindstr, &binding);
+	if (!NT_STATUS_IS_OK(status)) {
+		d_printf("failed to parse binding string\n");
+		return False;
+	}
+
+	ctx = libnet_context_init(NULL);
+	if (ctx == NULL) {
+		d_printf("failed to create libnet context\n");
+		ret = False;
+		goto done;
+	}
+
+	ctx->cred = cmdline_credentials;
+	
+	mem_ctx = talloc_init("torture_domain_close_samr");
+
+	ZERO_STRUCT(r);
+	r.in.hostname = binding->host;
+
+	status = libnet_DomainList(ctx, mem_ctx, &r);
+	if (!NT_STATUS_IS_OK(status)) {
+		ret = False;
+		goto done;
+	}
+
+	d_printf("Received list or domains:\n");
+	
+	for (i = 0; i < r.out.count; i++) {
+		d_printf("Name[%d]: %s\n", i, r.out.domains[i].name);
+	}
+
+done:
+	d_printf("\nStatus: %s\n", nt_errstr(status));
+
+	talloc_free(mem_ctx);
+	talloc_free(ctx);
+	return ret;
+}



More information about the samba-cvs mailing list