use of com.thoughtworks.go.plugin.domain.configrepo.Capabilities 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.Capabilities 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.Capabilities in project gocd by gocd.
the class ConfigRepoExtensionTest method shouldRequestCapabilitiesV1.
@Test
public void shouldRequestCapabilitiesV1() {
Capabilities capabilities = new Capabilities(false, false, false, false);
Capabilities res = extension.getCapabilities(PLUGIN_ID);
assertThat(capabilities, is(res));
}
use of com.thoughtworks.go.plugin.domain.configrepo.Capabilities in project gocd by gocd.
the class ConfigRepoExtensionTest method shouldRequestCapabilities.
@Test
public void shouldRequestCapabilities() {
Capabilities capabilities = new Capabilities(true, true, false, false);
when(jsonMessageHandler2.getCapabilitiesFromResponse(responseBody)).thenReturn(capabilities);
when(pluginManager.resolveExtensionVersion(PLUGIN_ID, CONFIG_REPO_EXTENSION, new ArrayList<>(Arrays.asList("1.0", "2.0", "3.0")))).thenReturn("2.0");
Capabilities res = extension.getCapabilities(PLUGIN_ID);
assertRequest(requestArgumentCaptor.getValue(), CONFIG_REPO_EXTENSION, "2.0", ConfigRepoExtension.REQUEST_CAPABILITIES, null);
assertSame(capabilities, res);
}
use of com.thoughtworks.go.plugin.domain.configrepo.Capabilities 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