use of org.apache.hadoop.ozone.security.acl.OzoneObj in project ozone by apache.
the class TestOzoneManagerListVolumes method setVolumeAcl.
/**
* Helper function to set volume ACL.
*/
private static void setVolumeAcl(ObjectStore objectStore, String volumeName, String aclString) throws IOException {
OzoneObj obj = OzoneObjInfo.Builder.newBuilder().setVolumeName(volumeName).setResType(OzoneObj.ResourceType.VOLUME).setStoreType(OZONE).build();
Assert.assertTrue(objectStore.setAcl(obj, OzoneAcl.parseAcls(aclString)));
}
use of org.apache.hadoop.ozone.security.acl.OzoneObj in project ozone by apache.
the class TestOzoneManagerHAWithACL method testSetPrefixAcl.
public void testSetPrefixAcl() throws Exception {
OzoneBucket ozoneBucket = setupBucket();
String remoteUserName = "remoteUser";
String prefixName = RandomStringUtils.randomAlphabetic(5) + "/";
OzoneAcl defaultUserAcl = new OzoneAcl(USER, remoteUserName, READ, DEFAULT);
OzoneObj ozoneObj = OzoneObjInfo.Builder.newBuilder().setResType(OzoneObj.ResourceType.PREFIX).setStoreType(OzoneObj.StoreType.OZONE).setVolumeName(ozoneBucket.getVolumeName()).setBucketName(ozoneBucket.getName()).setPrefixName(prefixName).build();
testSetAcl(remoteUserName, ozoneObj, defaultUserAcl);
}
use of org.apache.hadoop.ozone.security.acl.OzoneObj in project ozone by apache.
the class TestOzoneManagerHAWithACL method testAddKeyAcl.
public void testAddKeyAcl() throws Exception {
OzoneBucket ozoneBucket = setupBucket();
String remoteUserName = "remoteUser";
OzoneAcl userAcl = new OzoneAcl(USER, remoteUserName, READ, DEFAULT);
String key = createKey(ozoneBucket);
OzoneObj ozoneObj = OzoneObjInfo.Builder.newBuilder().setResType(OzoneObj.ResourceType.KEY).setStoreType(OzoneObj.StoreType.OZONE).setVolumeName(ozoneBucket.getVolumeName()).setBucketName(ozoneBucket.getName()).setKeyName(key).build();
testAddAcl(remoteUserName, ozoneObj, userAcl);
}
use of org.apache.hadoop.ozone.security.acl.OzoneObj in project ozone by apache.
the class TestOzoneManagerHAWithACL method testRemoveBucketAcl.
public void testRemoveBucketAcl() throws Exception {
OzoneBucket ozoneBucket = setupBucket();
String remoteUserName = "remoteUser";
OzoneAcl defaultUserAcl = new OzoneAcl(USER, remoteUserName, READ, DEFAULT);
OzoneObj ozoneObj = OzoneObjInfo.Builder.newBuilder().setResType(OzoneObj.ResourceType.BUCKET).setStoreType(OzoneObj.StoreType.OZONE).setVolumeName(ozoneBucket.getVolumeName()).setBucketName(ozoneBucket.getName()).build();
testRemoveAcl(remoteUserName, ozoneObj, defaultUserAcl);
}
use of org.apache.hadoop.ozone.security.acl.OzoneObj in project ozone by apache.
the class TestOzoneManagerHAWithACL method testRemovePrefixAcl.
public void testRemovePrefixAcl() throws Exception {
OzoneBucket ozoneBucket = setupBucket();
String remoteUserName = "remoteUser";
String prefixName = RandomStringUtils.randomAlphabetic(5) + "/";
OzoneAcl userAcl = new OzoneAcl(USER, remoteUserName, READ, ACCESS);
OzoneAcl userAcl1 = new OzoneAcl(USER, "remote", READ, ACCESS);
OzoneObj ozoneObj = OzoneObjInfo.Builder.newBuilder().setResType(OzoneObj.ResourceType.PREFIX).setStoreType(OzoneObj.StoreType.OZONE).setVolumeName(ozoneBucket.getVolumeName()).setBucketName(ozoneBucket.getName()).setPrefixName(prefixName).build();
ObjectStore objectStore = getObjectStore();
boolean result = objectStore.addAcl(ozoneObj, userAcl);
Assert.assertTrue(result);
result = objectStore.addAcl(ozoneObj, userAcl1);
Assert.assertTrue(result);
result = objectStore.removeAcl(ozoneObj, userAcl);
Assert.assertTrue(result);
// try removing already removed acl.
result = objectStore.removeAcl(ozoneObj, userAcl);
Assert.assertFalse(result);
result = objectStore.removeAcl(ozoneObj, userAcl1);
Assert.assertTrue(result);
}
Aggregations