@Test public void testHasRightOfUserWithValidResourceTypeAndAction() { when(umsClient.checkRight(anyString(), anyString(), anyString(), any())).thenReturn(true); assertTrue(ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.hasRightOfUser(USER_CRN, "datalake/read"))); when(umsClient.checkRight(anyString(), anyString(), anyString(), any())).thenReturn(false); assertFalse(ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.hasRightOfUser(USER_CRN, "datalake/read"))); }
public Boolean hasRightOfUser(String userCrn, String action) { Optional<AuthorizationResourceAction> actionEnum = umsRightProvider.getByName(action); if (!actionEnum.isPresent()) { throw new BadRequestException("Action cannot be found by request!"); } if (!hasRightOfUser(userCrn, actionEnum.get())) { return Boolean.FALSE; } return Boolean.TRUE; }
UmsAccountAuthorizationService { public Boolean hasRightOfUser(String userCrn, String action) { Optional<AuthorizationResourceAction> actionEnum = umsRightProvider.getByName(action); if (!actionEnum.isPresent()) { throw new BadRequestException("Action cannot be found by request!"); } if (!hasRightOfUser(userCrn, actionEnum.get())) { return Boolean.FALSE; } return Boolean.TRUE; } }
UmsAccountAuthorizationService { public Boolean hasRightOfUser(String userCrn, String action) { Optional<AuthorizationResourceAction> actionEnum = umsRightProvider.getByName(action); if (!actionEnum.isPresent()) { throw new BadRequestException("Action cannot be found by request!"); } if (!hasRightOfUser(userCrn, actionEnum.get())) { return Boolean.FALSE; } return Boolean.TRUE; }  }
UmsAccountAuthorizationService { public Boolean hasRightOfUser(String userCrn, String action) { Optional<AuthorizationResourceAction> actionEnum = umsRightProvider.getByName(action); if (!actionEnum.isPresent()) { throw new BadRequestException("Action cannot be found by request!"); } if (!hasRightOfUser(userCrn, actionEnum.get())) { return Boolean.FALSE; } return Boolean.TRUE; }  void checkRightOfUser(String userCrn, AuthorizationResourceAction action); Boolean hasRightOfUser(String userCrn, String action); void checkCallerIsSelfOrHasRight(String actorCrnStr, String targetUserCrnStr, AuthorizationResourceAction action); }
UmsAccountAuthorizationService { public Boolean hasRightOfUser(String userCrn, String action) { Optional<AuthorizationResourceAction> actionEnum = umsRightProvider.getByName(action); if (!actionEnum.isPresent()) { throw new BadRequestException("Action cannot be found by request!"); } if (!hasRightOfUser(userCrn, actionEnum.get())) { return Boolean.FALSE; } return Boolean.TRUE; }  void checkRightOfUser(String userCrn, AuthorizationResourceAction action); Boolean hasRightOfUser(String userCrn, String action); void checkCallerIsSelfOrHasRight(String actorCrnStr, String targetUserCrnStr, AuthorizationResourceAction action);  }