@Test public void userIsEffectivelyAManagerReturnsFalseWhenAuthenticatedUserIsAdminButUserDoesNotEqual() { given(retrieverMock.getUserId()).willReturn(USER_ID); given(userServiceMock.getUserById(USER_ID)).willReturn(userMock); boolean actualHasAccess = userAuthService.userIsEffectivelyAManager(otherUserMock); assertThat(actualHasAccess).isFalse(); }
@Override public boolean userIsEffectivelyAManager(User user) { return (getAuthenticatedUser().equals(user) && authenticatedUserIsAdmin()) || (userService.userIsManager(user)); }
DefaultUserAuthService implements UserAuthService { @Override public boolean userIsEffectivelyAManager(User user) { return (getAuthenticatedUser().equals(user) && authenticatedUserIsAdmin()) || (userService.userIsManager(user)); } }
DefaultUserAuthService implements UserAuthService { @Override public boolean userIsEffectivelyAManager(User user) { return (getAuthenticatedUser().equals(user) && authenticatedUserIsAdmin()) || (userService.userIsManager(user)); } DefaultUserAuthService(UserService userService, AuthenticationInfoRetriever retriever); }
DefaultUserAuthService implements UserAuthService { @Override public boolean userIsEffectivelyAManager(User user) { return (getAuthenticatedUser().equals(user) && authenticatedUserIsAdmin()) || (userService.userIsManager(user)); } DefaultUserAuthService(UserService userService, AuthenticationInfoRetriever retriever); @Override User getAuthenticatedUser(); @Override String getAuthenticatedUserId(); @Override boolean authenticatedUserIsAdmin(); @Override boolean userIsEffectivelyAManager(User user); }
DefaultUserAuthService implements UserAuthService { @Override public boolean userIsEffectivelyAManager(User user) { return (getAuthenticatedUser().equals(user) && authenticatedUserIsAdmin()) || (userService.userIsManager(user)); } DefaultUserAuthService(UserService userService, AuthenticationInfoRetriever retriever); @Override User getAuthenticatedUser(); @Override String getAuthenticatedUserId(); @Override boolean authenticatedUserIsAdmin(); @Override boolean userIsEffectivelyAManager(User user);  }