Search in sources :

Example 16 with AuthorizationPluginInfo

use of com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo in project gocd by gocd.

the class ConfigInfoProvider method securityInformation.

private LinkedHashMap<String, Object> securityInformation() {
    final LinkedHashMap<String, Object> security = new LinkedHashMap<>();
    final ArrayList<Map<String, Object>> pluginsConfigured = new ArrayList<>();
    security.put("Plugins", pluginsConfigured);
    if (goConfigService.security().securityAuthConfigs().isEmpty()) {
        security.put("Enabled", false);
        return security;
    }
    security.put("Enabled", true);
    for (AuthorizationPluginInfo pluginInfo : authorizationMetadataStore.allPluginInfos()) {
        final String pluginName = pluginInfo.getDescriptor().about().name();
        final boolean hashAuthConfig = !goConfigService.security().securityAuthConfigs().findByPluginId(pluginInfo.getDescriptor().id()).isEmpty();
        pluginsConfigured.add(singletonMap(pluginName, hashAuthConfig));
    }
    return security;
}
Also used : ArrayList(java.util.ArrayList) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) LinkedHashMap(java.util.LinkedHashMap)

Example 17 with AuthorizationPluginInfo

use of com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo in project gocd by gocd.

the class AuthorizationMetadataStoreTest method pluginInfo.

private AuthorizationPluginInfo pluginInfo(String pluginId, SupportedAuthType supportedAuthType) {
    AuthorizationPluginInfo pluginInfo = mock(AuthorizationPluginInfo.class);
    PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
    when(pluginDescriptor.id()).thenReturn(pluginId);
    when(pluginInfo.getDescriptor()).thenReturn(pluginDescriptor);
    Capabilities capabilities = mock(Capabilities.class);
    when(capabilities.getSupportedAuthType()).thenReturn(supportedAuthType);
    when(pluginInfo.getCapabilities()).thenReturn(capabilities);
    return pluginInfo;
}
Also used : PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) Capabilities(com.thoughtworks.go.plugin.domain.authorization.Capabilities) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)

Example 18 with AuthorizationPluginInfo

use of com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo in project gocd by gocd.

the class AuthorizationMetadataLoaderTest method onPluginUnloded_shouldRemoveTheCorrespondingPluginInfoFromStore.

@Test
public void onPluginUnloded_shouldRemoveTheCorrespondingPluginInfoFromStore() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    AuthorizationMetadataLoader metadataLoader = new AuthorizationMetadataLoader(pluginManager, metadataStore, infoBuilder, extension);
    AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfo(descriptor, null, null, null, null);
    metadataStore.setPluginInfo(pluginInfo);
    metadataLoader.pluginUnLoaded(descriptor);
    verify(metadataStore).remove(descriptor.id());
}
Also used : AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 19 with AuthorizationPluginInfo

use of com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo in project gocd by gocd.

the class AuthorizationPluginInfoBuilderTest method shouldBuildPluginInfoWithPluginDescriptor.

@Test
public void shouldBuildPluginInfoWithPluginDescriptor() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfoBuilder(extension).pluginInfoFor(descriptor);
    assertThat(pluginInfo.getDescriptor(), is(descriptor));
}
Also used : AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 20 with AuthorizationPluginInfo

use of com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo in project gocd by gocd.

the class AuthorizationPluginInfoBuilder method pluginInfoFor.

public AuthorizationPluginInfo pluginInfoFor(GoPluginDescriptor descriptor) {
    Capabilities capabilities = capabilities(descriptor.id());
    PluggableInstanceSettings authConfigSettings = authConfigSettings(descriptor.id());
    PluggableInstanceSettings roleSettings = roleSettings(descriptor.id(), capabilities);
    Image image = image(descriptor.id());
    return new AuthorizationPluginInfo(descriptor, authConfigSettings, roleSettings, image, capabilities);
}
Also used : PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) Capabilities(com.thoughtworks.go.plugin.domain.authorization.Capabilities) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) Image(com.thoughtworks.go.plugin.domain.common.Image)

Aggregations

AuthorizationPluginInfo (com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)24 Test (org.junit.Test)16 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)12 Capabilities (com.thoughtworks.go.plugin.domain.authorization.Capabilities)9 ArrayList (java.util.ArrayList)5 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)4 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)3 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)3 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)3 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)3 Image (com.thoughtworks.go.plugin.domain.common.Image)3 Map (java.util.Map)3 SecurityAuthConfig (com.thoughtworks.go.config.SecurityAuthConfig)2 PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)2 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)2 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)2 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)2 AuthPluginInfoViewModel (com.thoughtworks.go.server.ui.AuthPluginInfoViewModel)2 SecurityAuthConfigs (com.thoughtworks.go.config.SecurityAuthConfigs)1 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)1