use of com.thoughtworks.go.server.service.UserService in project gocd by gocd.
the class GoAuthenticationProviderTest method setUp.
@Before
public void setUp() throws Exception {
userService = mock(UserService.class);
underlyingProvider = mock(AuthenticationProvider.class);
enforcementProvider = new GoAuthenticationProvider(userService, underlyingProvider);
auth = new UsernamePasswordAuthenticationToken(new User("user", "pass", true, true, true, true, new GrantedAuthority[] {}), "credentials");
resultantAuthorization = new UsernamePasswordAuthenticationToken(new User("user-authenticated", "pass", true, true, true, true, new GrantedAuthority[] { GoAuthority.ROLE_GROUP_SUPERVISOR.asAuthority() }), "credentials");
when(underlyingProvider.authenticate(auth)).thenReturn(resultantAuthorization);
}
use of com.thoughtworks.go.server.service.UserService in project gocd by gocd.
the class PreAuthenticatedAuthenticationProviderTest method setUp.
@Before
public void setUp() throws Exception {
pluginId = "github.oauth";
user = new User("username", "displayname", "emailId");
authorities = new GrantedAuthority[] { GoAuthority.ROLE_USER.asAuthority() };
authorizationExtension = mock(AuthorizationExtension.class);
authorityGranter = mock(AuthorityGranter.class);
userService = mock(UserService.class);
pluginRoleService = mock(PluginRoleService.class);
goConfigService = mock(GoConfigService.class);
authenticationProvider = new PreAuthenticatedAuthenticationProvider(authorizationExtension, pluginRoleService, userService, authorityGranter, goConfigService);
AuthenticationResponse authenticationResponse = new AuthenticationResponse(user, asList("admin"));
securityConfig = new SecurityConfig();
stub(goConfigService.security()).toReturn(securityConfig);
stub(authorizationExtension.authenticateUser(any(String.class), any(Map.class), any(List.class), any(List.class))).toReturn(authenticationResponse);
stub(authorityGranter.authorities(anyString())).toReturn(authorities);
securityConfig.securityAuthConfigs().add(new SecurityAuthConfig("github", pluginId));
}
use of com.thoughtworks.go.server.service.UserService in project gocd by gocd.
the class WebBasedPluginAuthenticationProviderTest method setUp.
@BeforeEach
void setUp() {
SecurityService securityService = mock(SecurityService.class);
authorityGranter = spy(new AuthorityGranter(securityService));
goConfigService = mock(GoConfigService.class);
userService = mock(UserService.class);
authorizationExtension = mock(AuthorizationExtension.class);
pluginRoleService = mock(PluginRoleService.class);
clock = new TestingClock();
securityConfig = new SecurityConfig();
githubSecurityAuthconfig = new SecurityAuthConfig("github", PLUGIN_ID);
securityConfig.securityAuthConfigs().add(githubSecurityAuthconfig);
when(goConfigService.security()).thenReturn(securityConfig);
addPluginSupportingWebBasedAuthentication(PLUGIN_ID);
authenticationProvider = new WebBasedPluginAuthenticationProvider(authorizationExtension, authorityGranter, goConfigService, pluginRoleService, userService, clock);
}
use of com.thoughtworks.go.server.service.UserService in project gocd by gocd.
the class PasswordBasedPluginAuthenticationProviderTest method setUp.
@BeforeEach
void setUp() {
SecurityService securityService = mock(SecurityService.class);
AuthorityGranter authorityGranter = new AuthorityGranter(securityService);
GoConfigService goConfigService = mock(GoConfigService.class);
userService = mock(UserService.class);
authorizationExtension = mock(AuthorizationExtension.class);
pluginRoleService = mock(PluginRoleService.class);
clock = new TestingClock();
securityConfig = new SecurityConfig();
when(goConfigService.security()).thenReturn(securityConfig);
provider = new PasswordBasedPluginAuthenticationProvider(authorizationExtension, authorityGranter, goConfigService, pluginRoleService, userService, clock);
}
use of com.thoughtworks.go.server.service.UserService in project gocd by gocd.
the class AbstractUserEnabledCheckFilterTest method setUp.
@BeforeEach
void setUp() throws Exception {
userService = mock(UserService.class);
securityService = mock(SecurityService.class);
filter = spy(new AbstractUserEnabledCheckFilter(userService, securityService) {
@Override
void handleFailure(HttpServletRequest request, HttpServletResponse response, String errorMessage) throws IOException {
}
});
request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
filterChain = mock(FilterChain.class);
}
Aggregations