Search in sources :

Example 46 with PluginConfiguration

use of com.thoughtworks.go.plugin.domain.common.PluginConfiguration in project gocd by gocd.

the class ElasticAgentPluginInfoBuilder method elasticClusterProfileSettings.

private PluggableInstanceSettings elasticClusterProfileSettings(String pluginId) {
    if (extension.supportsClusterProfiles(pluginId)) {
        List<PluginConfiguration> profileMetadata = extension.getClusterProfileMetadata(pluginId);
        String profileView = extension.getClusterProfileView(pluginId);
        return new PluggableInstanceSettings(profileMetadata, new PluginView(profileView));
    }
    return new PluggableInstanceSettings(null, null);
}
Also used : PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) PluginView(com.thoughtworks.go.plugin.domain.common.PluginView)

Example 47 with PluginConfiguration

use of com.thoughtworks.go.plugin.domain.common.PluginConfiguration in project gocd by gocd.

the class ConfigRepoPluginInfoBuilderTest method shouldBuildPluginInfo.

@Test
public void shouldBuildPluginInfo() throws Exception {
    GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
    when(extension.getPluginSettingsView("plugin1")).thenReturn("some-html");
    when(extension.getCapabilities("plugin1")).thenReturn(new Capabilities(true, true, true, true));
    ConfigRepoPluginInfo pluginInfo = new ConfigRepoPluginInfoBuilder(extension).pluginInfoFor(descriptor);
    List<PluginConfiguration> pluginConfigurations = Arrays.asList(new PluginConfiguration("username", new Metadata(true, false)), new PluginConfiguration("password", new Metadata(true, true)));
    PluginView pluginView = new PluginView("some-html");
    assertThat(pluginInfo.getDescriptor(), is(descriptor));
    assertThat(pluginInfo.getExtensionName(), is("configrepo"));
    assertThat(pluginInfo.getPluginSettings(), is(new PluggableInstanceSettings(pluginConfigurations, pluginView)));
    assertThat(pluginInfo.getCapabilities(), is(new Capabilities(true, true, true, true)));
}
Also used : PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) Capabilities(com.thoughtworks.go.plugin.domain.configrepo.Capabilities) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) PluginView(com.thoughtworks.go.plugin.domain.common.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) ConfigRepoPluginInfo(com.thoughtworks.go.plugin.domain.configrepo.ConfigRepoPluginInfo) Test(org.junit.jupiter.api.Test)

Example 48 with PluginConfiguration

use of com.thoughtworks.go.plugin.domain.common.PluginConfiguration in project gocd by gocd.

the class ElasticAgentExtensionV5Test method shouldGetProfileMetadata.

@Test
public void shouldGetProfileMetadata() {
    String responseBody = "[{\"key\":\"Username\",\"metadata\":{\"required\":true,\"secure\":false}},{\"key\":\"Password\",\"metadata\":{\"required\":true,\"secure\":true}}]";
    when(pluginManager.submitTo(eq(PLUGIN_ID), eq(ELASTIC_AGENT_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(responseBody));
    final List<PluginConfiguration> metadata = extensionV5.getElasticProfileMetadata(PLUGIN_ID);
    assertThat(metadata, hasSize(2));
    assertThat(metadata, containsInAnyOrder(new PluginConfiguration("Username", new Metadata(true, false)), new PluginConfiguration("Password", new Metadata(true, true))));
    assertExtensionRequest("5.0", REQUEST_GET_ELASTIC_AGENT_PROFILE_METADATA, null);
}
Also used : Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) AgentMetadata(com.thoughtworks.go.plugin.access.elastic.models.AgentMetadata) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) Test(org.junit.jupiter.api.Test)

Example 49 with PluginConfiguration

use of com.thoughtworks.go.plugin.domain.common.PluginConfiguration in project gocd by gocd.

the class NotificationPluginInfoBuilderTest method shouldBuildPluginInfo.

@Test
public void shouldBuildPluginInfo() {
    GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
    NotificationPluginInfo pluginInfo = new NotificationPluginInfoBuilder(extension).pluginInfoFor(descriptor);
    List<PluginConfiguration> pluginConfigurations = Arrays.asList(new PluginConfiguration("username", new Metadata(true, false)), new PluginConfiguration("password", new Metadata(true, true)));
    PluginView pluginView = new PluginView("some-html");
    assertThat(pluginInfo.getDescriptor(), is(descriptor));
    assertThat(pluginInfo.getExtensionName(), is("notification"));
    assertThat(pluginInfo.getPluginSettings(), is(new PluggableInstanceSettings(pluginConfigurations, pluginView)));
}
Also used : PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) NotificationPluginInfo(com.thoughtworks.go.plugin.domain.notification.NotificationPluginInfo) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) PluginView(com.thoughtworks.go.plugin.domain.common.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.jupiter.api.Test)

Example 50 with PluginConfiguration

use of com.thoughtworks.go.plugin.domain.common.PluginConfiguration in project gocd by gocd.

the class RoleConfigCommandTest method setAuthorizationPluginInfo.

private void setAuthorizationPluginInfo() {
    PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
    PluginConfiguration k1 = new PluginConfiguration("k1", new Metadata(false, true));
    PluginConfiguration k2 = new PluginConfiguration("k2", new Metadata(false, false));
    PluginConfiguration k3 = new PluginConfiguration("k3", new Metadata(false, true));
    PluggableInstanceSettings authConfigSettins = new PluggableInstanceSettings(asList(k1, k2, k3));
    PluggableInstanceSettings roleConfigSettings = new PluggableInstanceSettings(asList(k1, k2, k3));
    com.thoughtworks.go.plugin.domain.authorization.Capabilities capabilities = new com.thoughtworks.go.plugin.domain.authorization.Capabilities(SupportedAuthType.Web, true, true, true);
    AuthorizationPluginInfo artifactPluginInfo = new AuthorizationPluginInfo(pluginDescriptor, authConfigSettins, roleConfigSettings, null, capabilities);
    when(pluginDescriptor.id()).thenReturn("cd.go.github");
    AuthorizationMetadataStore.instance().setPluginInfo(artifactPluginInfo);
}
Also used : Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration)

Aggregations

PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)58 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)51 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)38 Test (org.junit.jupiter.api.Test)36 GoCipher (com.thoughtworks.go.security.GoCipher)14 ArrayList (java.util.ArrayList)14 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)11 PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)11 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)10 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)10 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)9 Test (org.junit.Test)9 AgentMetadata (com.thoughtworks.go.plugin.access.elastic.models.AgentMetadata)8 ArtifactPluginInfo (com.thoughtworks.go.plugin.domain.artifact.ArtifactPluginInfo)8 Capabilities (com.thoughtworks.go.plugin.domain.artifact.Capabilities)8 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)8 GoPluginApiRequest (com.thoughtworks.go.plugin.api.request.GoPluginApiRequest)6 PluginView (com.thoughtworks.go.plugin.domain.common.PluginView)6 AuthorizationPluginInfo (com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)5 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)5