Search in sources :

Example 6 with PluginSettingsProperty

use of com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty in project gocd by gocd.

the class ConfigRepoPluginInfoBuilderTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    extension = mock(ConfigRepoExtension.class);
    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);
}
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)

Example 7 with PluginSettingsProperty

use of com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty in project gocd by gocd.

the class ElasticAgentPluginInfoBuilderTest method shouldFetchPluginSettingsForPluginsNotSupportingClusterProfiles.

@Test
public void shouldFetchPluginSettingsForPluginsNotSupportingClusterProfiles() {
    GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
    PluginSettingsConfiguration pluginSettingsConfiguration = new PluginSettingsConfiguration();
    pluginSettingsConfiguration.add(new PluginSettingsProperty("ami-id", "ami-123"));
    when(extension.getPluginSettingsConfiguration(descriptor.id())).thenReturn(pluginSettingsConfiguration);
    when(extension.getPluginSettingsView(descriptor.id())).thenReturn("some html");
    when(extension.supportsClusterProfiles("plugin1")).thenReturn(false);
    ElasticAgentPluginInfoBuilder builder = new ElasticAgentPluginInfoBuilder(extension);
    ElasticAgentPluginInfo pluginInfo = builder.pluginInfoFor(descriptor);
    assertThat(pluginInfo.getPluginSettings(), is(new PluggableInstanceSettings(builder.configurations(pluginSettingsConfiguration), new PluginView("some html"))));
}
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 8 with PluginSettingsProperty

use of com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty in project gocd by gocd.

the class ElasticAgentPluginInfoBuilderTest method shouldBuildPluginInfoWithProfileSettings.

@Test
public void shouldBuildPluginInfoWithProfileSettings() {
    GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
    List<PluginConfiguration> pluginConfigurations = List.of(new PluginConfiguration("aws_password", 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.getProfileMetadata(descriptor.id())).thenReturn(pluginConfigurations);
    when(extension.getProfileView(descriptor.id())).thenReturn("profile_view");
    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(pluginConfigurations, new PluginView("profile_view"))));
    assertThat(pluginInfo.getPluginSettings(), is(new PluggableInstanceSettings(builder.configurations(pluginSettingsConfiguration), new PluginView("some html"))));
    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 9 with PluginSettingsProperty

use of com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty in project gocd by gocd.

the class ElasticAgentPluginInfoBuilderTest method shouldBuildPluginInfoWithoutClusterProfileSettingsForPluginsImplementedUsingv4Extension.

@Test
public void shouldBuildPluginInfoWithoutClusterProfileSettingsForPluginsImplementedUsingv4Extension() {
    GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
    List<PluginConfiguration> elasticAgentProfileConfigurations = Arrays.asList(new PluginConfiguration("aws_password", 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.getProfileMetadata(descriptor.id())).thenReturn(elasticAgentProfileConfigurations);
    when(extension.getProfileView(descriptor.id())).thenReturn("elastic_agent_profile_view");
    when(extension.supportsClusterProfiles("plugin1")).thenReturn(false);
    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(null, null)));
    assertThat(pluginInfo.getPluginSettings(), is(new PluggableInstanceSettings(builder.configurations(pluginSettingsConfiguration), new PluginView("some html"))));
    assertFalse(pluginInfo.supportsStatusReport());
    verify(extension, never()).getClusterProfileMetadata(any());
    verify(extension, never()).getClusterProfileView(any());
}
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 10 with PluginSettingsProperty

use of com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty in project gocd by gocd.

the class NotificationPluginInfoBuilderTest method setUp.

@BeforeEach
public void setUp() {
    extension = mock(NotificationExtension.class);
    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");
}
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