@Test public void testCheckRightOnResource() { when(umsClient.checkRight(anyString(), anyString(), anyString(), anyString(), any())).thenReturn(false); thrown.expect(AccessDeniedException.class); thrown.expectMessage("You have no right to perform environments/describeEnvironment on resource " + RESOURCE_CRN); ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest. checkRightOfUserOnResource(USER_CRN, AuthorizationResourceAction.DESCRIBE_ENVIRONMENT, RESOURCE_CRN)); }
public void checkRightOfUserOnResource(String userCrn, AuthorizationResourceAction action, String resourceCrn) { String right = umsRightProvider.getRight(action); String unauthorizedMessage = String.format("You have no right to perform %s on resource %s.", right, resourceCrn); checkRightOfUserOnResource(userCrn, right, resourceCrn, unauthorizedMessage); }
UmsResourceAuthorizationService { public void checkRightOfUserOnResource(String userCrn, AuthorizationResourceAction action, String resourceCrn) { String right = umsRightProvider.getRight(action); String unauthorizedMessage = String.format("You have no right to perform %s on resource %s.", right, resourceCrn); checkRightOfUserOnResource(userCrn, right, resourceCrn, unauthorizedMessage); } }
UmsResourceAuthorizationService { public void checkRightOfUserOnResource(String userCrn, AuthorizationResourceAction action, String resourceCrn) { String right = umsRightProvider.getRight(action); String unauthorizedMessage = String.format("You have no right to perform %s on resource %s.", right, resourceCrn); checkRightOfUserOnResource(userCrn, right, resourceCrn, unauthorizedMessage); }  }
UmsResourceAuthorizationService { public void checkRightOfUserOnResource(String userCrn, AuthorizationResourceAction action, String resourceCrn) { String right = umsRightProvider.getRight(action); String unauthorizedMessage = String.format("You have no right to perform %s on resource %s.", right, resourceCrn); checkRightOfUserOnResource(userCrn, right, resourceCrn, unauthorizedMessage); }  void checkRightOfUserOnResource(String userCrn, AuthorizationResourceAction action, String resourceCrn); Map<String, Boolean> getRightOfUserOnResources(String userCrn, AuthorizationResourceAction action, List<String> resourceCrns); void checkRightOfUserOnResources(String userCrn, AuthorizationResourceAction action, Collection<String> resourceCrns); void checkIfUserHasAtLeastOneRight(String userCrn, Map<String, AuthorizationResourceAction> checkedRightsForResources); }
UmsResourceAuthorizationService { public void checkRightOfUserOnResource(String userCrn, AuthorizationResourceAction action, String resourceCrn) { String right = umsRightProvider.getRight(action); String unauthorizedMessage = String.format("You have no right to perform %s on resource %s.", right, resourceCrn); checkRightOfUserOnResource(userCrn, right, resourceCrn, unauthorizedMessage); }  void checkRightOfUserOnResource(String userCrn, AuthorizationResourceAction action, String resourceCrn); Map<String, Boolean> getRightOfUserOnResources(String userCrn, AuthorizationResourceAction action, List<String> resourceCrns); void checkRightOfUserOnResources(String userCrn, AuthorizationResourceAction action, Collection<String> resourceCrns); void checkIfUserHasAtLeastOneRight(String userCrn, Map<String, AuthorizationResourceAction> checkedRightsForResources);  }