Gargi-jais11 commented on code in PR #9774:
URL: https://github.com/apache/ozone/pull/9774#discussion_r2815352119
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/OMClientRequestUtils.java:
##########
@@ -111,4 +112,27 @@ public static boolean
shouldLogClientRequestFailure(IOException exception) {
return true;
}
}
+
+ public static void validateVolumeName(String volumeName) throws IOException {
+ if (StringUtils.isBlank(volumeName)) {
+ if (StringUtils.isBlank(volumeName)) {
+ throw new OMException("Invalid, volume name is empty",
+ OMException.ResultCodes.INVALID_VOLUME_NAME);
+ }
Review Comment:
Nit: Remove this redundant check twice.
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/key/TestOMSetTimesRequest.java:
##########
@@ -61,6 +67,32 @@ public void testKeySetTimesRequest() throws Exception {
assertEquals(mtime, keyMtime);
}
+ @Test
+ public void preExecutePermissionDeniedWhenAclEnabled() throws Exception {
+ OMRequestTestUtils.addVolumeAndBucketToDB(volumeName, bucketName,
+ omMetadataManager, getBucketLayout());
+ addKeyToTable();
+
+ when(ozoneManager.getAclsEnabled()).thenReturn(true);
+
+ OMRequest req = createSetTimesKeyRequest(2000, 1000);
+
+ OMKeySetTimesRequest setTimes = new OMKeySetTimesRequest(req,
getBucketLayout()) {
+ @Override
+ public void checkAcls(OzoneManager ozoneManager,
+ OzoneObj.ResourceType resType,
+ OzoneObj.StoreType storeType,
+ IAccessAuthorizer.ACLType aclType,
+ String vol, String bucket, String key) throws
IOException {
Review Comment:
Please fix the indent of this function statement. It is preferred to have 4
back space indent.
```suggestion
public void checkAcls(OzoneManager ozoneManager,
OzoneObj.ResourceType resType,
OzoneObj.StoreType storeType,
IAccessAuthorizer.ACLType aclType,
String vol, String bucket, String key) throws IOException
```
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/volume/TestOMVolumeDeleteRequest.java:
##########
@@ -48,6 +55,33 @@ public void testPreExecute() throws Exception {
assertNotEquals(originalRequest, modifiedRequest);
}
+ @Test
+ public void preExecutePermissionDeniedWhenAclEnabledForDeleteVolume()
+ throws Exception {
+
+ String volumeName = UUID.randomUUID().toString();
+ when(ozoneManager.getAclsEnabled()).thenReturn(true);
+
+ OMRequest originalRequest = createDeleteVolumeRequest(volumeName);
+
+ OMVolumeDeleteRequest req = new OMVolumeDeleteRequest(originalRequest) {
+ @Override
+ public void checkAcls(OzoneManager ozoneManager,
+ OzoneObj.ResourceType resType,
+ OzoneObj.StoreType storeType,
+ IAccessAuthorizer.ACLType aclType,
+ String vol, String bucket, String key) throws
IOException {
Review Comment:
Please fix the indent of this function statement. It is preferred to have 4
back space indent.
```suggestion
public void checkAcls(OzoneManager ozoneManager,
OzoneObj.ResourceType resType,
OzoneObj.StoreType storeType,
IAccessAuthorizer.ACLType aclType,
String vol, String bucket, String key) throws IOException
```
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/bucket/TestOMBucketSetPropertyRequest.java:
##########
@@ -77,6 +84,35 @@ public void testPreExecute() throws Exception {
assertNotEquals(omRequest,
omBucketSetPropertyRequest.preExecute(ozoneManager));
}
+ @Test
+ public void preExecutePermissionDeniedWhenAclEnabled() throws Exception {
+ String volumeName = UUID.randomUUID().toString();
+ String bucketName = UUID.randomUUID().toString();
+
+ when(ozoneManager.getAclsEnabled()).thenReturn(true);
+
+ IAccessAuthorizer authorizer = mock(IAccessAuthorizer.class);
+ when(authorizer.isNative()).thenReturn(false);
+ when(ozoneManager.getAccessAuthorizer()).thenReturn(authorizer);
+
+ OMRequest originalRequest = createSetBucketPropertyRequest(
+ volumeName, bucketName, true, Long.MAX_VALUE);
+
+ OMBucketSetPropertyRequest req = new
OMBucketSetPropertyRequest(originalRequest) {
+ @Override
+ public void checkAcls(OzoneManager ozoneManager,
+ OzoneObj.ResourceType resType,
+ OzoneObj.StoreType storeType,
+ IAccessAuthorizer.ACLType aclType,
Review Comment:
Please fix the indent of this function statement. It is preferred to have 4
back space indent.
```suggestion
public void checkAcls(OzoneManager ozoneManager,
OzoneObj.ResourceType resType,
OzoneObj.StoreType storeType,
IAccessAuthorizer.ACLType aclType,
String vol, String bucket, String key) throws IOException
```
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/bucket/TestOMBucketDeleteRequest.java:
##########
@@ -59,6 +67,32 @@ public void testPreExecute() throws Exception {
assertNotEquals(omRequest, omBucketDeleteRequest.preExecute(ozoneManager));
}
+ @Test
+ public void preExecutePermissionDeniedWhenAclEnabled() {
+ String volumeName = UUID.randomUUID().toString();
+ String bucketName = UUID.randomUUID().toString();
+
+ when(ozoneManager.getAclsEnabled()).thenReturn(true);
+
+ OMRequest originalRequest = newDeleteBucketRequest(volumeName, bucketName);
+
+ OMBucketDeleteRequest req = new OMBucketDeleteRequest(originalRequest) {
+ @Override
+ public void checkAcls(OzoneManager ozoneManager,
+ OzoneObj.ResourceType resType,
+ OzoneObj.StoreType storeType,
+ IAccessAuthorizer.ACLType aclType,
+ String vol, String bucket, String key) throws
IOException {
Review Comment:
Please fix the indent of this function statement. It is preferred to have 4
back space indent.
```suggestion
public void checkAcls(OzoneManager ozoneManager,
OzoneObj.ResourceType resType,
OzoneObj.StoreType storeType,
IAccessAuthorizer.ACLType aclType,
String vol, String bucket, String key) throws IOException
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]