use of com.thoughtworks.go.plugin.domain.common.PluginConfiguration in project gocd by gocd.
the class BasicCruiseConfigTest method setArtifactPluginInfo.
private void setArtifactPluginInfo() {
PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
PluggableInstanceSettings storeConfigSettings = new PluggableInstanceSettings(asList());
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 publishArtifactSettings = new PluggableInstanceSettings(asList(k1, k2, k3));
PluggableInstanceSettings fetchArtifactSettings = new PluggableInstanceSettings(asList(k1, k2, k3));
ArtifactPluginInfo artifactPluginInfo = new ArtifactPluginInfo(pluginDescriptor, storeConfigSettings, publishArtifactSettings, fetchArtifactSettings, null, new Capabilities());
when(pluginDescriptor.id()).thenReturn("cd.go.s3");
ArtifactMetadataStore.instance().setPluginInfo(artifactPluginInfo);
}
use of com.thoughtworks.go.plugin.domain.common.PluginConfiguration in project gocd by gocd.
the class SecurityAuthConfigTest method postConstruct_shouldEncryptSecureConfigurations.
@Test
public void postConstruct_shouldEncryptSecureConfigurations() throws Exception {
PluggableInstanceSettings profileSettings = new PluggableInstanceSettings(Arrays.asList(new PluginConfiguration("password", new Metadata(true, true))));
AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfo(pluginDescriptor("plugin_id"), profileSettings, null, null, null);
store.setPluginInfo(pluginInfo);
SecurityAuthConfig authConfig = new SecurityAuthConfig("id", "plugin_id", new ConfigurationProperty(new ConfigurationKey("password"), new ConfigurationValue("pass")));
authConfig.encryptSecureConfigurations();
assertThat(authConfig.size(), is(1));
assertTrue(authConfig.first().isSecure());
}
use of com.thoughtworks.go.plugin.domain.common.PluginConfiguration 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)));
}
use of com.thoughtworks.go.plugin.domain.common.PluginConfiguration 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))));
}
use of com.thoughtworks.go.plugin.domain.common.PluginConfiguration 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))));
}
Aggregations