use of com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings in project gocd by gocd.
the class PluginSettings method getSecurePluginSettingsProperties.
public List<ConfigurationProperty> getSecurePluginSettingsProperties(PluginInfo pluginInfo) {
ArrayList<ConfigurationProperty> configurationProperties = new ArrayList<>();
if (pluginInfo != null) {
ConfigurationPropertyBuilder builder = new ConfigurationPropertyBuilder();
PluggableInstanceSettings pluginSettings = pluginInfo.getPluginSettings();
for (ConfigurationProperty configurationProperty : settingsMap) {
PluginConfiguration pluginConfiguration = configPropertyFor(configurationProperty.getConfigKeyName(), pluginSettings);
if (pluginConfiguration != null && pluginConfiguration.isSecure()) {
configurationProperties.add(builder.create(configurationProperty.getConfigKeyName(), configurationProperty.getConfigValue(), configurationProperty.getEncryptedValue(), true));
} else {
configurationProperties.add(configurationProperty);
}
}
}
return configurationProperties;
}
use of com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings in project gocd by gocd.
the class PluggableTaskPluginInfoBuilderTest method shouldBuildPluginInfo.
@Test
public void shouldBuildPluginInfo() throws Exception {
GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false);
PluggableTaskPluginInfo pluginInfo = new PluggableTaskPluginInfoBuilder(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("task"));
assertThat(pluginInfo.getDisplayName(), is("my task plugin"));
assertThat(pluginInfo.getTaskSettings(), is(new PluggableInstanceSettings(pluginConfigurations, pluginView)));
assertNull(pluginInfo.getPluginSettings());
}
use of com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings in project gocd by gocd.
the class AnalyticsPluginInfoBuilder method pluginInfoFor.
public AnalyticsPluginInfo pluginInfoFor(GoPluginDescriptor descriptor) {
Capabilities capabilities = capabilities(descriptor.id());
PluggableInstanceSettings pluginSettingsAndView = getPluginSettingsAndView(descriptor, extension);
Image image = image(descriptor.id());
return new AnalyticsPluginInfo(descriptor, image, capabilities, pluginSettingsAndView);
}
use of com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings in project gocd by gocd.
the class PluginSettingsTest method shouldEncryptedValuesForSecureProperties.
@Test
public void shouldEncryptedValuesForSecureProperties() throws InvalidCipherTextException {
ArrayList<PluginConfiguration> pluginConfigurations = new ArrayList<>();
pluginConfigurations.add(new PluginConfiguration("k1", new Metadata(true, false)));
pluginConfigurations.add(new PluginConfiguration("k2", new Metadata(true, true)));
ConfigRepoPluginInfo pluginInfo = new ConfigRepoPluginInfo(null, new PluggableInstanceSettings(pluginConfigurations));
ConfigurationProperty configProperty1 = new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("v1"));
ConfigurationProperty configProperty2 = new ConfigurationProperty(new ConfigurationKey("k2"), new EncryptedConfigurationValue(new GoCipher().encrypt("v2")));
ArrayList<ConfigurationProperty> configurationProperties = new ArrayList<>();
configurationProperties.add(configProperty1);
configurationProperties.add(configProperty2);
PluginSettings pluginSettings = new PluginSettings(PLUGIN_ID);
pluginSettings.addConfigurations(pluginInfo, configurationProperties);
List<ConfigurationProperty> pluginSettingsProperties = pluginSettings.getSecurePluginSettingsProperties(pluginInfo);
assertThat(pluginSettingsProperties.size(), is(2));
assertThat(pluginSettingsProperties.get(0), is(configProperty1));
assertThat(pluginSettingsProperties.get(1), is(configProperty2));
}
use of com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings in project gocd by gocd.
the class PluginSettingsTest method shouldAddConfigurationsToSettingsMapCorrectly.
@Test
public void shouldAddConfigurationsToSettingsMapCorrectly() throws InvalidCipherTextException {
ArrayList<PluginConfiguration> pluginConfigurations = new ArrayList<>();
pluginConfigurations.add(new PluginConfiguration("k1", new Metadata(true, false)));
pluginConfigurations.add(new PluginConfiguration("k2", new Metadata(true, true)));
ConfigRepoPluginInfo pluginInfo = new ConfigRepoPluginInfo(null, new PluggableInstanceSettings(pluginConfigurations));
ArrayList<ConfigurationProperty> configurationProperties = new ArrayList<>();
configurationProperties.add(new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("v1")));
configurationProperties.add(new ConfigurationProperty(new ConfigurationKey("k2"), new EncryptedConfigurationValue(new GoCipher().encrypt("v2"))));
PluginSettings pluginSettings = new PluginSettings(PLUGIN_ID);
pluginSettings.addConfigurations(pluginInfo, configurationProperties);
PluginSettingsConfiguration pluginSettingsProperties = pluginSettings.toPluginSettingsConfiguration();
assertThat(pluginSettingsProperties.size(), is(2));
assertThat(pluginSettingsProperties.get("k1").getValue(), is("v1"));
assertThat(pluginSettingsProperties.get("k2").getValue(), is("v2"));
}
Aggregations