use of com.thoughtworks.go.plugin.domain.configrepo.ConfigRepoPluginInfo in project gocd by gocd.
the class PluginSettingsTest method shouldAddConfigurationsToSettingsMapCorrectly.
@Test
public void shouldAddConfigurationsToSettingsMapCorrectly() throws CryptoException {
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, null, new PluggableInstanceSettings(pluginConfigurations), new Capabilities());
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"));
}
use of com.thoughtworks.go.plugin.domain.configrepo.ConfigRepoPluginInfo in project gocd by gocd.
the class PluginSettingsTest method shouldEncryptedValuesForSecureProperties.
@Test
public void shouldEncryptedValuesForSecureProperties() throws CryptoException {
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, null, new PluggableInstanceSettings(pluginConfigurations), new Capabilities());
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.getPluginSettingsProperties();
assertThat(pluginSettingsProperties.size(), is(2));
assertThat(pluginSettingsProperties.get(0), is(configProperty1));
assertThat(pluginSettingsProperties.get(1), is(configProperty2));
}
use of com.thoughtworks.go.plugin.domain.configrepo.ConfigRepoPluginInfo in project gocd by gocd.
the class ConfigRepoExtensionRepresenter method toJSON.
@Override
public void toJSON(OutputWriter extensionWriter, PluginInfo extension) {
super.toJSON(extensionWriter, extension);
ConfigRepoPluginInfo configRepoPluginInfo = (ConfigRepoPluginInfo) extension;
extensionWriter.addChild("capabilities", capabilitiesWriter -> capabilitiesWriter.add("supports_pipeline_export", configRepoPluginInfo.getCapabilities().isSupportsPipelineExport()).add("supports_parse_content", configRepoPluginInfo.getCapabilities().isSupportsParseContent()).add("supports_list_config_files", configRepoPluginInfo.getCapabilities().isSupportsListConfigFiles()).add("supports_user_defined_properties", configRepoPluginInfo.getCapabilities().isSupportsUserDefinedProperties()));
}
use of com.thoughtworks.go.plugin.domain.configrepo.ConfigRepoPluginInfo in project gocd by gocd.
the class ConfigRepoPluginInfoBuilderTest method shouldContinueWithBuildingPluginInfoIfPluginSettingsIsNotProvidedByPlugin.
@Test
public void shouldContinueWithBuildingPluginInfoIfPluginSettingsIsNotProvidedByPlugin() throws Exception {
GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
doThrow(new RuntimeException("foo")).when(extension).getPluginSettingsConfiguration("plugin1");
ConfigRepoPluginInfo pluginInfo = new ConfigRepoPluginInfoBuilder(extension).pluginInfoFor(descriptor);
assertThat(pluginInfo.getDescriptor(), is(descriptor));
assertThat(pluginInfo.getExtensionName(), is("configrepo"));
assertNull(pluginInfo.getPluginSettings());
}
use of com.thoughtworks.go.plugin.domain.configrepo.ConfigRepoPluginInfo in project gocd by gocd.
the class ConfigRepoPluginInfoBuilderTest method shouldBuildPluginInfo.
@Test
public void shouldBuildPluginInfo() throws Exception {
GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
when(extension.getPluginSettingsView("plugin1")).thenReturn("some-html");
when(extension.getCapabilities("plugin1")).thenReturn(new Capabilities(true, true, true, true));
ConfigRepoPluginInfo pluginInfo = new ConfigRepoPluginInfoBuilder(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("configrepo"));
assertThat(pluginInfo.getPluginSettings(), is(new PluggableInstanceSettings(pluginConfigurations, pluginView)));
assertThat(pluginInfo.getCapabilities(), is(new Capabilities(true, true, true, true)));
}
Aggregations