use of com.thoughtworks.go.plugin.domain.common.Metadata in project gocd by gocd.
the class ArtifactExtensionTestBase 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.Metadata in project gocd by gocd.
the class ArtifactExtensionTestBase 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.Metadata in project gocd by gocd.
the class AuthorizationExtensionTest method shouldTalkToPlugin_To_GetRoleConfigurationMetadata.
@Test
void shouldTalkToPlugin_To_GetRoleConfigurationMetadata() {
String responseBody = "[{\"key\":\"memberOf\",\"metadata\":{\"required\":true,\"secure\":false}}]";
when(pluginManager.submitTo(eq(PLUGIN_ID), eq(AUTHORIZATION_EXTENSION), requestArgumentCaptor.capture())).thenReturn(new DefaultGoPluginApiResponse(SUCCESS_RESPONSE_CODE, responseBody));
List<PluginConfiguration> roleConfigurationMetadata = authorizationExtension.getRoleConfigurationMetadata(PLUGIN_ID);
assertRequest(requestArgumentCaptor.getValue(), AUTHORIZATION_EXTENSION, "1.0", REQUEST_GET_ROLE_CONFIG_METADATA, null);
assertThat(roleConfigurationMetadata.size()).isEqualTo(1);
assertThat(roleConfigurationMetadata).contains(new PluginConfiguration("memberOf", new Metadata(true, false)));
}
use of com.thoughtworks.go.plugin.domain.common.Metadata in project gocd by gocd.
the class ArtifactStoreTest method postConstruct_shouldEncryptSecureConfigurations.
@Test
public void postConstruct_shouldEncryptSecureConfigurations() {
final PluggableInstanceSettings storeConfig = new PluggableInstanceSettings(Arrays.asList(new PluginConfiguration("password", new Metadata(true, true))));
final ArtifactPluginInfo pluginInfo = new ArtifactPluginInfo(pluginDescriptor("plugin_id"), storeConfig, null, null, null, null);
store.setPluginInfo(pluginInfo);
ArtifactStore artifactStore = new ArtifactStore("id", "plugin_id", new ConfigurationProperty(new ConfigurationKey("password"), new ConfigurationValue("pass")));
artifactStore.encryptSecureConfigurations();
assertThat(artifactStore.size(), is(1));
assertTrue(artifactStore.first().isSecure());
}
use of com.thoughtworks.go.plugin.domain.common.Metadata in project gocd by gocd.
the class BasicCruiseConfigTest method setEAPluginInfo.
private void setEAPluginInfo() {
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 clusterProfileSettings = new PluggableInstanceSettings(asList(k1, k2, k3));
PluggableInstanceSettings profileSettings = new PluggableInstanceSettings(asList(k1, k2, k3));
com.thoughtworks.go.plugin.domain.elastic.Capabilities capabilities = new com.thoughtworks.go.plugin.domain.elastic.Capabilities(true);
ElasticAgentPluginInfo ecsPluginInfo = new ElasticAgentPluginInfo(pluginDescriptor, clusterProfileSettings, profileSettings, null, null, capabilities);
when(pluginDescriptor.id()).thenReturn("ecs");
ElasticAgentMetadataStore.instance().setPluginInfo(ecsPluginInfo);
}
Aggregations