Search in sources :

Example 1 with PluggableInstanceSettings

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;
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) ConfigurationPropertyBuilder(com.thoughtworks.go.config.builder.ConfigurationPropertyBuilder) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration)

Example 2 with PluggableInstanceSettings

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());
}
Also used : PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluggableTaskPluginInfo(com.thoughtworks.go.plugin.domain.pluggabletask.PluggableTaskPluginInfo) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) PluginView(com.thoughtworks.go.plugin.domain.common.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 3 with PluggableInstanceSettings

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);
}
Also used : AnalyticsPluginInfo(com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) Capabilities(com.thoughtworks.go.plugin.domain.analytics.Capabilities) Image(com.thoughtworks.go.plugin.domain.common.Image)

Example 4 with PluggableInstanceSettings

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));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) GoCipher(com.thoughtworks.go.security.GoCipher) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) EncryptedConfigurationValue(com.thoughtworks.go.domain.config.EncryptedConfigurationValue) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) EncryptedConfigurationValue(com.thoughtworks.go.domain.config.EncryptedConfigurationValue) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) ConfigRepoPluginInfo(com.thoughtworks.go.plugin.domain.configrepo.ConfigRepoPluginInfo) Test(org.junit.Test)

Example 5 with PluggableInstanceSettings

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"));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) GoCipher(com.thoughtworks.go.security.GoCipher) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) EncryptedConfigurationValue(com.thoughtworks.go.domain.config.EncryptedConfigurationValue) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) EncryptedConfigurationValue(com.thoughtworks.go.domain.config.EncryptedConfigurationValue) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) ConfigRepoPluginInfo(com.thoughtworks.go.plugin.domain.configrepo.ConfigRepoPluginInfo) PluginSettingsConfiguration(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration) Test(org.junit.Test)

Aggregations

PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)18 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)12 Test (org.junit.Test)12 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)10 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)10 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)9 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)9 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)8 PluginView (com.thoughtworks.go.plugin.domain.common.PluginView)5 AuthorizationPluginInfo (com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)4 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)4 ConfigRepoPluginInfo (com.thoughtworks.go.plugin.domain.configrepo.ConfigRepoPluginInfo)3 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)3 Image (com.thoughtworks.go.plugin.domain.common.Image)2 PluggableTaskPluginInfo (com.thoughtworks.go.plugin.domain.pluggabletask.PluggableTaskPluginInfo)2 GoCipher (com.thoughtworks.go.security.GoCipher)2 ArrayList (java.util.ArrayList)2 ConfigurationPropertyBuilder (com.thoughtworks.go.config.builder.ConfigurationPropertyBuilder)1 PluginSettingsConfiguration (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration)1 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)1