r26530: Add NET-API-GROUPLIST test.
authorRafal Szczesniak <mimir@samba.org>
Tue, 18 Dec 2007 23:44:01 +0000 (00:44 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 21 Dec 2007 04:51:54 +0000 (05:51 +0100)
(This used to be commit 73566f520c0835f6b6b37d3f62414052468afb99)

source4/torture/libnet/libnet.c
source4/torture/libnet/libnet_group.c

index 0e5c9301f8a42c4678013a893129f2c126d0fc53..0bb70df1e092cb482d7c55b9c18dc628eef04758 100644 (file)
@@ -42,6 +42,7 @@ NTSTATUS torture_net_init(void)
        torture_suite_add_simple_test(suite, "API-USERINFO", torture_userinfo_api);
        torture_suite_add_simple_test(suite, "API-USERLIST", torture_userlist);
        torture_suite_add_simple_test(suite, "API-GROUPINFO", torture_groupinfo_api);
+       torture_suite_add_simple_test(suite, "API-GROUPLIST", torture_grouplist);
        torture_suite_add_simple_test(suite, "API-RPCCONN-BIND", torture_rpc_connect_binding);
        torture_suite_add_simple_test(suite, "API-RPCCONN-SRV", torture_rpc_connect_srv);
        torture_suite_add_simple_test(suite, "API-RPCCONN-PDC", torture_rpc_connect_pdc);
index 02fc0f7fd5210e94c0dacbf3b31dcfe88e4477f6..83aab48e90e2c78c667199ed6653c8dd2783d54a 100644 (file)
@@ -202,6 +202,25 @@ static bool test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
 }
 
 
+static bool test_lsa_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+                          struct policy_handle *domain_handle)
+{
+       NTSTATUS status;
+       struct lsa_Close r;
+
+       r.in.handle = domain_handle;
+       r.out.handle = domain_handle;
+       
+       status = dcerpc_lsa_Close(p, mem_ctx, &r);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("Close lsa domain failed - %s\n", nt_errstr(status));
+               return false;
+       }
+
+       return true;
+}
+
+
 bool torture_groupinfo_api(struct torture_context *torture)
 {
        const char *name = TEST_GROUPNAME;
@@ -269,3 +288,64 @@ done:
        talloc_free(mem_ctx);
        return ret;
 }
+
+
+bool torture_grouplist(struct torture_context *torture)
+{
+       bool ret = true;
+       NTSTATUS status;
+       TALLOC_CTX *mem_ctx = NULL;
+       struct libnet_context *ctx;
+       struct lsa_String domain_name;
+       struct libnet_GroupList req;
+       int i;
+
+       ctx = libnet_context_init(NULL, torture->lp_ctx);
+       ctx->cred = cmdline_credentials;
+
+       domain_name.string = lp_workgroup(torture->lp_ctx);
+       mem_ctx = talloc_init("torture group list");
+
+       ZERO_STRUCT(req);
+
+       printf("listing group accounts:\n");
+       
+       do {
+               req.in.domain_name  = domain_name.string;
+               req.in.page_size    = 128;
+               req.in.resume_index = req.out.resume_index;
+
+               status = libnet_GroupList(ctx, mem_ctx, &req);
+               if (!NT_STATUS_IS_OK(status) &&
+                   !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) break;
+
+               for (i = 0; i < req.out.count; i++) {
+                       printf("\tgroup: %s, sid=%s\n",
+                              req.out.groups[i].groupname, req.out.groups[i].sid);
+               }
+
+       } while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES));
+
+       if (!(NT_STATUS_IS_OK(status) ||
+             NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES))) {
+               printf("libnet_GroupList call failed: %s\n", nt_errstr(status));
+               ret = false;
+               goto done;
+       }
+
+       if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) {
+               printf("domain close failed\n");
+               ret = false;
+       }
+
+       if (!test_lsa_close(ctx->lsa.pipe, mem_ctx, &ctx->lsa.handle)) {
+               printf("lsa domain close failed\n");
+               ret = false;
+       }
+
+       talloc_free(ctx);
+
+done:
+       talloc_free(mem_ctx);
+       return ret;
+}