s4-torture: add more cluster group tests.
authorGünther Deschner <gd@samba.org>
Thu, 5 Mar 2015 11:06:05 +0000 (12:06 +0100)
committerGünther Deschner <gd@samba.org>
Fri, 13 Mar 2015 22:58:08 +0000 (23:58 +0100)
Guenther

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

index f10c88c14862bc35a95d76a8aeadf23e8dec065d..5c2c38a2e103f117034e7362d2c7d3dc56bfc319 100644 (file)
@@ -1104,6 +1104,165 @@ static bool test_CloseGroup(struct torture_context *tctx,
        return test_CloseGroup_int(tctx, p, &hGroup);
 }
 
+static bool test_GetGroupState_int(struct torture_context *tctx,
+                                  struct dcerpc_pipe *p,
+                                  struct policy_handle *hGroup)
+{
+       struct dcerpc_binding_handle *b = p->binding_handle;
+       struct clusapi_GetGroupState r;
+       enum clusapi_ClusterGroupState State;
+       const char *NodeName;
+       WERROR rpc_status;
+
+       r.in.hGroup = *hGroup;
+       r.out.State = &State;
+       r.out.NodeName = &NodeName;
+       r.out.rpc_status = &rpc_status;
+
+       torture_assert_ntstatus_ok(tctx,
+               dcerpc_clusapi_GetGroupState_r(b, tctx, &r),
+               "GetGroupState failed");
+       torture_assert_werr_ok(tctx,
+               r.out.result,
+               "GetGroupState failed");
+
+       return true;
+}
+
+static bool test_GetGroupState(struct torture_context *tctx,
+                              struct dcerpc_pipe *p)
+{
+       struct policy_handle hGroup;
+       bool ret = true;
+
+       if (!test_OpenGroup_int(tctx, p, &hGroup)) {
+               return false;
+       }
+
+       ret = test_GetGroupState_int(tctx, p, &hGroup);
+
+       test_CloseGroup_int(tctx, p, &hGroup);
+
+       return ret;
+}
+
+static bool test_GetGroupId_int(struct torture_context *tctx,
+                               struct dcerpc_pipe *p,
+                               struct policy_handle *hGroup)
+{
+       struct dcerpc_binding_handle *b = p->binding_handle;
+       struct clusapi_GetGroupId r;
+       const char *pGuid;
+       WERROR rpc_status;
+
+       r.in.hGroup = *hGroup;
+       r.out.pGuid = &pGuid;
+       r.out.rpc_status = &rpc_status;
+
+       torture_assert_ntstatus_ok(tctx,
+               dcerpc_clusapi_GetGroupId_r(b, tctx, &r),
+               "GetGroupId failed");
+       torture_assert_werr_ok(tctx,
+               r.out.result,
+               "GetGroupId failed");
+
+       return true;
+}
+
+static bool test_GetGroupId(struct torture_context *tctx,
+                           struct dcerpc_pipe *p)
+{
+       struct policy_handle hGroup;
+       bool ret = true;
+
+       if (!test_OpenGroup_int(tctx, p, &hGroup)) {
+               return false;
+       }
+
+       ret = test_GetGroupId_int(tctx, p, &hGroup);
+
+       test_CloseGroup_int(tctx, p, &hGroup);
+
+       return ret;
+}
+
+static bool test_OnlineGroup_int(struct torture_context *tctx,
+                                struct dcerpc_pipe *p,
+                                struct policy_handle *hGroup)
+{
+       struct dcerpc_binding_handle *b = p->binding_handle;
+       struct clusapi_OnlineGroup r;
+       WERROR rpc_status;
+
+       r.in.hGroup = *hGroup;
+       r.out.rpc_status = &rpc_status;
+
+       torture_assert_ntstatus_ok(tctx,
+               dcerpc_clusapi_OnlineGroup_r(b, tctx, &r),
+               "OnlineGroup failed");
+       torture_assert_werr_ok(tctx,
+               r.out.result,
+               "OnlineGroup failed");
+
+       return true;
+}
+
+static bool test_OnlineGroup(struct torture_context *tctx,
+                            struct dcerpc_pipe *p)
+{
+       struct policy_handle hGroup;
+       bool ret = true;
+
+       if (!test_OpenGroup_int(tctx, p, &hGroup)) {
+               return false;
+       }
+
+       ret = test_OnlineGroup_int(tctx, p, &hGroup);
+
+       test_CloseGroup_int(tctx, p, &hGroup);
+
+       return ret;
+}
+
+static bool test_OfflineGroup_int(struct torture_context *tctx,
+                                 struct dcerpc_pipe *p,
+                                 struct policy_handle *hGroup)
+{
+       struct dcerpc_binding_handle *b = p->binding_handle;
+       struct clusapi_OfflineGroup r;
+       WERROR rpc_status;
+
+       r.in.hGroup = *hGroup;
+       r.out.rpc_status = &rpc_status;
+
+       torture_assert_ntstatus_ok(tctx,
+               dcerpc_clusapi_OfflineGroup_r(b, tctx, &r),
+               "OfflineGroup failed");
+       torture_assert_werr_ok(tctx,
+               r.out.result,
+               "OfflineGroup failed");
+
+       return true;
+}
+
+static bool test_OfflineGroup(struct torture_context *tctx,
+                                struct dcerpc_pipe *p)
+{
+       struct policy_handle hGroup;
+       bool ret = true;
+
+       if (!test_OpenGroup_int(tctx, p, &hGroup)) {
+               return false;
+       }
+
+       ret = test_OfflineGroup_int(tctx, p, &hGroup);
+
+       test_CloseGroup_int(tctx, p, &hGroup);
+
+       return ret;
+}
+
+
 struct torture_suite *torture_rpc_clusapi(TALLOC_CTX *mem_ctx)
 {
        struct torture_rpc_tcase *tcase;
@@ -1190,7 +1349,15 @@ struct torture_suite *torture_rpc_clusapi(TALLOC_CTX *mem_ctx)
                                   test_OpenGroup);
        torture_rpc_tcase_add_test(tcase, "CloseGroup",
                                   test_CloseGroup);
-
+       torture_rpc_tcase_add_test(tcase, "GetGroupState",
+                                  test_GetGroupState);
+       torture_rpc_tcase_add_test(tcase, "GetGroupId",
+                                  test_GetGroupId);
+       torture_rpc_tcase_add_test(tcase, "OnlineGroup",
+                                  test_OnlineGroup);
+       test = torture_rpc_tcase_add_test(tcase, "OfflineGroup",
+                                  test_OfflineGroup);
+       test->dangerous = true;
 
        return suite;
 }