@Test public void testCheckRight() { when(umsClient.checkRight(anyString(), anyString(), anyString(), any())).thenReturn(false); thrown.expect(AccessDeniedException.class); thrown.expectMessage("You have no right to perform datalake/read in account 1234"); ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest. checkRightOfUser(USER_CRN, AuthorizationResourceAction.DATALAKE_READ)); }
public void checkRightOfUser(String userCrn, AuthorizationResourceAction action) { String unauthorizedMessage = String.format("You have no right to perform %s in account %s.", umsRightProvider.getRight(action), Crn.fromString(userCrn).getAccountId()); checkRightOfUser(userCrn, action, unauthorizedMessage); }
UmsAccountAuthorizationService { public void checkRightOfUser(String userCrn, AuthorizationResourceAction action) { String unauthorizedMessage = String.format("You have no right to perform %s in account %s.", umsRightProvider.getRight(action), Crn.fromString(userCrn).getAccountId()); checkRightOfUser(userCrn, action, unauthorizedMessage); } }
UmsAccountAuthorizationService { public void checkRightOfUser(String userCrn, AuthorizationResourceAction action) { String unauthorizedMessage = String.format("You have no right to perform %s in account %s.", umsRightProvider.getRight(action), Crn.fromString(userCrn).getAccountId()); checkRightOfUser(userCrn, action, unauthorizedMessage); }  }
UmsAccountAuthorizationService { public void checkRightOfUser(String userCrn, AuthorizationResourceAction action) { String unauthorizedMessage = String.format("You have no right to perform %s in account %s.", umsRightProvider.getRight(action), Crn.fromString(userCrn).getAccountId()); checkRightOfUser(userCrn, action, unauthorizedMessage); }  void checkRightOfUser(String userCrn, AuthorizationResourceAction action); Boolean hasRightOfUser(String userCrn, String action); void checkCallerIsSelfOrHasRight(String actorCrnStr, String targetUserCrnStr, AuthorizationResourceAction action); }
UmsAccountAuthorizationService { public void checkRightOfUser(String userCrn, AuthorizationResourceAction action) { String unauthorizedMessage = String.format("You have no right to perform %s in account %s.", umsRightProvider.getRight(action), Crn.fromString(userCrn).getAccountId()); checkRightOfUser(userCrn, action, unauthorizedMessage); }  void checkRightOfUser(String userCrn, AuthorizationResourceAction action); Boolean hasRightOfUser(String userCrn, String action); void checkCallerIsSelfOrHasRight(String actorCrnStr, String targetUserCrnStr, AuthorizationResourceAction action);  }