@Test public void hasPersmissionToApplyToProjectReturnsTrueWhenProjectDoesNotExist() { given(projectServiceMock.projectExists(PROJECT_ID)).willReturn(false); boolean actualHasPermission = evaluator.hasPermissionToApplyToProject(authenticationMock, userMock, PROJECT_ID); assertThat(actualHasPermission).isTrue(); }
@Override public boolean hasPermissionToApplyToProject(Authentication authentication, User user, String projectId) { if(projectDoesNotExistOrHasLobIndependentStatus(projectId)) { return true; } var project = projectService.getProjectById(projectId); if(applicationService.userHasAppliedForProject(user, project)) { return true; } if(userService.userIsManager(user)) { return true; } if(!userAccessService.userHasActiveAccessInterval(user)) { return false; } var projectLob = project.getLob(); var userLob = userService.getUserData(user).getLob(); return projectLob == null || projectLob.equalsIgnoreCase(userLob) || bookmarkService.userHasBookmark(user, project); }
UserAccessExpressionEvaluator implements ExpressionEvaluator { @Override public boolean hasPermissionToApplyToProject(Authentication authentication, User user, String projectId) { if(projectDoesNotExistOrHasLobIndependentStatus(projectId)) { return true; } var project = projectService.getProjectById(projectId); if(applicationService.userHasAppliedForProject(user, project)) { return true; } if(userService.userIsManager(user)) { return true; } if(!userAccessService.userHasActiveAccessInterval(user)) { return false; } var projectLob = project.getLob(); var userLob = userService.getUserData(user).getLob(); return projectLob == null || projectLob.equalsIgnoreCase(userLob) || bookmarkService.userHasBookmark(user, project); } }
UserAccessExpressionEvaluator implements ExpressionEvaluator { @Override public boolean hasPermissionToApplyToProject(Authentication authentication, User user, String projectId) { if(projectDoesNotExistOrHasLobIndependentStatus(projectId)) { return true; } var project = projectService.getProjectById(projectId); if(applicationService.userHasAppliedForProject(user, project)) { return true; } if(userService.userIsManager(user)) { return true; } if(!userAccessService.userHasActiveAccessInterval(user)) { return false; } var projectLob = project.getLob(); var userLob = userService.getUserData(user).getLob(); return projectLob == null || projectLob.equalsIgnoreCase(userLob) || bookmarkService.userHasBookmark(user, project); } @Autowired  UserAccessExpressionEvaluator(UserService userService,
                                         UserAccessService userAccessService,
                                         ProjectService projectService,
                                         ApplicationService applicationService,
                                         BookmarkService bookmarkService,
                                         ProjectBoardConfigurationProperties properties); }
UserAccessExpressionEvaluator implements ExpressionEvaluator { @Override public boolean hasPermissionToApplyToProject(Authentication authentication, User user, String projectId) { if(projectDoesNotExistOrHasLobIndependentStatus(projectId)) { return true; } var project = projectService.getProjectById(projectId); if(applicationService.userHasAppliedForProject(user, project)) { return true; } if(userService.userIsManager(user)) { return true; } if(!userAccessService.userHasActiveAccessInterval(user)) { return false; } var projectLob = project.getLob(); var userLob = userService.getUserData(user).getLob(); return projectLob == null || projectLob.equalsIgnoreCase(userLob) || bookmarkService.userHasBookmark(user, project); } @Autowired  UserAccessExpressionEvaluator(UserService userService,
                                         UserAccessService userAccessService,
                                         ProjectService projectService,
                                         ApplicationService applicationService,
                                         BookmarkService bookmarkService,
                                         ProjectBoardConfigurationProperties properties); @Override boolean hasAccessToProjects(Authentication authentication, User user); @Override boolean hasAccessToProject(Authentication authentication, User user, String projectId); @Override boolean hasPermissionToApplyToProject(Authentication authentication, User user, String projectId); @Override boolean hasPermissionToAccessUser(Authentication authentication, User user, String userId); @Override boolean hasElevatedAccessToUser(Authentication authentication, User user, String userId); }
UserAccessExpressionEvaluator implements ExpressionEvaluator { @Override public boolean hasPermissionToApplyToProject(Authentication authentication, User user, String projectId) { if(projectDoesNotExistOrHasLobIndependentStatus(projectId)) { return true; } var project = projectService.getProjectById(projectId); if(applicationService.userHasAppliedForProject(user, project)) { return true; } if(userService.userIsManager(user)) { return true; } if(!userAccessService.userHasActiveAccessInterval(user)) { return false; } var projectLob = project.getLob(); var userLob = userService.getUserData(user).getLob(); return projectLob == null || projectLob.equalsIgnoreCase(userLob) || bookmarkService.userHasBookmark(user, project); } @Autowired  UserAccessExpressionEvaluator(UserService userService,
                                         UserAccessService userAccessService,
                                         ProjectService projectService,
                                         ApplicationService applicationService,
                                         BookmarkService bookmarkService,
                                         ProjectBoardConfigurationProperties properties); @Override boolean hasAccessToProjects(Authentication authentication, User user); @Override boolean hasAccessToProject(Authentication authentication, User user, String projectId); @Override boolean hasPermissionToApplyToProject(Authentication authentication, User user, String projectId); @Override boolean hasPermissionToAccessUser(Authentication authentication, User user, String userId); @Override boolean hasElevatedAccessToUser(Authentication authentication, User user, String userId);  }