Search in sources :

Example 16 with SecurityConfig

use of com.thoughtworks.go.config.SecurityConfig in project gocd by gocd.

the class FileAuthenticationProviderTest method shouldNotEngageWhenPasswordFileIsNotConfigured.

@Test
public void shouldNotEngageWhenPasswordFileIsNotConfigured() throws Exception {
    FileAuthenticationProvider provider = new FileAuthenticationProvider(goConfigService, null, userService, securityService);
    when(goConfigService.security()).thenReturn(new SecurityConfig(null, new PasswordFileConfig(), true));
    assertThat(provider.supports(UsernamePasswordAuthenticationToken.class), is(false));
}
Also used : SecurityConfig(com.thoughtworks.go.config.SecurityConfig) UsernamePasswordAuthenticationToken(org.springframework.security.providers.UsernamePasswordAuthenticationToken) PasswordFileConfig(com.thoughtworks.go.config.PasswordFileConfig) Test(org.junit.Test)

Example 17 with SecurityConfig

use of com.thoughtworks.go.config.SecurityConfig in project gocd by gocd.

the class PluginAuthenticationProviderTest method setUp.

@Before
public void setUp() {
    initMocks(this);
    when(authenticationToken.getCredentials()).thenReturn("password");
    userAuthority = GoAuthority.ROLE_USER.asAuthority();
    when(authorityGranter.authorities("username")).thenReturn(new GrantedAuthority[] { userAuthority });
    provider = new PluginAuthenticationProvider(authorizationExtension, authorityGranter, goConfigService, pluginRoleService, userService);
    securityConfig = new SecurityConfig();
    when(goConfigService.security()).thenReturn(securityConfig);
}
Also used : SecurityConfig(com.thoughtworks.go.config.SecurityConfig) Before(org.junit.Before)

Example 18 with SecurityConfig

use of com.thoughtworks.go.config.SecurityConfig in project gocd by gocd.

the class PreAuthenticatedRequestsProcessingFilterTest method setUp.

@Before
public void setUp() throws Exception {
    request = mock(HttpServletRequest.class);
    response = mock(HttpServletResponse.class);
    filterChain = mock(FilterChain.class);
    authenticationManager = mock(AuthenticationManager.class);
    authorizationExtension = mock(AuthorizationExtension.class);
    configService = mock(GoConfigService.class);
    filter = new PreAuthenticatedRequestsProcessingFilter(authorizationExtension, configService);
    securityConfig = new SecurityConfig();
    filter.setAuthenticationManager(authenticationManager);
    filter.setFilterProcessesUrl("^/go/plugin/([\\w\\-.]+)/authenticate$");
    stub(configService.security()).toReturn(securityConfig);
    stub(request.getHeaderNames()).toReturn(Collections.emptyEnumeration());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) AuthenticationManager(org.springframework.security.AuthenticationManager) SecurityConfig(com.thoughtworks.go.config.SecurityConfig) AuthorizationExtension(com.thoughtworks.go.plugin.access.authorization.AuthorizationExtension) FilterChain(javax.servlet.FilterChain) HttpServletResponse(javax.servlet.http.HttpServletResponse) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) Before(org.junit.Before)

Example 19 with SecurityConfig

use of com.thoughtworks.go.config.SecurityConfig in project gocd by gocd.

the class RemoveAdminPermissionFilter method onConfigChange.

public void onConfigChange(CruiseConfig newCruiseConfig) {
    SecurityConfig newSecurityConfig = securityConfig(newCruiseConfig);
    if (this.securityConfig != null && !this.securityConfig.equals(newSecurityConfig)) {
        LOGGER.info("[Configuration Changed] Security Configuration is changed. Updating the last changed time.");
        this.lastChangedTime = timeProvider.currentTimeMillis();
    }
    this.securityConfig = newSecurityConfig;
}
Also used : SecurityConfig(com.thoughtworks.go.config.SecurityConfig)

Example 20 with SecurityConfig

use of com.thoughtworks.go.config.SecurityConfig in project gocd by gocd.

the class AgentRegistrationControllerTest method mockedServerConfig.

private ServerConfig mockedServerConfig(String tokenGenerationKey, String agentAutoRegisterKey) {
    final ServerConfig serverConfig = mock(ServerConfig.class);
    when(serverConfig.getTokenGenerationKey()).thenReturn(tokenGenerationKey);
    when(serverConfig.getAgentAutoRegisterKey()).thenReturn(agentAutoRegisterKey);
    when(serverConfig.shouldAutoRegisterAgentWith(agentAutoRegisterKey)).thenReturn(true);
    when(serverConfig.security()).thenReturn(new SecurityConfig());
    return serverConfig;
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) SecurityConfig(com.thoughtworks.go.config.SecurityConfig)

Aggregations

SecurityConfig (com.thoughtworks.go.config.SecurityConfig)28 Test (org.junit.jupiter.api.Test)9 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)6 LdapConfig (com.thoughtworks.go.config.LdapConfig)5 SecurityAuthConfig (com.thoughtworks.go.config.SecurityAuthConfig)5 Before (org.junit.Before)5 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)4 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)4 PasswordFileConfig (com.thoughtworks.go.config.PasswordFileConfig)4 ServerConfig (com.thoughtworks.go.config.ServerConfig)4 AuthorizationExtension (com.thoughtworks.go.plugin.access.authorization.AuthorizationExtension)4 Test (org.junit.Test)4 AuthorityGranter (com.thoughtworks.go.server.security.AuthorityGranter)3 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)3 UserSearchModel (com.thoughtworks.go.presentation.UserSearchModel)2 GoCipher (com.thoughtworks.go.security.GoCipher)2 PluginRoleService (com.thoughtworks.go.server.service.PluginRoleService)2 UserService (com.thoughtworks.go.server.service.UserService)2 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)2 FilterChain (javax.servlet.FilterChain)2