use of com.thoughtworks.go.plugin.domain.common.Metadata in project gocd by gocd.
the class BasicCruiseConfigTest method setAuthorizationPluginInfo.
private void setAuthorizationPluginInfo() {
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 authConfigSettins = new PluggableInstanceSettings(asList(k1, k2, k3));
PluggableInstanceSettings roleConfigSettings = new PluggableInstanceSettings(asList(k1, k2, k3));
com.thoughtworks.go.plugin.domain.authorization.Capabilities capabilities = new com.thoughtworks.go.plugin.domain.authorization.Capabilities(SupportedAuthType.Web, true, true, true);
AuthorizationPluginInfo artifactPluginInfo = new AuthorizationPluginInfo(pluginDescriptor, authConfigSettins, roleConfigSettings, null, capabilities);
when(pluginDescriptor.id()).thenReturn("cd.go.github");
AuthorizationMetadataStore.instance().setPluginInfo(artifactPluginInfo);
}
use of com.thoughtworks.go.plugin.domain.common.Metadata in project gocd by gocd.
the class PluggableArtifactConfigTest method shouldIgnoreEncryptionOfSecurePropertyForInvalidParamSpecification.
@Test
public void shouldIgnoreEncryptionOfSecurePropertyForInvalidParamSpecification() {
GoCipher goCipher = new GoCipher();
ArrayList<PluginConfiguration> pluginConfigurations = new ArrayList<>();
pluginConfigurations.add(new PluginConfiguration("key1", new Metadata(true, true)));
pluginConfigurations.add(new PluginConfiguration("key2", new Metadata(true, false)));
when(artifactPluginInfo.getArtifactConfigSettings()).thenReturn(new PluggableInstanceSettings(pluginConfigurations));
ConfigurationProperty secureProperty = new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1"), null, goCipher);
ConfigurationProperty nonSecureProperty = new ConfigurationProperty(new ConfigurationKey("key2"), new ConfigurationValue("value2"), null, goCipher);
PluggableArtifactConfig pluggableArtifactConfig = new PluggableArtifactConfig("id", "#{#{invalid}}", secureProperty, nonSecureProperty);
BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
cruiseConfig.getArtifactStores().add(new ArtifactStore("store-id", "cd.go.s3"));
pluggableArtifactConfig.encryptSecureProperties(cruiseConfig, pluggableArtifactConfig);
assertThat(secureProperty.isSecure(), is(false));
assertThat(secureProperty.getValue(), is("value1"));
assertThat(nonSecureProperty.isSecure(), is(false));
assertThat(nonSecureProperty.getValue(), is("value2"));
}
use of com.thoughtworks.go.plugin.domain.common.Metadata in project gocd by gocd.
the class PluggableArtifactConfigTest method shouldIgnoreEncryptionOfSecurePropertyForNonExistentParam.
@Test
public void shouldIgnoreEncryptionOfSecurePropertyForNonExistentParam() {
GoCipher goCipher = new GoCipher();
ArrayList<PluginConfiguration> pluginConfigurations = new ArrayList<>();
pluginConfigurations.add(new PluginConfiguration("key1", new Metadata(true, true)));
pluginConfigurations.add(new PluginConfiguration("key2", new Metadata(true, false)));
when(artifactPluginInfo.getArtifactConfigSettings()).thenReturn(new PluggableInstanceSettings(pluginConfigurations));
ConfigurationProperty secureProperty = new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1"), null, goCipher);
ConfigurationProperty nonSecureProperty = new ConfigurationProperty(new ConfigurationKey("key2"), new ConfigurationValue("value2"), null, goCipher);
PluggableArtifactConfig pluggableArtifactConfig1 = new PluggableArtifactConfig("id", "#{non-existent-param}", secureProperty, nonSecureProperty);
BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
cruiseConfig.getArtifactStores().add(new ArtifactStore("store-id", "cd.go.s3"));
pluggableArtifactConfig1.encryptSecureProperties(cruiseConfig, pluggableArtifactConfig1);
assertThat(secureProperty.isSecure(), is(false));
assertThat(secureProperty.getValue(), is("value1"));
assertThat(nonSecureProperty.isSecure(), is(false));
assertThat(nonSecureProperty.getValue(), is("value2"));
}
use of com.thoughtworks.go.plugin.domain.common.Metadata in project gocd by gocd.
the class ArtifactTypeConfigsTest method setConfigAttributes_shouldSetExternalArtifactWithPlainTextValuesIfPluginIdIsProvided.
@Test
public void setConfigAttributes_shouldSetExternalArtifactWithPlainTextValuesIfPluginIdIsProvided() {
ArtifactPluginInfo artifactPluginInfo = mock(ArtifactPluginInfo.class);
PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
when(artifactPluginInfo.getDescriptor()).thenReturn(pluginDescriptor);
when(pluginDescriptor.id()).thenReturn("cd.go.artifact.foo");
PluginConfiguration image = new PluginConfiguration("Image", new Metadata(true, true));
PluginConfiguration tag = new PluginConfiguration("Tag", new Metadata(true, false));
ArrayList<PluginConfiguration> pluginMetadata = new ArrayList<>();
pluginMetadata.add(image);
pluginMetadata.add(tag);
when(artifactPluginInfo.getArtifactConfigSettings()).thenReturn(new PluggableInstanceSettings(pluginMetadata));
ArtifactMetadataStore.instance().setPluginInfo(artifactPluginInfo);
HashMap<Object, Object> configurationMap1 = new HashMap<>();
configurationMap1.put("Image", "gocd/gocd-server");
configurationMap1.put("Tag", "v18.6.0");
HashMap<String, Object> artifactPlan1 = new HashMap<>();
artifactPlan1.put("artifactTypeValue", "Pluggable Artifact");
artifactPlan1.put("id", "artifactId");
artifactPlan1.put("storeId", "storeId");
artifactPlan1.put("pluginId", "cd.go.artifact.foo");
artifactPlan1.put("configuration", configurationMap1);
List<Map> artifactPlansList = new ArrayList<>();
artifactPlansList.add(artifactPlan1);
ArtifactTypeConfigs artifactTypeConfigs = new ArtifactTypeConfigs();
artifactTypeConfigs.setConfigAttributes(artifactPlansList);
assertThat(artifactTypeConfigs.size(), is(1));
PluggableArtifactConfig artifactConfig = (PluggableArtifactConfig) artifactTypeConfigs.get(0);
assertThat(artifactConfig.getArtifactType(), is(ArtifactType.external));
assertThat(artifactConfig.getId(), is("artifactId"));
assertThat(artifactConfig.getStoreId(), is("storeId"));
assertThat(artifactConfig.getConfiguration().getProperty("Image").isSecure(), is(false));
}
use of com.thoughtworks.go.plugin.domain.common.Metadata in project gocd by gocd.
the class PluggableArtifactConfigTest method shouldIgnoreEncryptionOfSecurePropertyIfParamsIsUndefined.
@Test
public void shouldIgnoreEncryptionOfSecurePropertyIfParamsIsUndefined() {
GoCipher goCipher = new GoCipher();
ArrayList<PluginConfiguration> pluginConfigurations = new ArrayList<>();
pluginConfigurations.add(new PluginConfiguration("key1", new Metadata(true, true)));
pluginConfigurations.add(new PluginConfiguration("key2", new Metadata(true, false)));
when(artifactPluginInfo.getArtifactConfigSettings()).thenReturn(new PluggableInstanceSettings(pluginConfigurations));
ConfigurationProperty secureProperty1 = new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1"), null, goCipher);
ConfigurationProperty secureProperty2 = new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1"), null, goCipher);
ConfigurationProperty nonSecureProperty1 = new ConfigurationProperty(new ConfigurationKey("key2"), new ConfigurationValue("value2"), null, goCipher);
ConfigurationProperty nonSecureProperty2 = new ConfigurationProperty(new ConfigurationKey("key2"), new ConfigurationValue("value2"), null, goCipher);
PluggableArtifactConfig pluggableArtifactConfig1 = new PluggableArtifactConfig("id", "#{storeId}", secureProperty1, nonSecureProperty1);
PluggableArtifactConfig pluggableArtifactConfig2 = new PluggableArtifactConfig("id", "#{storeId}", secureProperty2, nonSecureProperty2);
BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
cruiseConfig.getArtifactStores().add(new ArtifactStore("store-id", "cd.go.s3"));
pluggableArtifactConfig1.encryptSecureProperties(cruiseConfig, pluggableArtifactConfig1);
pluggableArtifactConfig2.encryptSecureProperties(cruiseConfig, pluggableArtifactConfig2);
assertThat(secureProperty1.isSecure(), is(false));
assertThat(secureProperty1.getValue(), is("value1"));
assertThat(nonSecureProperty1.isSecure(), is(false));
assertThat(nonSecureProperty1.getValue(), is("value2"));
assertThat(secureProperty2.isSecure(), is(false));
assertThat(secureProperty2.getValue(), is("value1"));
assertThat(nonSecureProperty2.isSecure(), is(false));
assertThat(nonSecureProperty2.getValue(), is("value2"));
}
Aggregations