Search in sources :

Example 31 with PluginConfiguration

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

the class PipelineConfigsServiceIntegrationTest method setupMetadataForPlugin.

private void setupMetadataForPlugin() {
    PluginDescriptor pluginDescriptor = GoPluginDescriptor.builder().id("cd.go.artifact.docker.registry").build();
    com.thoughtworks.go.plugin.domain.common.PluginConfiguration buildFile = new com.thoughtworks.go.plugin.domain.common.PluginConfiguration("BuildFile", new Metadata(false, false));
    com.thoughtworks.go.plugin.domain.common.PluginConfiguration image = new com.thoughtworks.go.plugin.domain.common.PluginConfiguration("Image", new Metadata(false, true));
    com.thoughtworks.go.plugin.domain.common.PluginConfiguration tag = new com.thoughtworks.go.plugin.domain.common.PluginConfiguration("Tag", new Metadata(false, false));
    com.thoughtworks.go.plugin.domain.common.PluginConfiguration fetchProperty = new com.thoughtworks.go.plugin.domain.common.PluginConfiguration("FetchProperty", new Metadata(false, true));
    com.thoughtworks.go.plugin.domain.common.PluginConfiguration fetchTag = new com.thoughtworks.go.plugin.domain.common.PluginConfiguration("Tag", new Metadata(false, false));
    com.thoughtworks.go.plugin.domain.common.PluginConfiguration registryUrl = new com.thoughtworks.go.plugin.domain.common.PluginConfiguration("RegistryURL", new Metadata(true, false));
    com.thoughtworks.go.plugin.domain.common.PluginConfiguration username = new com.thoughtworks.go.plugin.domain.common.PluginConfiguration("Username", new Metadata(false, false));
    com.thoughtworks.go.plugin.domain.common.PluginConfiguration password = new PluginConfiguration("Password", new Metadata(false, true));
    PluggableInstanceSettings storeConfigSettings = new PluggableInstanceSettings(asList(registryUrl, username, password));
    PluggableInstanceSettings publishArtifactSettings = new PluggableInstanceSettings(asList(buildFile, image, tag));
    PluggableInstanceSettings fetchArtifactSettings = new PluggableInstanceSettings(asList(fetchProperty, fetchTag));
    ArtifactPluginInfo artifactPluginInfo = new ArtifactPluginInfo(pluginDescriptor, storeConfigSettings, publishArtifactSettings, fetchArtifactSettings, null, new Capabilities());
    ArtifactMetadataStore.instance().setPluginInfo(artifactPluginInfo);
}
Also used : PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) ArtifactPluginInfo(com.thoughtworks.go.plugin.domain.artifact.ArtifactPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) Capabilities(com.thoughtworks.go.plugin.domain.artifact.Capabilities) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration)

Example 32 with PluginConfiguration

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

the class ElasticAgentExtensionTest method shouldGetProfileMetadata.

@Test
public void shouldGetProfileMetadata() throws JSONException {
    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 = extension.getProfileMetadata(PLUGIN_ID);
    MatcherAssert.assertThat(metadata, hasSize(2));
    MatcherAssert.assertThat(metadata, containsInAnyOrder(new PluginConfiguration("Username", new Metadata(true, false)), new PluginConfiguration("Password", new Metadata(true, true))));
    assertExtensionRequest("3.0", REQUEST_GET_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.Test)

Example 33 with PluginConfiguration

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

the class ElasticAgentExtensionV3Test method shouldGetProfileMetadata.

@Test
public void shouldGetProfileMetadata() throws JSONException {
    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 = extensionV3.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("3.0", REQUEST_GET_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.Test)

Example 34 with PluginConfiguration

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

the class ArtifactExtensionTest method shouldGetFetchArtifactMetadataFromPlugin.

@Test
public void shouldGetFetchArtifactMetadataFromPlugin() {
    String responseBody = "[{\"key\":\"FILENAME\",\"metadata\":{\"required\":true,\"secure\":false}},{\"key\":\"VERSION\",\"metadata\":{\"required\":true,\"secure\":true}}]";
    when(pluginManager.submitTo(eq(PLUGIN_ID), eq(ARTIFACT_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(responseBody));
    final List<PluginConfiguration> response = artifactExtension.getFetchArtifactMetadata(PLUGIN_ID);
    final GoPluginApiRequest request = requestArgumentCaptor.getValue();
    assertThat(request.extension(), is(ARTIFACT_EXTENSION));
    assertThat(request.requestName(), is(REQUEST_FETCH_ARTIFACT_METADATA));
    assertNull(request.requestBody());
    assertThat(response.size(), is(2));
    assertThat(response, containsInAnyOrder(new PluginConfiguration("FILENAME", new Metadata(true, false)), new PluginConfiguration("VERSION", new Metadata(true, true))));
}
Also used : GoPluginApiRequest(com.thoughtworks.go.plugin.api.request.GoPluginApiRequest) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) Test(org.junit.Test)

Example 35 with PluginConfiguration

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

the class ElasticAgentPluginInfoBuilder method elasticProfileSettings.

private PluggableInstanceSettings elasticProfileSettings(String pluginId) {
    List<PluginConfiguration> profileMetadata = extension.getProfileMetadata(pluginId);
    String profileView = extension.getProfileView(pluginId);
    return new PluggableInstanceSettings(profileMetadata, new PluginView(profileView));
}
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)

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