Gargi-jais11 commented on code in PR #9774:
URL: https://github.com/apache/ozone/pull/9774#discussion_r2816037209
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/key/TestOMSetTimesRequest.java:
##########
@@ -61,6 +67,33 @@ 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
+ {
+ throw new OMException("denied",
OMException.ResultCodes.PERMISSION_DENIED);
+ }
Review Comment:
I think its better to use Mockito spy instead of override for ACL
Permission-Denied Tests. One of the reason is that if checkAcls signature
changes, only the stubbing call needs updating.
```
OMKeySetTimesRequest setTimes = spy(new OMKeySetTimesRequest(req,
getBucketLayout()));
doThrow(new OMException("denied", OMException.ResultCodes.PERMISSION_DENIED))
.when(setTimes).checkAcls(any(), any(), any(), any(), any(), any(),
any());
```
Files needed to change: TestOMSetTimesRequest, TestOMVolumeDeleteRequest,
TestOMBucketSetPropertyRequest, TestOMBucketDeleteRequest.
--
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]