Search in sources :

Example 1 with PluginSettingsProperty

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(""));
}
Also used : PluginSettingsConfiguration(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration) PluginSettingsProperty(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty) Test(org.junit.Test)

Example 2 with PluginSettingsProperty

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)));
}
Also used : AnalyticsPluginInfo(com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginSettingsConfiguration(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration) PluginSettingsProperty(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty) Test(org.junit.jupiter.api.Test)

Example 3 with PluginSettingsProperty

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);
}
Also used : PackageMaterialProperty(com.thoughtworks.go.plugin.api.material.packagerepository.PackageMaterialProperty) PluginSettingsConfiguration(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration) PluginSettingsProperty(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with PluginSettingsProperty

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());
}
Also used : ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginSettingsConfiguration(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration) PluginSettingsProperty(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty) Test(org.junit.jupiter.api.Test)

Example 5 with PluginSettingsProperty

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");
}
Also used : PluginSettingsConfiguration(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration) PluginSettingsProperty(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

PluginSettingsConfiguration (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration)11 PluginSettingsProperty (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty)11 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)5 Test (org.junit.jupiter.api.Test)5 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 PackageMaterialProperty (com.thoughtworks.go.plugin.api.material.packagerepository.PackageMaterialProperty)1 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)1 AnalyticsPluginInfo (com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo)1 Test (org.junit.Test)1