summaryrefslogtreecommitdiff
path: root/source4/torture/rpc
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>2009-09-13 23:54:05 +0300
committerAnatoliy Atanasov <anatoliy.atanasov@postpath.com>2009-10-01 11:29:22 +0300
commitd60e3ac8d303d75d7056eba9dac0ba05852238bf (patch)
tree6a9b769da7d717642eec77a873aa78119a63ac3a /source4/torture/rpc
parentb49249864a0d8d087c9bf5e1661824a7e8d96324 (diff)
downloadsamba-d60e3ac8d303d75d7056eba9dac0ba05852238bf.tar.gz
samba-d60e3ac8d303d75d7056eba9dac0ba05852238bf.tar.bz2
samba-d60e3ac8d303d75d7056eba9dac0ba05852238bf.zip
s4-tort-drs: DsReplicaUpdateRefs test fixed and extended
Signed-off-by: Anatoliy Atanasov <anatoliy.atanasov@postpath.com>
Diffstat (limited to 'source4/torture/rpc')
-rw-r--r--source4/torture/rpc/drsuapi.c87
1 files changed, 50 insertions, 37 deletions
diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c
index 174de5e981..6142096bc9 100644
--- a/source4/torture/rpc/drsuapi.c
+++ b/source4/torture/rpc/drsuapi.c
@@ -416,51 +416,64 @@ static bool test_DsReplicaUpdateRefs(struct torture_context *tctx,
{
NTSTATUS status;
struct dcerpc_pipe *p = priv->pipe;
- int i;
struct drsuapi_DsReplicaUpdateRefs r;
struct drsuapi_DsReplicaObjectIdentifier nc;
struct GUID null_guid;
+ struct GUID dest_dsa_guid;
+ const char *dest_dsa_guid_str;
struct dom_sid null_sid;
- struct {
- int32_t level;
- } array[] = {
- {
- 1
- }
- };
-
- if (torture_setting_bool(tctx, "samba4", false)) {
- torture_comment(tctx, "skipping DsReplicaUpdateRefs test against Samba4\n");
- return true;
- }
ZERO_STRUCT(null_guid);
ZERO_STRUCT(null_sid);
+ dest_dsa_guid = GUID_random();
+ dest_dsa_guid_str = GUID_string(tctx, &dest_dsa_guid);
- r.in.bind_handle = &priv->bind_handle;
-
- for (i=0; i < ARRAY_SIZE(array); i++) {
- torture_comment(tctx, "testing DsReplicaUpdateRefs level %d\n",
- array[i].level);
-
- r.in.level = array[i].level;
- switch(r.in.level) {
- case 1:
- nc.guid = null_guid;
- nc.sid = null_sid;
- nc.dn = priv->domain_obj_dn ? priv->domain_obj_dn : "";
-
- r.in.req.req1.naming_context = &nc;
- r.in.req.req1.dest_dsa_dns_name = talloc_asprintf(tctx, "__some_dest_dsa_guid_string._msdn.%s",
- priv->domain_dns_name);
- r.in.req.req1.dest_dsa_guid = null_guid;
- r.in.req.req1.options = 0;
- break;
- }
-
- status = dcerpc_drsuapi_DsReplicaUpdateRefs(p, tctx, &r);
- torture_drsuapi_assert_call(tctx, p, status, &r, "dcerpc_drsuapi_DsReplicaUpdateRefs");
- }
+ r.in.bind_handle = &priv->bind_handle;
+ r.in.level = 1; /* Only version 1 is defined presently */
+
+ /* setup NC */
+ nc.guid = priv->domain_obj_dn ? null_guid : priv->domain_guid;
+ nc.sid = null_sid;
+ nc.dn = priv->domain_obj_dn ? priv->domain_obj_dn : "";
+
+ /* default setup for request */
+ r.in.req.req1.naming_context = &nc;
+ r.in.req.req1.dest_dsa_dns_name = talloc_asprintf(tctx, "%s._msdn.%s",
+ dest_dsa_guid_str,
+ priv->domain_dns_name);
+ r.in.req.req1.dest_dsa_guid = dest_dsa_guid;
+
+ /* 1. deleting replica dest should fail */
+ torture_comment(tctx, "delete: %s\n", r.in.req.req1.dest_dsa_dns_name);
+ r.in.req.req1.options = DRSUAPI_DS_REPLICA_UPDATE_DELETE_REFERENCE;
+ status = dcerpc_drsuapi_DsReplicaUpdateRefs(p, tctx, &r);
+ torture_drsuapi_assert_call_werr(tctx, p,
+ status, WERR_DS_DRA_REF_NOT_FOUND, &r,
+ "dcerpc_drsuapi_DsReplicaUpdateRefs");
+
+ /* 2. hopefully adding random replica dest should succeed */
+ torture_comment(tctx, "add : %s\n", r.in.req.req1.dest_dsa_dns_name);
+ r.in.req.req1.options = DRSUAPI_DS_REPLICA_UPDATE_ADD_REFERENCE;
+ status = dcerpc_drsuapi_DsReplicaUpdateRefs(p, tctx, &r);
+ torture_drsuapi_assert_call_werr(tctx, p,
+ status, WERR_OK, &r,
+ "dcerpc_drsuapi_DsReplicaUpdateRefs");
+
+ /* 3. try adding same replica dest - should fail */
+ torture_comment(tctx, "add : %s\n", r.in.req.req1.dest_dsa_dns_name);
+ r.in.req.req1.options = DRSUAPI_DS_REPLICA_UPDATE_ADD_REFERENCE;
+ status = dcerpc_drsuapi_DsReplicaUpdateRefs(p, tctx, &r);
+ torture_drsuapi_assert_call_werr(tctx, p,
+ status, WERR_DS_DRA_REF_ALREADY_EXISTS, &r,
+ "dcerpc_drsuapi_DsReplicaUpdateRefs");
+
+ /* 4. delete random replicate added at step 2. */
+ torture_comment(tctx, "delete: %s\n", r.in.req.req1.dest_dsa_dns_name);
+ r.in.req.req1.options = DRSUAPI_DS_REPLICA_UPDATE_DELETE_REFERENCE;
+ status = dcerpc_drsuapi_DsReplicaUpdateRefs(p, tctx, &r);
+ torture_drsuapi_assert_call_werr(tctx, p,
+ status, WERR_OK, &r,
+ "dcerpc_drsuapi_DsReplicaUpdateRefs");
return true;
}