@Test public void testHasRightOfUserWithInvalidAction() { thrown.expect(BadRequestException.class); thrown.expectMessage("Action cannot be found by request!"); ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.hasRightOfUser(USER_CRN, "invalid")); verifyZeroInteractions(umsClient); }
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);  }