use of com.thoughtworks.go.config.SecurityConfig in project gocd by gocd.
the class WebBasedAuthenticationFilterTest method setUp.
@Before
public void setUp() throws Exception {
request = mock(HttpServletRequest.class);
response = mock(HttpServletResponse.class);
filterChain = mock(FilterChain.class);
authorizationExtension = mock(AuthorizationExtension.class);
goConfigService = mock(GoConfigService.class);
siteUrlProvider = mock(SiteUrlProvider.class);
securityConfig = new SecurityConfig();
securityAuthConfig = new SecurityAuthConfig("github", "github.oauth", new ConfigurationProperty());
securityConfig.securityAuthConfigs().add(securityAuthConfig);
stub(goConfigService.security()).toReturn(securityConfig);
filter = new WebBasedAuthenticationFilter(authorizationExtension, goConfigService, siteUrlProvider);
}
use of com.thoughtworks.go.config.SecurityConfig 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.config.SecurityConfig in project gocd by gocd.
the class InvalidateAuthenticationOnSecurityConfigChangeFilter method onConfigChange.
@Override
public void onConfigChange(CruiseConfig newCruiseConfig) {
SecurityConfig newSecurityConfig = securityConfig(newCruiseConfig);
if (!Objects.equals(this.securityConfig, newSecurityConfig)) {
updateLastChangedTime();
authorizationExtensionCacheService.invalidateCache();
}
this.securityConfig = newSecurityConfig;
}
use of com.thoughtworks.go.config.SecurityConfig in project gocd by gocd.
the class TokenGenerationKeyImmutabilityValidatorTest method shouldAllowSaveIfTokenGenerationKeyIsUnChanged.
@Test
public void shouldAllowSaveIfTokenGenerationKeyIsUnChanged() throws Exception {
final BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
tokenGenerationKeyImmutabilityValidator.validate(cruiseConfig);
assertThat(tokenGenerationKeyImmutabilityValidator.getTokenGenerationKey(), is(cruiseConfig.server().getTokenGenerationKey()));
cruiseConfig.server().useSecurity(new SecurityConfig());
tokenGenerationKeyImmutabilityValidator.validate(cruiseConfig);
assertThat(tokenGenerationKeyImmutabilityValidator.getTokenGenerationKey(), is(cruiseConfig.server().getTokenGenerationKey()));
}
use of com.thoughtworks.go.config.SecurityConfig in project gocd by gocd.
the class SecurityAuthConfigServiceTest method shouldGetSecurityAuthConfigByGivenId.
@Test
public void shouldGetSecurityAuthConfigByGivenId() throws Exception {
SecurityAuthConfig authConfig = new SecurityAuthConfig("ldap", "cd.go.ldap");
SecurityConfig securityConfig = new SecurityConfig();
securityConfig.securityAuthConfigs().add(authConfig);
when(goConfigService.security()).thenReturn(securityConfig);
assertThat(securityAuthConfigService.findProfile("ldap"), is(authConfig));
}
Aggregations