use of com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo 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.plugin.domain.authorization.AuthorizationPluginInfo in project gocd by gocd.
the class ConfigInfoProviderTest method shouldProvideSecurityInformationWhenNoAuthorizationPluginIsConfigured.
@Test
public void shouldProvideSecurityInformationWhenNoAuthorizationPluginIsConfigured() throws Exception {
final GoConfigService goConfigService = goConfigService();
final AuthorizationPluginInfo passwordFile = pluginInfo("cd.go.authentication.passwordfile", "Password File Authentication Plugin for GoCD");
final AuthorizationPluginInfo ldap = pluginInfo("cd.go.authentication.ldap", "LDAP Authentication Plugin for GoCD");
authorizationMetadataStore.setPluginInfo(passwordFile);
authorizationMetadataStore.setPluginInfo(ldap);
final Map<String, Object> map = new ConfigInfoProvider(goConfigService, authorizationMetadataStore).asJson();
final Map<String, Object> security = (Map<String, Object>) map.get("Security");
assertNotNull(security);
assertThat(security, hasEntry("Enabled", false));
assertThat(security, hasEntry("Plugins", new ArrayList<>()));
}
use of com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo in project gocd by gocd.
the class ConfigInfoProviderTest method shouldProvideSecurityInformationWhenAuthorizationPluginsConfigured.
@Test
public void shouldProvideSecurityInformationWhenAuthorizationPluginsConfigured() throws Exception {
final GoConfigService goConfigService = goConfigService();
final AuthorizationPluginInfo passwordFile = pluginInfo("cd.go.authentication.passwordfile", "Password File Authentication Plugin for GoCD");
final AuthorizationPluginInfo ldap = pluginInfo("cd.go.authentication.ldap", "LDAP Authentication Plugin for GoCD");
authorizationMetadataStore.setPluginInfo(passwordFile);
authorizationMetadataStore.setPluginInfo(ldap);
goConfigService.security().securityAuthConfigs().add(new SecurityAuthConfig("file", "cd.go.authentication.passwordfile"));
final Map<String, Object> map = new ConfigInfoProvider(goConfigService, authorizationMetadataStore).asJson();
final Map<String, Object> security = (Map<String, Object>) map.get("Security");
assertNotNull(security);
assertThat(security, hasEntry("Enabled", true));
final List<Map<String, Boolean>> plugins = (List<Map<String, Boolean>>) security.get("Plugins");
assertThat(plugins, containsInAnyOrder(singletonMap("Password File Authentication Plugin for GoCD", true), singletonMap("LDAP Authentication Plugin for GoCD", false)));
}
use of com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo in project gocd by gocd.
the class AuthPluginInfoViewModelTest method shouldGetDetailsAboutThePlugin.
@Test
public void shouldGetDetailsAboutThePlugin() {
GoPluginDescriptor.About about = new GoPluginDescriptor.About("GitHub Auth Plugin", "1.0", null, null, null, null);
String pluginId = "github";
GoPluginDescriptor descriptor = new GoPluginDescriptor(pluginId, "1.0", about, null, null, false);
AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfo(descriptor, null, null, new Image("svg", "data", "hash"), new Capabilities(SupportedAuthType.Web, true, true));
AuthPluginInfoViewModel model = new AuthPluginInfoViewModel(pluginInfo);
assertThat(model.imageUrl(), is("/go/api/plugin_images/github/hash"));
assertThat(model.pluginId(), is("github"));
assertThat(model.name(), is("GitHub Auth Plugin"));
}
Aggregations