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));
}
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);
}
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());
}
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;
}
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;
}
Aggregations