Search in sources :

Example 16 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 17 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 18 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() throws Exception {
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
    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.Test)

Example 19 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 20 with PluginConfiguration

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

the class AuthorizationExtensionTest method shouldTalkToPlugin_To_GetPluginConfigurationMetadata.

@Test
public void shouldTalkToPlugin_To_GetPluginConfigurationMetadata() throws Exception {
    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(), is(2));
    assertThat(authConfigMetadata, containsInAnyOrder(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.Test)

Aggregations

PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)23 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)21 Test (org.junit.Test)21 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)12 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)8 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)7 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)7 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)6 AgentMetadata (com.thoughtworks.go.plugin.access.elastic.models.AgentMetadata)4 PluginView (com.thoughtworks.go.plugin.domain.common.PluginView)4 GoPluginApiRequest (com.thoughtworks.go.plugin.api.request.GoPluginApiRequest)3 ConfigRepoPluginInfo (com.thoughtworks.go.plugin.domain.configrepo.ConfigRepoPluginInfo)3 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)3 DefaultGoPluginApiResponse (com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse)2 AuthorizationPluginInfo (com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)2 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)2 GoCipher (com.thoughtworks.go.security.GoCipher)2 ConfigurationPropertyBuilder (com.thoughtworks.go.config.builder.ConfigurationPropertyBuilder)1 PluginSettingsConfiguration (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration)1 ArtifactPluginInfo (com.thoughtworks.go.plugin.domain.artifact.ArtifactPluginInfo)1