ChenSammi commented on code in PR #9654:
URL: https://github.com/apache/ozone/pull/9654#discussion_r2720331468
##########
hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/ratis/TestOzoneManagerRatisRequest.java:
##########
@@ -136,4 +140,58 @@ public void testUnknownRequestHandling()
assertEquals(expectedResponse, actualResponse);
}
+
+ @Test
+ public void testAssumeRoleRejectedWhenStsDisabled() {
+ ozoneManager = mock(OzoneManager.class, CALLS_REAL_METHODS);
+ when(ozoneManager.isS3STSEnabled()).thenReturn(false);
+
+ final OzoneManagerProtocolProtos.OMRequest omRequest =
+ OzoneManagerProtocolProtos.OMRequest.newBuilder()
+ .setCmdType(OzoneManagerProtocolProtos.Type.AssumeRole)
+ .setClientId(ClientId.randomId().toString())
+ .build();
+
+ final OMException omException = assertThrows(OMException.class,
+ () -> OzoneManagerRatisUtils.createClientRequest(omRequest,
ozoneManager));
+ assertEquals(OMException.ResultCodes.FEATURE_NOT_ENABLED,
omException.getResult());
+ }
+
+ @Test
+ public void testAssumeRoleRejectedWhenStsEnabledButNativeAuthorizerUsed() {
+ ozoneManager = mock(OzoneManager.class, CALLS_REAL_METHODS);
+ when(ozoneManager.isS3STSEnabled()).thenReturn(true);
+
+ final IAccessAuthorizer authorizer = mock(IAccessAuthorizer.class);
+ when(authorizer.isNative()).thenReturn(true);
+ when(ozoneManager.getAccessAuthorizer()).thenReturn(authorizer);
+
+ final OzoneManagerProtocolProtos.OMRequest omRequest =
+ OzoneManagerProtocolProtos.OMRequest.newBuilder()
+ .setCmdType(OzoneManagerProtocolProtos.Type.AssumeRole)
+ .setClientId(ClientId.randomId().toString())
+ .build();
+
+ final OMException omException = assertThrows(OMException.class,
+ () -> OzoneManagerRatisUtils.createClientRequest(omRequest,
ozoneManager));
+ assertEquals(OMException.ResultCodes.FEATURE_NOT_ENABLED,
omException.getResult());
+ }
+
+ @Test
+ public void testAssumeRoleRejectedWhenStsEnabledAndNativeAuthorizerNotUsed()
{
Review Comment:
testAssumeRoleRejectedWhenStsEnabledAndNativeAuthorizerNotUsed ->
testAssumeRoleAllowedWhenStsEnabledAndNativeAuthorizerNotUsed
--
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]