use of com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty in project gocd by gocd.
the class PluginSettingsTest method shouldPopulateSettingsMapFromPluginFromConfiguration.
@Test
public void shouldPopulateSettingsMapFromPluginFromConfiguration() {
PluginSettingsConfiguration configuration = new PluginSettingsConfiguration();
configuration.add(new PluginSettingsProperty("k1", "v1"));
configuration.add(new PluginSettingsProperty("k2", ""));
configuration.add(new PluginSettingsProperty("k3", null));
PluginSettings pluginSettings = new PluginSettings(PLUGIN_ID);
pluginSettings.populateSettingsMap(configuration);
assertThat(pluginSettings.getValueFor("k1"), is(""));
assertThat(pluginSettings.getValueFor("k2"), is(""));
assertThat(pluginSettings.getValueFor("k3"), is(""));
}
use of com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty in project gocd by gocd.
the class AnalyticsPluginInfoBuilderTest method shouldBuildPluginInfoWithPluginSettingsConfiguration.
@Test
public void shouldBuildPluginInfoWithPluginSettingsConfiguration() {
GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
PluginSettingsConfiguration value = new PluginSettingsConfiguration();
value.add(new PluginSettingsProperty("username", null).with(Property.REQUIRED, true).with(Property.SECURE, false));
value.add(new PluginSettingsProperty("password", null).with(Property.REQUIRED, true).with(Property.SECURE, true));
when(extension.getPluginSettingsConfiguration("plugin1")).thenReturn(value);
when(extension.getPluginSettingsView("plugin1")).thenReturn("some-html");
AnalyticsPluginInfo pluginInfo = new AnalyticsPluginInfoBuilder(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("analytics"));
assertThat(pluginInfo.getPluginSettings(), is(new PluggableInstanceSettings(pluginConfigurations, pluginView)));
}
use of com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty in project gocd by gocd.
the class PackageMaterialPluginInfoBuilderTest method setUp.
@BeforeEach
public void setUp() throws Exception {
extension = mock(PackageRepositoryExtension.class);
com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration packageSettings = new com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration();
packageSettings.add(new PackageMaterialProperty("username", null).with(Property.REQUIRED, true).with(Property.SECURE, false).with(Property.PART_OF_IDENTITY, false).with(Property.DISPLAY_NAME, "foo").with(Property.DISPLAY_ORDER, 1));
packageSettings.add(new PackageMaterialProperty("password", null).with(Property.REQUIRED, true).with(Property.SECURE, true).with(Property.DISPLAY_ORDER, 2));
RepositoryConfiguration repoSettings = new RepositoryConfiguration();
repoSettings.add(new PackageMaterialProperty("foo", null).with(Property.REQUIRED, true).with(Property.SECURE, false).with(Property.DISPLAY_ORDER, 1));
repoSettings.add(new PackageMaterialProperty("bar", null).with(Property.REQUIRED, true).with(Property.SECURE, true).with(Property.DISPLAY_ORDER, 2));
when(extension.getPackageConfiguration("plugin1")).thenReturn(packageSettings);
when(extension.getRepositoryConfiguration("plugin1")).thenReturn(repoSettings);
when(extension.getPluginSettingsView("plugin1")).thenReturn("some-html");
PluginSettingsConfiguration pluginSettingsConfiguration = new PluginSettingsConfiguration();
pluginSettingsConfiguration.add(new PluginSettingsProperty("k1", null).with(Property.REQUIRED, true).with(Property.SECURE, false).with(Property.DISPLAY_ORDER, 3));
when(extension.getPluginSettingsConfiguration("plugin1")).thenReturn(pluginSettingsConfiguration);
}
use of com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty in project gocd by gocd.
the class ElasticAgentPluginInfoBuilderTest method shouldBuildPluginInfoWithClusterProfileSettings.
@Test
public void shouldBuildPluginInfoWithClusterProfileSettings() {
GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
List<PluginConfiguration> elasticAgentProfileConfigurations = Arrays.asList(new PluginConfiguration("aws_password", new Metadata(true, false)));
List<PluginConfiguration> clusterProfileConfigurations = Arrays.asList(new PluginConfiguration("aws_url", new Metadata(true, false)));
PluginSettingsProperty property = new PluginSettingsProperty("ami-id", "ami-123");
PluginSettingsConfiguration pluginSettingsConfiguration = new PluginSettingsConfiguration();
pluginSettingsConfiguration.add(property);
Image icon = new Image("content_type", "data", "hash");
when(pluginManager.resolveExtensionVersion("plugin1", ELASTIC_AGENT_EXTENSION, SUPPORTED_VERSIONS)).thenReturn("1.0");
when(extension.getPluginSettingsConfiguration(descriptor.id())).thenReturn(pluginSettingsConfiguration);
when(extension.getPluginSettingsView(descriptor.id())).thenReturn("some html");
when(extension.getIcon(descriptor.id())).thenReturn(icon);
when(extension.getClusterProfileMetadata(descriptor.id())).thenReturn(clusterProfileConfigurations);
when(extension.getClusterProfileView(descriptor.id())).thenReturn("cluster_profile_view");
when(extension.getProfileMetadata(descriptor.id())).thenReturn(elasticAgentProfileConfigurations);
when(extension.getProfileView(descriptor.id())).thenReturn("elastic_agent_profile_view");
when(extension.supportsClusterProfiles("plugin1")).thenReturn(true);
ElasticAgentPluginInfoBuilder builder = new ElasticAgentPluginInfoBuilder(extension);
ElasticAgentPluginInfo pluginInfo = builder.pluginInfoFor(descriptor);
assertThat(pluginInfo.getDescriptor(), is(descriptor));
assertThat(pluginInfo.getExtensionName(), is("elastic-agent"));
assertThat(pluginInfo.getImage(), is(icon));
assertThat(pluginInfo.getElasticAgentProfileSettings(), is(new PluggableInstanceSettings(elasticAgentProfileConfigurations, new PluginView("elastic_agent_profile_view"))));
assertThat(pluginInfo.getClusterProfileSettings(), is(new PluggableInstanceSettings(clusterProfileConfigurations, new PluginView("cluster_profile_view"))));
assertNull(pluginInfo.getPluginSettings());
assertFalse(pluginInfo.supportsStatusReport());
}
use of com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty in project gocd by gocd.
the class SCMPluginInfoBuilderTest method setUp.
@BeforeEach
public void setUp() throws Exception {
extension = mock(SCMExtension.class);
SCMPropertyConfiguration value = new SCMPropertyConfiguration();
value.add(new SCMProperty("username", null).with(Property.REQUIRED, true).with(Property.SECURE, false).with(Property.PART_OF_IDENTITY, true).with(Property.DISPLAY_ORDER, 1));
value.add(new SCMProperty("password", null).with(Property.REQUIRED, true).with(Property.SECURE, true).with(Property.PART_OF_IDENTITY, false).with(Property.DISPLAY_ORDER, 2));
when(extension.getSCMConfiguration("plugin1")).thenReturn(value);
when(extension.getSCMView("plugin1")).thenReturn(new SCMView() {
@Override
public String displayValue() {
return "some scm plugin";
}
@Override
public String template() {
return "some html";
}
});
PluginSettingsConfiguration pluginSettingsConfiguration = new PluginSettingsConfiguration();
pluginSettingsConfiguration.add(new PluginSettingsProperty("k1", null).with(Property.REQUIRED, true).with(Property.SECURE, false).with(Property.DISPLAY_ORDER, 3));
when(extension.getPluginSettingsConfiguration("plugin1")).thenReturn(pluginSettingsConfiguration);
when(extension.getPluginSettingsView("plugin1")).thenReturn("settings view");
}
Aggregations