Search in sources :

Example 46 with Metadata

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

the class AuthorizationExtensionTest method shouldTalkToPlugin_To_GetPluginConfigurationMetadata.

@Test
void shouldTalkToPlugin_To_GetPluginConfigurationMetadata() {
    String responseBody = "[{\"key\":\"username\",\"metadata\":{\"required\":true,\"secure\":false}},{\"key\":\"password\",\"metadata\":{\"required\":true,\"secure\":true}}]";
    when(pluginManager.submitTo(eq(PLUGIN_ID), eq(AUTHORIZATION_EXTENSION), requestArgumentCaptor.capture())).thenReturn(new DefaultGoPluginApiResponse(SUCCESS_RESPONSE_CODE, responseBody));
    List<PluginConfiguration> authConfigMetadata = authorizationExtension.getAuthConfigMetadata(PLUGIN_ID);
    assertRequest(requestArgumentCaptor.getValue(), AUTHORIZATION_EXTENSION, "1.0", REQUEST_GET_AUTH_CONFIG_METADATA, null);
    assertThat(authConfigMetadata.size()).isEqualTo(2);
    assertThat(authConfigMetadata).hasSize(2).contains(new PluginConfiguration("username", new Metadata(true, false)), new PluginConfiguration("password", new Metadata(true, true)));
}
Also used : DefaultGoPluginApiResponse(com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) Test(org.junit.jupiter.api.Test)

Example 47 with Metadata

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

the class ArtifactExtensionTestBase 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.jupiter.api.Test)

Example 48 with Metadata

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

the class PluginProfileMetadataKeysTest method shouldGetPluginConfigurations.

@Test
public void shouldGetPluginConfigurations() throws Exception {
    PluginProfileMetadataKeys metadata = PluginProfileMetadataKeys.fromJSON("[{\n" + "  \"key\": \"username\",\n" + "  \"metadata\": {\n" + "    \"secure\": true,\n" + "    \"required\": false\n" + "  }\n" + "}, {\n" + "  \"key\": \"password\",\n" + "  \"metadata\": {\n" + "    \"secure\": true,\n" + "    \"required\": true\n" + "  }\n" + "}]");
    List<PluginConfiguration> pluginConfigurations = metadata.toPluginConfigurations();
    assertThat(pluginConfigurations, containsInAnyOrder(new PluginConfiguration("username", new Metadata(false, true)), new PluginConfiguration("password", new Metadata(true, true))));
}
Also used : Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) Test(org.junit.jupiter.api.Test)

Example 49 with Metadata

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

the class PluginProfileMetadataKeysTest method shouldGetPluginConfigurationsWithMetadataDefaultedToFalseInAbsenceOfPluginMetadata.

@Test
public void shouldGetPluginConfigurationsWithMetadataDefaultedToFalseInAbsenceOfPluginMetadata() throws Exception {
    PluginProfileMetadataKeys metadata = PluginProfileMetadataKeys.fromJSON("[{\n" + "  \"key\": \"username\"\n" + "}, {\n" + "  \"key\": \"password\",\n" + "  \"metadata\": {\n" + "    \"secure\": true,\n" + "    \"required\": true\n" + "  }\n" + "}]");
    List<PluginConfiguration> pluginConfigurations = metadata.toPluginConfigurations();
    assertThat(pluginConfigurations, containsInAnyOrder(new PluginConfiguration("username", new Metadata(false, false)), new PluginConfiguration("password", new Metadata(true, true))));
}
Also used : Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) Test(org.junit.jupiter.api.Test)

Example 50 with Metadata

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

the class SecretsExtensionV1Test method shouldTalkToPlugin_toFetchSecretsConfigMetadata.

@Test
void shouldTalkToPlugin_toFetchSecretsConfigMetadata() {
    String responseBody = "[{\"key\":\"Username\",\"metadata\":{\"required\":true,\"secure\":false}},{\"key\":\"Password\",\"metadata\":{\"required\":true,\"secure\":true}}]";
    when(pluginManager.submitTo(eq(PLUGIN_ID), eq(SECRETS_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(responseBody));
    final List<PluginConfiguration> metadata = secretsExtensionV1.getSecretsConfigMetadata(PLUGIN_ID);
    assertThat(metadata).hasSize(2);
    assertThat(metadata).contains(new PluginConfiguration("Username", new Metadata(true, false)), new PluginConfiguration("Password", new Metadata(true, true)));
    assertExtensionRequest(REQUEST_GET_SECRETS_CONFIG_METADATA, null);
}
Also used : Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)51 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)51 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)33 Test (org.junit.jupiter.api.Test)33 GoCipher (com.thoughtworks.go.security.GoCipher)13 ArrayList (java.util.ArrayList)13 PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)11 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)10 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)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 AuthorizationPluginInfo (com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)5 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)5 PluginView (com.thoughtworks.go.plugin.domain.common.PluginView)3