s4-torture: fix clusapi_SetClusterName test by re-setting existing cluster name.
authorGünther Deschner <gd@samba.org>
Wed, 4 Mar 2015 14:34:29 +0000 (15:34 +0100)
committerGünther Deschner <gd@samba.org>
Fri, 13 Mar 2015 22:58:08 +0000 (23:58 +0100)
Guenther

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

index 535130147ada0bdf1f64fdfffe4fb4b2a28dd7e7..9875f97ce0cdf1c9dc208a92b8e6de7ddfa52ec2 100644 (file)
@@ -94,21 +94,48 @@ static bool test_CloseCluster(struct torture_context *tctx,
        return test_CloseCluster_int(tctx, p, &Cluster);
 }
 
+static bool test_GetClusterName_int(struct torture_context *tctx,
+                                   struct dcerpc_pipe *p,
+                                   const char **ClusterName)
+{
+       struct dcerpc_binding_handle *b = p->binding_handle;
+       struct clusapi_GetClusterName r;
+       const char *NodeName;
+
+       r.out.ClusterName = ClusterName;
+       r.out.NodeName = &NodeName;
+
+       torture_assert_ntstatus_ok(tctx,
+               dcerpc_clusapi_GetClusterName_r(b, tctx, &r),
+               "GetClusterName failed");
+       torture_assert_werr_ok(tctx,
+               r.out.result,
+               "GetClusterName failed");
+
+       return true;
+}
+
 static bool test_SetClusterName(struct torture_context *tctx,
                                struct dcerpc_pipe *p)
 {
        struct dcerpc_binding_handle *b = p->binding_handle;
        struct clusapi_SetClusterName r;
+       const char *NewClusterName;
        WERROR rpc_status;
 
-       r.in.NewClusterName = "wurst";
+       torture_assert(tctx,
+               test_GetClusterName_int(tctx, p, &NewClusterName),
+               "failed to query old ClusterName");
+
+       r.in.NewClusterName = NewClusterName;
        r.out.rpc_status = &rpc_status;
 
        torture_assert_ntstatus_ok(tctx,
                dcerpc_clusapi_SetClusterName_r(b, tctx, &r),
                "SetClusterName failed");
-       torture_assert_werr_ok(tctx,
+       torture_assert_werr_equal(tctx,
                r.out.result,
+               WERR_RESOURCE_PROPERTIES_STORED,
                "SetClusterName failed");
 
        return true;
@@ -117,22 +144,9 @@ static bool test_SetClusterName(struct torture_context *tctx,
 static bool test_GetClusterName(struct torture_context *tctx,
                                struct dcerpc_pipe *p)
 {
-       struct dcerpc_binding_handle *b = p->binding_handle;
-       struct clusapi_GetClusterName r;
        const char *ClusterName;
-       const char *NodeName;
-
-       r.out.ClusterName = &ClusterName;
-       r.out.NodeName = &NodeName;
 
-       torture_assert_ntstatus_ok(tctx,
-               dcerpc_clusapi_GetClusterName_r(b, tctx, &r),
-               "GetClusterName failed");
-       torture_assert_werr_ok(tctx,
-               r.out.result,
-               "GetClusterName failed");
-
-       return true;
+       return test_GetClusterName_int(tctx, p, &ClusterName);
 }
 
 static bool test_GetClusterVersion(struct torture_context *tctx,