Search in sources :

Example 1 with AuthorizationPluginInfo

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

the class CombinedPluginInfoTest method shouldFindFirstExtensionWithImageIfPluginImplementsAtleastOneExtensionWithImage.

@Test
public void shouldFindFirstExtensionWithImageIfPluginImplementsAtleastOneExtensionWithImage() throws Exception {
    Image image1 = new Image("c1", "d1", "hash1");
    Image image2 = new Image("c2", "d2", "hash2");
    Image image3 = new Image("c3", "d3", "hash3");
    ElasticAgentPluginInfo elasticAgentPluginInfo = new ElasticAgentPluginInfo(null, null, image1, null, null);
    AuthorizationPluginInfo authorizationPluginInfo = new AuthorizationPluginInfo(null, null, null, image2, null);
    AnalyticsPluginInfo analyticsPluginInfo = new AnalyticsPluginInfo(null, image3, null, null);
    assertThat(new CombinedPluginInfo(elasticAgentPluginInfo).getImage(), is(image1));
    assertThat(new CombinedPluginInfo(authorizationPluginInfo).getImage(), is(image2));
    assertThat(new CombinedPluginInfo(analyticsPluginInfo).getImage(), is(image3));
    assertThat(new CombinedPluginInfo(asList(elasticAgentPluginInfo, authorizationPluginInfo)).getImage(), anyOf(is(image1), is(image2)));
    assertThat(new CombinedPluginInfo(asList(analyticsPluginInfo, authorizationPluginInfo)).getImage(), anyOf(is(image2), is(image3)));
}
Also used : ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) AnalyticsPluginInfo(com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) Test(org.junit.Test)

Example 2 with AuthorizationPluginInfo

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

the class ConfigInfoProviderTest method pluginInfo.

private AuthorizationPluginInfo pluginInfo(String pluginId, String pluginName) {
    final AuthorizationPluginInfo pluginInfo = mock(AuthorizationPluginInfo.class);
    final PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
    final PluginDescriptor.About about = mock(PluginDescriptor.About.class);
    when(pluginDescriptor.id()).thenReturn(pluginId);
    when(pluginDescriptor.about()).thenReturn(about);
    when(about.name()).thenReturn(pluginName);
    when(pluginInfo.getDescriptor()).thenReturn(pluginDescriptor);
    Capabilities capabilities = mock(Capabilities.class);
    when(capabilities.getSupportedAuthType()).thenReturn(SupportedAuthType.Password);
    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 3 with AuthorizationPluginInfo

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

the class AuthorizationMetadataLoaderTest method onPluginLoaded_shouldAddPluginInfoToMetadataStore.

@Test
public void onPluginLoaded_shouldAddPluginInfoToMetadataStore() 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);
    when(extension.canHandlePlugin(descriptor.id())).thenReturn(true);
    when(infoBuilder.pluginInfoFor(descriptor)).thenReturn(pluginInfo);
    metadataLoader.pluginLoaded(descriptor);
    verify(metadataStore).setPluginInfo(pluginInfo);
}
Also used : AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 4 with AuthorizationPluginInfo

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

the class AuthorizationPluginInfoBuilderTest method shouldBuildPluginInfoWithImage.

@Test
public void shouldBuildPluginInfoWithImage() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    Image icon = new Image("content_type", "data", "hash");
    when(extension.getIcon(descriptor.id())).thenReturn(icon);
    AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfoBuilder(extension).pluginInfoFor(descriptor);
    assertThat(pluginInfo.getImage(), is(icon));
}
Also used : AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 5 with AuthorizationPluginInfo

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

the class AuthorizationPluginInfoBuilderTest method shouldNotHaveRoleSettingsInPluginInfoIfPluginCannotAuthorize.

@Test
public void shouldNotHaveRoleSettingsInPluginInfoIfPluginCannotAuthorize() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    Capabilities capabilities = new Capabilities(SupportedAuthType.Password, true, false);
    when(extension.getCapabilities(descriptor.id())).thenReturn(capabilities);
    AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfoBuilder(extension).pluginInfoFor(descriptor);
    assertNull(pluginInfo.getRoleSettings());
}
Also used : Capabilities(com.thoughtworks.go.plugin.domain.authorization.Capabilities) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

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