use of com.thoughtworks.go.server.ui.AuthPluginInfoViewModel in project gocd by gocd.
the class SecurityAuthConfigService method getAllConfiguredWebBasedAuthorizationPlugins.
public List<AuthPluginInfoViewModel> getAllConfiguredWebBasedAuthorizationPlugins() {
ArrayList<AuthPluginInfoViewModel> result = new ArrayList();
Set<AuthorizationPluginInfo> loadedWebBasedAuthPlugins = authorizationMetadataStore.getPluginsThatSupportsWebBasedAuthentication();
SecurityAuthConfigs configuredAuthPluginProfiles = getPluginProfiles();
for (SecurityAuthConfig authConfig : configuredAuthPluginProfiles) {
AuthorizationPluginInfo authorizationPluginInfo = loadedWebBasedAuthPlugins.stream().filter(authorizationPluginInfo1 -> authorizationPluginInfo1.getDescriptor().id().equals(authConfig.getPluginId())).findFirst().orElse(null);
if (authorizationPluginInfo != null) {
result.add(new AuthPluginInfoViewModel(authorizationPluginInfo));
}
}
return result;
}
use of com.thoughtworks.go.server.ui.AuthPluginInfoViewModel 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"));
}
Aggregations