xiaoyuyao commented on a change in pull request #927: HDDS-1543. Implement
addAcl,removeAcl,setAcl,getAcl for Prefix. Contr…
URL: https://github.com/apache/hadoop/pull/927#discussion_r292707539
##########
File path:
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientAbstract.java
##########
@@ -2200,6 +2201,66 @@ public void testNativeAclsForKey() throws Exception {
validateOzoneAcl(ozObj);
}
+ @Test
+ public void testNativeAclsForPrefix() throws Exception {
+ String volumeName = UUID.randomUUID().toString();
+ String bucketName = UUID.randomUUID().toString();
+
+ String prefix1 = "PF" + UUID.randomUUID().toString() + "/";
+ String key1 = prefix1 + "KEY" + UUID.randomUUID().toString();
+
+ String prefix2 = "PF" + UUID.randomUUID().toString() + "/";
+ String key2 = prefix2 + "KEY" + UUID.randomUUID().toString();
+
+ store.createVolume(volumeName);
+ OzoneVolume volume = store.getVolume(volumeName);
+ volume.createBucket(bucketName);
+ OzoneBucket bucket = volume.getBucket(bucketName);
+ assertNotNull("Bucket creation failed", bucket);
+
+ writeKey(key1, bucket);
+ writeKey(key2, bucket);
+
+ OzoneObj ozObj = new OzoneObjInfo.Builder()
+ .setVolumeName(volumeName)
+ .setBucketName(bucketName)
+ .setPrefixName(prefix1)
+ .setResType(OzoneObj.ResourceType.PREFIX)
+ .setStoreType(OzoneObj.StoreType.OZONE)
+ .build();
+
+ // add acl
+ BitSet aclRights1 = new BitSet();
+ aclRights1.set(ACLType.READ.ordinal());
+ OzoneAcl user1Acl = new OzoneAcl(ACLIdentityType.USER,
+ "user1", aclRights1);
+ assertTrue(store.addAcl(ozObj, user1Acl));
+
+ // get acl
+ List<OzoneAcl> aclsGet = store.getAcl(ozObj);
+ Assert.assertEquals(1, aclsGet.size());
+ Assert.assertEquals(user1Acl, aclsGet.get(0));
+
+ // remove acl
+ Assert.assertTrue(store.removeAcl(ozObj, user1Acl));
+ aclsGet = store.getAcl(ozObj);
+ Assert.assertEquals(0, aclsGet.size());
+
+ // set acl
+ BitSet aclRights2 = new BitSet();
+ aclRights2.set(ACLType.ALL.ordinal());
+ OzoneAcl group1Acl = new OzoneAcl(ACLIdentityType.GROUP,
+ "group1", aclRights2);
+ List<OzoneAcl> acls = new ArrayList<>();
+ acls.add(user1Acl);
+ acls.add(group1Acl);
+ Assert.assertTrue(store.setAcl(ozObj, acls));
+
+ // get acl
+ aclsGet = store.getAcl(ozObj);
+ Assert.assertEquals(2, aclsGet.size());
Review comment:
validateOzoneAcl() reused at the beginning of the new test cases.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]