use of com.thoughtworks.go.config.SecurityAuthConfig 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, agentService()).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)));
}
Aggregations