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