s4-torture: test all available groups on the cluster.
authorGünther Deschner <gd@samba.org>
Thu, 5 Mar 2015 23:05:09 +0000 (00:05 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 13 Mar 2015 11:05:15 +0000 (12:05 +0100)
Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source4/torture/rpc/clusapi.c

index 85386d57a18de5a6bd4dafa1c0032301ceb84aa0..d67344bf1c0db6dbb09211f95bd4a59a78e189d1 100644 (file)
@@ -1547,6 +1547,67 @@ static bool test_OfflineGroup(struct torture_context *tctx,
        return ret;
 }
 
+static bool test_one_group(struct torture_context *tctx,
+                          struct dcerpc_pipe *p,
+                          const char *node_name)
+{
+       struct policy_handle hGroup;
+
+       torture_assert(tctx,
+               test_OpenGroup_int(tctx, p, node_name, &hGroup),
+               "failed to open group");
+       test_CloseGroup_int(tctx, p, &hGroup);
+
+       torture_assert(tctx,
+               test_OpenGroupEx_int(tctx, p, node_name, &hGroup),
+               "failed to openex group");
+
+       torture_assert(tctx,
+               test_GetGroupId_int(tctx, p, &hGroup),
+               "failed to query group id");
+       torture_assert(tctx,
+               test_GetGroupState_int(tctx, p, &hGroup),
+               "failed to query group id");
+
+       test_CloseGroup_int(tctx, p, &hGroup);
+
+       return true;
+}
+
+static bool test_all_groups(struct torture_context *tctx,
+                           struct dcerpc_pipe *p)
+{
+       struct dcerpc_binding_handle *b = p->binding_handle;
+       struct clusapi_CreateEnum r;
+       uint32_t dwType = CLUSTER_ENUM_GROUP;
+       struct ENUM_LIST *ReturnEnum;
+       WERROR rpc_status;
+       int i;
+
+       r.in.dwType = dwType;
+       r.out.ReturnEnum = &ReturnEnum;
+       r.out.rpc_status = &rpc_status;
+
+       torture_assert_ntstatus_ok(tctx,
+               dcerpc_clusapi_CreateEnum_r(b, tctx, &r),
+               "CreateEnum failed");
+       torture_assert_werr_ok(tctx,
+               r.out.result,
+               "CreateEnum failed");
+
+       for (i=0; i < ReturnEnum->EntryCount; i++) {
+
+               struct ENUM_ENTRY e = ReturnEnum->Entry[i];
+
+               torture_assert_int_equal(tctx, e.Type, CLUSTER_ENUM_GROUP, "type mismatch");
+
+               torture_assert(tctx,
+                       test_one_group(tctx, p, e.Name),
+                       "failed to test one group");
+       }
+
+       return true;
+}
 
 struct torture_suite *torture_rpc_clusapi(TALLOC_CTX *mem_ctx)
 {
@@ -1654,6 +1715,8 @@ struct torture_suite *torture_rpc_clusapi(TALLOC_CTX *mem_ctx)
        test = torture_rpc_tcase_add_test(tcase, "OfflineGroup",
                                   test_OfflineGroup);
        test->dangerous = true;
+       torture_rpc_tcase_add_test(tcase, "all_groups",
+                                  test_all_groups);
 
        return suite;
 }