use of com.thoughtworks.go.plugin.domain.common.PluginConfiguration in project gocd by gocd.
the class ElasticAgentExtensionV1Test 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 = extensionV1.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("1.0", REQUEST_GET_PROFILE_METADATA, null);
}
use of com.thoughtworks.go.plugin.domain.common.PluginConfiguration in project gocd by gocd.
the class ElasticAgentExtensionV2Test 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 = extensionV2.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("2.0", REQUEST_GET_PROFILE_METADATA, null);
}
use of com.thoughtworks.go.plugin.domain.common.PluginConfiguration in project gocd by gocd.
the class ArtifactExtensionTest method shouldGetArtifactStoreMetadataFromPlugin.
@Test
public void shouldGetArtifactStoreMetadataFromPlugin() {
String responseBody = "[{\"key\":\"BUCKET_NAME\",\"metadata\":{\"required\":true,\"secure\":false}},{\"key\":\"AWS_ACCESS_KEY\",\"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.getArtifactStoreMetadata(PLUGIN_ID);
final GoPluginApiRequest request = requestArgumentCaptor.getValue();
assertThat(request.extension(), is(ARTIFACT_EXTENSION));
assertThat(request.requestName(), is(REQUEST_STORE_CONFIG_METADATA));
assertNull(request.requestBody());
assertThat(response.size(), is(2));
assertThat(response, containsInAnyOrder(new PluginConfiguration("BUCKET_NAME", new Metadata(true, false)), new PluginConfiguration("AWS_ACCESS_KEY", new Metadata(true, true))));
}
use of com.thoughtworks.go.plugin.domain.common.PluginConfiguration in project gocd by gocd.
the class ArtifactExtensionTest method shouldGetPluggableArtifactMetadataFromPlugin.
@Test
public void shouldGetPluggableArtifactMetadataFromPlugin() {
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.getPublishArtifactMetadata(PLUGIN_ID);
final GoPluginApiRequest request = requestArgumentCaptor.getValue();
assertThat(request.extension(), is(ARTIFACT_EXTENSION));
assertThat(request.requestName(), is(REQUEST_PUBLISH_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))));
}
use of com.thoughtworks.go.plugin.domain.common.PluginConfiguration in project gocd by gocd.
the class ElasticProfileTest method postConstruct_shouldEncryptSecureConfigurations.
@Test
public void postConstruct_shouldEncryptSecureConfigurations() {
PluggableInstanceSettings profileSettings = new PluggableInstanceSettings(Arrays.asList(new PluginConfiguration("password", new Metadata(true, true))));
ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(pluginDescriptor("plugin_id"), profileSettings, null, null, null);
store.setPluginInfo(pluginInfo);
ElasticProfile profile = new ElasticProfile("id", "plugin_id", new ConfigurationProperty(new ConfigurationKey("password"), new ConfigurationValue("pass")));
profile.encryptSecureConfigurations();
assertThat(profile.size(), is(1));
assertTrue(profile.first().isSecure());
}
Aggregations