github-advanced-security[bot] commented on code in PR #19877:
URL: https://github.com/apache/druid/pull/19877#discussion_r3714325144
##########
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/basic/authorization/endpoint/BasicAuthorizerResourceTest.java:
##########
@@ -74,264 +79,286 @@
@Test
public void getAllUsersShouldReturnExpectedUsers()
{
- Assert.assertNotNull(target.getAllUsers(req, AUTHORIZER_NAME));
+ Assertions.assertNotNull(target.getAllUsers(req, AUTHORIZER_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void getAllUsersWithInvalidAuthorizerNameShouldThrowException()
{
- target.getAllUsers(req, INVALID_AUTHORIZER_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.getAllUsers(req, INVALID_AUTHORIZER_NAME));
}
@Test
public void getAllGroupMappingsShouldReturnExpectedGroupMappings()
{
- Assert.assertNotNull(target.getAllGroupMappings(req, AUTHORIZER_NAME));
+ Assertions.assertNotNull(target.getAllGroupMappings(req, AUTHORIZER_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void
getAllGroupMappingsWithInvalidAuthorizerNameShouldThrowException()
{
- target.getAllGroupMappings(req, INVALID_AUTHORIZER_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.getAllGroupMappings(req, INVALID_AUTHORIZER_NAME));
}
@Test
public void getUserShouldReturnExpectedUser()
{
- Assert.assertNotNull(target.getUser(req, AUTHORIZER_NAME, USER_NAME, null,
null));
+ Assertions.assertNotNull(target.getUser(req, AUTHORIZER_NAME, USER_NAME,
null, null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void getUserWithInvalidAuthorizerNameShouldThrowException()
{
- target.getUser(req, INVALID_AUTHORIZER_NAME, USER_NAME, null, null);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.getUser(req, INVALID_AUTHORIZER_NAME, USER_NAME, null, null));
}
@Test
public void getGroupMappingShouldReturnExpectedGroupMapping()
{
- Assert.assertNotNull(target.getGroupMapping(req, AUTHORIZER_NAME,
GROUP_MAPPING_NAME, null));
+ Assertions.assertNotNull(target.getGroupMapping(req, AUTHORIZER_NAME,
GROUP_MAPPING_NAME, null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void getGroupMappingWithInvalidAuthorizerNameShouldThrowException()
{
- target.getGroupMapping(req, INVALID_AUTHORIZER_NAME, GROUP_MAPPING_NAME,
null);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.getGroupMapping(req, INVALID_AUTHORIZER_NAME, GROUP_MAPPING_NAME,
null));
}
@Test
public void createUserShouldReturnExpectedResponse()
{
- Assert.assertNotNull(target.createUser(req, AUTHORIZER_NAME, USER_NAME));
+ Assertions.assertNotNull(target.createUser(req, AUTHORIZER_NAME,
USER_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void createUserWithInvalidAuthorizerNameShouldThrowException()
{
- target.createUser(req, INVALID_AUTHORIZER_NAME, USER_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.createUser(req, INVALID_AUTHORIZER_NAME, USER_NAME));
}
@Test
public void deleteUserShouldReturnExpectedResponse()
{
- Assert.assertNotNull(target.deleteUser(req, AUTHORIZER_NAME, USER_NAME));
+ Assertions.assertNotNull(target.deleteUser(req, AUTHORIZER_NAME,
USER_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void deleteUserWithInvalidAuthorizerNameShouldThrowException()
{
- target.deleteUser(req, INVALID_AUTHORIZER_NAME, USER_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.deleteUser(req, INVALID_AUTHORIZER_NAME, USER_NAME));
}
@Test
public void createGroupMappingShouldReturnExpectedResponse()
{
- Assert.assertNotNull(target.createGroupMapping(req, AUTHORIZER_NAME,
GROUP_MAPPING_NAME, groupMapping));
+ Assertions.assertNotNull(target.createGroupMapping(req, AUTHORIZER_NAME,
GROUP_MAPPING_NAME, groupMapping));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void createGroupMappingWithInvalidAuthorizerNameShouldThrowException()
{
- target.createGroupMapping(req, INVALID_AUTHORIZER_NAME,
GROUP_MAPPING_NAME, groupMapping);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.createGroupMapping(req, INVALID_AUTHORIZER_NAME,
GROUP_MAPPING_NAME, groupMapping));
}
@Test
public void deleteGroupMappingShouldReturnExpectedResponse()
{
- Assert.assertNotNull(target.deleteGroupMapping(req, AUTHORIZER_NAME,
GROUP_MAPPING_NAME));
+ Assertions.assertNotNull(target.deleteGroupMapping(req, AUTHORIZER_NAME,
GROUP_MAPPING_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void deleteGroupMappingWithInvalidAuthorizerNameShouldThrowException()
{
- target.deleteGroupMapping(req, INVALID_AUTHORIZER_NAME,
GROUP_MAPPING_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.deleteGroupMapping(req, INVALID_AUTHORIZER_NAME,
GROUP_MAPPING_NAME));
}
@Test
public void getRoleShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.getRole(req, AUTHORIZER_NAME, ROLE_NAME, null,
null));
+ Assertions.assertNotNull(target.getRole(req, AUTHORIZER_NAME, ROLE_NAME,
null, null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void getRoleWithInvalidAuthorizerNameShouldThrowException()
{
- target.getRole(req, INVALID_AUTHORIZER_NAME, ROLE_NAME, null, null);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.getRole(req, INVALID_AUTHORIZER_NAME, ROLE_NAME, null, null));
}
@Test
public void createRoleShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.createRole(req, AUTHORIZER_NAME, ROLE_NAME));
+ Assertions.assertNotNull(target.createRole(req, AUTHORIZER_NAME,
ROLE_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void createRoleWithInvalidAuthorizerNameShouldThrowException()
{
- target.createRole(req, INVALID_AUTHORIZER_NAME, ROLE_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.createRole(req, INVALID_AUTHORIZER_NAME, ROLE_NAME));
}
@Test
public void deleteRoleShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.deleteRole(req, AUTHORIZER_NAME, ROLE_NAME));
+ Assertions.assertNotNull(target.deleteRole(req, AUTHORIZER_NAME,
ROLE_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void deleteRoleWithInvalidAuthorizerNameShouldThrowException()
{
- target.deleteRole(req, INVALID_AUTHORIZER_NAME, ROLE_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.deleteRole(req, INVALID_AUTHORIZER_NAME, ROLE_NAME));
}
@Test
public void assignRoleToUserShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.assignRoleToUser(req, AUTHORIZER_NAME,
USER_NAME, ROLE_NAME));
+ Assertions.assertNotNull(target.assignRoleToUser(req, AUTHORIZER_NAME,
USER_NAME, ROLE_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void assignRoleToUserWithInvalidAuthorizerNameShouldThrowException()
{
- target.assignRoleToUser(req, INVALID_AUTHORIZER_NAME, USER_NAME,
ROLE_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.assignRoleToUser(req, INVALID_AUTHORIZER_NAME, USER_NAME,
ROLE_NAME));
}
@Test
public void unassignRoleFromUserShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.unassignRoleFromUser(req, AUTHORIZER_NAME,
USER_NAME, ROLE_NAME));
+ Assertions.assertNotNull(target.unassignRoleFromUser(req, AUTHORIZER_NAME,
USER_NAME, ROLE_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void
unassignRoleFromUserWithInvalidAuthorizerNameShouldThrowException()
{
- target.unassignRoleFromUser(req, INVALID_AUTHORIZER_NAME, USER_NAME,
ROLE_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.unassignRoleFromUser(req, INVALID_AUTHORIZER_NAME, USER_NAME,
ROLE_NAME));
}
@Test
public void assignRoleToGroupMappingShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.assignRoleToGroupMapping(req, AUTHORIZER_NAME,
GROUP_MAPPING_NAME, ROLE_NAME));
+ Assertions.assertNotNull(target.assignRoleToGroupMapping(req,
AUTHORIZER_NAME, GROUP_MAPPING_NAME, ROLE_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void
assignRoleToGroupMappingWithInvalidAuthorizerNameShouldThrowException()
{
- target.assignRoleToGroupMapping(req, INVALID_AUTHORIZER_NAME,
GROUP_MAPPING_NAME, ROLE_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.assignRoleToGroupMapping(req, INVALID_AUTHORIZER_NAME,
GROUP_MAPPING_NAME, ROLE_NAME));
}
@Test
public void unassignRoleFromGroupMappingShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.unassignRoleFromGroupMapping(req,
AUTHORIZER_NAME, GROUP_MAPPING_NAME, ROLE_NAME));
+ Assertions.assertNotNull(target.unassignRoleFromGroupMapping(req,
AUTHORIZER_NAME, GROUP_MAPPING_NAME, ROLE_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void
unassignRoleFromGroupMappingWithInvalidAuthorizerNameShouldThrowException()
{
- target.unassignRoleFromGroupMapping(req, INVALID_AUTHORIZER_NAME,
GROUP_MAPPING_NAME, ROLE_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.unassignRoleFromGroupMapping(req, INVALID_AUTHORIZER_NAME,
GROUP_MAPPING_NAME, ROLE_NAME));
}
@Test
public void setRolePermissionsShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.setRolePermissions(req, AUTHORIZER_NAME,
ROLE_NAME, resourceActions));
+ Assertions.assertNotNull(target.setRolePermissions(req, AUTHORIZER_NAME,
ROLE_NAME, resourceActions));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void setRolePermissionsWithInvalidAuthorizerNameShouldThrowException()
{
- target.setRolePermissions(req, INVALID_AUTHORIZER_NAME, ROLE_NAME,
resourceActions);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.setRolePermissions(req, INVALID_AUTHORIZER_NAME, ROLE_NAME,
resourceActions));
}
@Test
public void getRolePermissionsShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.getRolePermissions(req, AUTHORIZER_NAME,
ROLE_NAME));
+ Assertions.assertNotNull(target.getRolePermissions(req, AUTHORIZER_NAME,
ROLE_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void getRolePermissionsWithInvalidAuthorizerNameShouldThrowException()
{
- target.getRolePermissions(req, INVALID_AUTHORIZER_NAME, ROLE_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.getRolePermissions(req, INVALID_AUTHORIZER_NAME, ROLE_NAME));
}
@Test
public void getCachedSerializedUserMapShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.getCachedSerializedUserMap(req,
AUTHORIZER_NAME));
+ Assertions.assertNotNull(target.getCachedSerializedUserMap(req,
AUTHORIZER_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void
getCachedSerializedUserMapWithInvalidAuthorizerNameShouldThrowException()
{
- target.getCachedSerializedUserMap(req, INVALID_AUTHORIZER_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.getCachedSerializedUserMap(req, INVALID_AUTHORIZER_NAME));
}
@Test
public void getCachedSerializedGroupMapShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.getCachedSerializedGroupMap(req,
AUTHORIZER_NAME));
+ Assertions.assertNotNull(target.getCachedSerializedGroupMap(req,
AUTHORIZER_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void
getCachedSerializedGroupMapWithInvalidAuthorizerNameShouldThrowException()
{
- target.getCachedSerializedGroupMap(req, INVALID_AUTHORIZER_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.getCachedSerializedGroupMap(req, INVALID_AUTHORIZER_NAME));
}
@Test
public void authorizerUpdateListenerShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.authorizerUpdateListener(req, AUTHORIZER_NAME,
SERIALIZED_ROLE_MAP));
+ Assertions.assertNotNull(target.authorizerUpdateListener(req,
AUTHORIZER_NAME, SERIALIZED_ROLE_MAP));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void
authorizerUpdateListenerWithInvalidAuthorizerNameShouldThrowException()
{
- target.authorizerUpdateListener(req, INVALID_AUTHORIZER_NAME,
SERIALIZED_ROLE_MAP);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.authorizerUpdateListener(req, INVALID_AUTHORIZER_NAME,
SERIALIZED_ROLE_MAP));
Review Comment:
## CodeQL / Deprecated method or constructor invocation
Invoking [BasicAuthorizerResource.authorizerUpdateListener](1) should be
avoided because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11548)
##########
extensions-core/druid-basic-security/src/test/java/org/apache/druid/security/basic/authorization/endpoint/BasicAuthorizerResourceTest.java:
##########
@@ -74,264 +79,286 @@
@Test
public void getAllUsersShouldReturnExpectedUsers()
{
- Assert.assertNotNull(target.getAllUsers(req, AUTHORIZER_NAME));
+ Assertions.assertNotNull(target.getAllUsers(req, AUTHORIZER_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void getAllUsersWithInvalidAuthorizerNameShouldThrowException()
{
- target.getAllUsers(req, INVALID_AUTHORIZER_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.getAllUsers(req, INVALID_AUTHORIZER_NAME));
}
@Test
public void getAllGroupMappingsShouldReturnExpectedGroupMappings()
{
- Assert.assertNotNull(target.getAllGroupMappings(req, AUTHORIZER_NAME));
+ Assertions.assertNotNull(target.getAllGroupMappings(req, AUTHORIZER_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void
getAllGroupMappingsWithInvalidAuthorizerNameShouldThrowException()
{
- target.getAllGroupMappings(req, INVALID_AUTHORIZER_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.getAllGroupMappings(req, INVALID_AUTHORIZER_NAME));
}
@Test
public void getUserShouldReturnExpectedUser()
{
- Assert.assertNotNull(target.getUser(req, AUTHORIZER_NAME, USER_NAME, null,
null));
+ Assertions.assertNotNull(target.getUser(req, AUTHORIZER_NAME, USER_NAME,
null, null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void getUserWithInvalidAuthorizerNameShouldThrowException()
{
- target.getUser(req, INVALID_AUTHORIZER_NAME, USER_NAME, null, null);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.getUser(req, INVALID_AUTHORIZER_NAME, USER_NAME, null, null));
}
@Test
public void getGroupMappingShouldReturnExpectedGroupMapping()
{
- Assert.assertNotNull(target.getGroupMapping(req, AUTHORIZER_NAME,
GROUP_MAPPING_NAME, null));
+ Assertions.assertNotNull(target.getGroupMapping(req, AUTHORIZER_NAME,
GROUP_MAPPING_NAME, null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void getGroupMappingWithInvalidAuthorizerNameShouldThrowException()
{
- target.getGroupMapping(req, INVALID_AUTHORIZER_NAME, GROUP_MAPPING_NAME,
null);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.getGroupMapping(req, INVALID_AUTHORIZER_NAME, GROUP_MAPPING_NAME,
null));
}
@Test
public void createUserShouldReturnExpectedResponse()
{
- Assert.assertNotNull(target.createUser(req, AUTHORIZER_NAME, USER_NAME));
+ Assertions.assertNotNull(target.createUser(req, AUTHORIZER_NAME,
USER_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void createUserWithInvalidAuthorizerNameShouldThrowException()
{
- target.createUser(req, INVALID_AUTHORIZER_NAME, USER_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.createUser(req, INVALID_AUTHORIZER_NAME, USER_NAME));
}
@Test
public void deleteUserShouldReturnExpectedResponse()
{
- Assert.assertNotNull(target.deleteUser(req, AUTHORIZER_NAME, USER_NAME));
+ Assertions.assertNotNull(target.deleteUser(req, AUTHORIZER_NAME,
USER_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void deleteUserWithInvalidAuthorizerNameShouldThrowException()
{
- target.deleteUser(req, INVALID_AUTHORIZER_NAME, USER_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.deleteUser(req, INVALID_AUTHORIZER_NAME, USER_NAME));
}
@Test
public void createGroupMappingShouldReturnExpectedResponse()
{
- Assert.assertNotNull(target.createGroupMapping(req, AUTHORIZER_NAME,
GROUP_MAPPING_NAME, groupMapping));
+ Assertions.assertNotNull(target.createGroupMapping(req, AUTHORIZER_NAME,
GROUP_MAPPING_NAME, groupMapping));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void createGroupMappingWithInvalidAuthorizerNameShouldThrowException()
{
- target.createGroupMapping(req, INVALID_AUTHORIZER_NAME,
GROUP_MAPPING_NAME, groupMapping);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.createGroupMapping(req, INVALID_AUTHORIZER_NAME,
GROUP_MAPPING_NAME, groupMapping));
}
@Test
public void deleteGroupMappingShouldReturnExpectedResponse()
{
- Assert.assertNotNull(target.deleteGroupMapping(req, AUTHORIZER_NAME,
GROUP_MAPPING_NAME));
+ Assertions.assertNotNull(target.deleteGroupMapping(req, AUTHORIZER_NAME,
GROUP_MAPPING_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void deleteGroupMappingWithInvalidAuthorizerNameShouldThrowException()
{
- target.deleteGroupMapping(req, INVALID_AUTHORIZER_NAME,
GROUP_MAPPING_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.deleteGroupMapping(req, INVALID_AUTHORIZER_NAME,
GROUP_MAPPING_NAME));
}
@Test
public void getRoleShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.getRole(req, AUTHORIZER_NAME, ROLE_NAME, null,
null));
+ Assertions.assertNotNull(target.getRole(req, AUTHORIZER_NAME, ROLE_NAME,
null, null));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void getRoleWithInvalidAuthorizerNameShouldThrowException()
{
- target.getRole(req, INVALID_AUTHORIZER_NAME, ROLE_NAME, null, null);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.getRole(req, INVALID_AUTHORIZER_NAME, ROLE_NAME, null, null));
}
@Test
public void createRoleShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.createRole(req, AUTHORIZER_NAME, ROLE_NAME));
+ Assertions.assertNotNull(target.createRole(req, AUTHORIZER_NAME,
ROLE_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void createRoleWithInvalidAuthorizerNameShouldThrowException()
{
- target.createRole(req, INVALID_AUTHORIZER_NAME, ROLE_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.createRole(req, INVALID_AUTHORIZER_NAME, ROLE_NAME));
}
@Test
public void deleteRoleShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.deleteRole(req, AUTHORIZER_NAME, ROLE_NAME));
+ Assertions.assertNotNull(target.deleteRole(req, AUTHORIZER_NAME,
ROLE_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void deleteRoleWithInvalidAuthorizerNameShouldThrowException()
{
- target.deleteRole(req, INVALID_AUTHORIZER_NAME, ROLE_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.deleteRole(req, INVALID_AUTHORIZER_NAME, ROLE_NAME));
}
@Test
public void assignRoleToUserShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.assignRoleToUser(req, AUTHORIZER_NAME,
USER_NAME, ROLE_NAME));
+ Assertions.assertNotNull(target.assignRoleToUser(req, AUTHORIZER_NAME,
USER_NAME, ROLE_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void assignRoleToUserWithInvalidAuthorizerNameShouldThrowException()
{
- target.assignRoleToUser(req, INVALID_AUTHORIZER_NAME, USER_NAME,
ROLE_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.assignRoleToUser(req, INVALID_AUTHORIZER_NAME, USER_NAME,
ROLE_NAME));
}
@Test
public void unassignRoleFromUserShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.unassignRoleFromUser(req, AUTHORIZER_NAME,
USER_NAME, ROLE_NAME));
+ Assertions.assertNotNull(target.unassignRoleFromUser(req, AUTHORIZER_NAME,
USER_NAME, ROLE_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void
unassignRoleFromUserWithInvalidAuthorizerNameShouldThrowException()
{
- target.unassignRoleFromUser(req, INVALID_AUTHORIZER_NAME, USER_NAME,
ROLE_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.unassignRoleFromUser(req, INVALID_AUTHORIZER_NAME, USER_NAME,
ROLE_NAME));
}
@Test
public void assignRoleToGroupMappingShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.assignRoleToGroupMapping(req, AUTHORIZER_NAME,
GROUP_MAPPING_NAME, ROLE_NAME));
+ Assertions.assertNotNull(target.assignRoleToGroupMapping(req,
AUTHORIZER_NAME, GROUP_MAPPING_NAME, ROLE_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void
assignRoleToGroupMappingWithInvalidAuthorizerNameShouldThrowException()
{
- target.assignRoleToGroupMapping(req, INVALID_AUTHORIZER_NAME,
GROUP_MAPPING_NAME, ROLE_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.assignRoleToGroupMapping(req, INVALID_AUTHORIZER_NAME,
GROUP_MAPPING_NAME, ROLE_NAME));
}
@Test
public void unassignRoleFromGroupMappingShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.unassignRoleFromGroupMapping(req,
AUTHORIZER_NAME, GROUP_MAPPING_NAME, ROLE_NAME));
+ Assertions.assertNotNull(target.unassignRoleFromGroupMapping(req,
AUTHORIZER_NAME, GROUP_MAPPING_NAME, ROLE_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void
unassignRoleFromGroupMappingWithInvalidAuthorizerNameShouldThrowException()
{
- target.unassignRoleFromGroupMapping(req, INVALID_AUTHORIZER_NAME,
GROUP_MAPPING_NAME, ROLE_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.unassignRoleFromGroupMapping(req, INVALID_AUTHORIZER_NAME,
GROUP_MAPPING_NAME, ROLE_NAME));
}
@Test
public void setRolePermissionsShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.setRolePermissions(req, AUTHORIZER_NAME,
ROLE_NAME, resourceActions));
+ Assertions.assertNotNull(target.setRolePermissions(req, AUTHORIZER_NAME,
ROLE_NAME, resourceActions));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void setRolePermissionsWithInvalidAuthorizerNameShouldThrowException()
{
- target.setRolePermissions(req, INVALID_AUTHORIZER_NAME, ROLE_NAME,
resourceActions);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.setRolePermissions(req, INVALID_AUTHORIZER_NAME, ROLE_NAME,
resourceActions));
}
@Test
public void getRolePermissionsShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.getRolePermissions(req, AUTHORIZER_NAME,
ROLE_NAME));
+ Assertions.assertNotNull(target.getRolePermissions(req, AUTHORIZER_NAME,
ROLE_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void getRolePermissionsWithInvalidAuthorizerNameShouldThrowException()
{
- target.getRolePermissions(req, INVALID_AUTHORIZER_NAME, ROLE_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.getRolePermissions(req, INVALID_AUTHORIZER_NAME, ROLE_NAME));
}
@Test
public void getCachedSerializedUserMapShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.getCachedSerializedUserMap(req,
AUTHORIZER_NAME));
+ Assertions.assertNotNull(target.getCachedSerializedUserMap(req,
AUTHORIZER_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void
getCachedSerializedUserMapWithInvalidAuthorizerNameShouldThrowException()
{
- target.getCachedSerializedUserMap(req, INVALID_AUTHORIZER_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.getCachedSerializedUserMap(req, INVALID_AUTHORIZER_NAME));
}
@Test
public void getCachedSerializedGroupMapShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.getCachedSerializedGroupMap(req,
AUTHORIZER_NAME));
+ Assertions.assertNotNull(target.getCachedSerializedGroupMap(req,
AUTHORIZER_NAME));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void
getCachedSerializedGroupMapWithInvalidAuthorizerNameShouldThrowException()
{
- target.getCachedSerializedGroupMap(req, INVALID_AUTHORIZER_NAME);
+ assertThrows(IllegalArgumentException.class, () ->
+ target.getCachedSerializedGroupMap(req, INVALID_AUTHORIZER_NAME));
}
@Test
public void authorizerUpdateListenerShouldReturnExpectedResult()
{
- Assert.assertNotNull(target.authorizerUpdateListener(req, AUTHORIZER_NAME,
SERIALIZED_ROLE_MAP));
+ Assertions.assertNotNull(target.authorizerUpdateListener(req,
AUTHORIZER_NAME, SERIALIZED_ROLE_MAP));
Review Comment:
## CodeQL / Deprecated method or constructor invocation
Invoking [BasicAuthorizerResource.authorizerUpdateListener](1) should be
avoided because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/11547)
--
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]