Description
steps:
create user DataRolesDataWriterAllBuckets with role data_writer[*] and try to create doc like:
|
String key = username + "_doc"; |
JsonObject content = JsonObject.create().put("hello", "world"); |
if (writeAccess != null && !writeAccess) { |
assertTrue(addKey(key, content, GAMESIM_SAMPLE_BUCKET, HOST));
|
}
|
|
if (createUser) { |
UserRole[] roles = {new UserRole(userRole, bucketName)}; |
assertTrue(createUser("DataRolesDataWriterAllBuckets", "data_writer[*]", "password", HOST)); |
Thread.sleep(10000); |
}
|
|
CouchbaseCluster cluster = CouchbaseCluster.create(HOST);
|
cluster.authenticate(username, password);
|
|
Bucket bucket = null; |
|
try { |
bucket = cluster.openBucket(GAMESIM_SAMPLE_BUCKET);
|
assertTrue("User '" + username + "' with role '" + userRole + "' can open bucket '" + GAMESIM_SAMPLE_BUCKET + "' but shouldn't!", openBucketAccess); |
} catch (Exception ex) { |
assertFalse("User '" + username + "' with role '" + userRole + "' can't open bucket '" + GAMESIM_SAMPLE_BUCKET + "' but should! " + ex, openBucketAccess); |
return; |
}
|
|
try { |
JsonDocument upsert_result = bucket.upsert(JsonDocument.create(key, content), PersistTo.ONE, ReplicateTo.ONE, TIMEOUT, TimeUnit.SECONDS);
|
assertTrue("User '" + username + "' with role '" + userRole + "' has write access but shouldn't! " + upsert_result, writeAccess); |
} catch (Exception ex) { |
assertFalse("User '" + username + "' with role '" + userRole + "' doesn't have write access but should! " + ex, writeAccess); -FAILED |
}
|