Search in sources :

Example 26 with SecurityConfig

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

the class SecurityAuthConfigServiceTest method shouldGetAListOfAllConfiguredWebBasedAuthorizationPlugins.

@Test
public void shouldGetAListOfAllConfiguredWebBasedAuthorizationPlugins() {
    Set<AuthorizationPluginInfo> installedWebBasedPlugins = new HashSet<>();
    String githubPluginId = "cd.go.github";
    AuthorizationPluginInfo githubPluginInfo = pluginInfo(githubPluginId, "GitHub Auth Plugin", SupportedAuthType.Web);
    installedWebBasedPlugins.add(githubPluginInfo);
    installedWebBasedPlugins.add(pluginInfo(githubPluginId, "Google Auth Plugin", SupportedAuthType.Web));
    when(authorizationMetadataStore.getPluginsThatSupportsWebBasedAuthentication()).thenReturn(installedWebBasedPlugins);
    when(authorizationMetadataStore.getPluginInfo(githubPluginId)).thenReturn(githubPluginInfo);
    SecurityConfig securityConfig = new SecurityConfig();
    SecurityAuthConfig github = new SecurityAuthConfig("github", githubPluginId);
    SecurityAuthConfig ldap = new SecurityAuthConfig("ldap", "cd.go.ldap");
    securityConfig.securityAuthConfigs().add(github);
    securityConfig.securityAuthConfigs().add(ldap);
    when(goConfigService.security()).thenReturn(securityConfig);
    List<AuthPluginInfoViewModel> allWebBasedAuthorizationConfigs = securityAuthConfigService.getAllConfiguredWebBasedAuthorizationPlugins();
    assertThat(allWebBasedAuthorizationConfigs.size(), is(1));
    AuthPluginInfoViewModel pluginInfoViewModel = allWebBasedAuthorizationConfigs.get(0);
    assertThat(pluginInfoViewModel.pluginId(), is(githubPluginId));
    assertThat(pluginInfoViewModel.name(), is("GitHub Auth Plugin"));
    assertThat(pluginInfoViewModel.imageUrl(), is("/go/api/plugin_images/cd.go.github/hash"));
}
Also used : SecurityAuthConfig(com.thoughtworks.go.config.SecurityAuthConfig) SecurityConfig(com.thoughtworks.go.config.SecurityConfig) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) AuthPluginInfoViewModel(com.thoughtworks.go.server.ui.AuthPluginInfoViewModel) Test(org.junit.jupiter.api.Test)

Example 27 with SecurityConfig

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

the class SecurityAuthConfigServiceTest method shouldReturnAnEmptyMapForAuthConfigsIfNonePresent.

@Test
public void shouldReturnAnEmptyMapForAuthConfigsIfNonePresent() {
    when(goConfigService.security()).thenReturn(new SecurityConfig());
    assertThat(securityAuthConfigService.listAll().isEmpty(), is(true));
}
Also used : SecurityConfig(com.thoughtworks.go.config.SecurityConfig) Test(org.junit.jupiter.api.Test)

Example 28 with SecurityConfig

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

the class ConfigInfoProviderTest method goConfigService.

private GoConfigService goConfigService() {
    final GoConfigService goConfigService = mock(GoConfigService.class);
    final CruiseConfig cruiseConfig = mock(CruiseConfig.class);
    when(goConfigService.getCurrentConfig()).thenReturn(cruiseConfig);
    when(goConfigService.getAllPipelineConfigs()).thenReturn(emptyList());
    when(cruiseConfig.getEnvironments()).thenReturn(new EnvironmentsConfig());
    when(cruiseConfig.getAllUniqueMaterials()).thenReturn(emptySet());
    when(goConfigService.getSchedulableMaterials()).thenReturn(emptySet());
    when(goConfigService.security()).thenReturn(new SecurityConfig());
    return goConfigService;
}
Also used : SecurityConfig(com.thoughtworks.go.config.SecurityConfig) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) EnvironmentsConfig(com.thoughtworks.go.config.EnvironmentsConfig)

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