Search in sources :

Example 41 with GoPluginDescriptor

use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.

the class TaskViewServiceTest method shouldFetchPluggableTasksWithSecureConfigurations.

@Test
public void shouldFetchPluggableTasksWithSecureConfigurations() throws Exception {
    String plugin = "task-plugin";
    when(pluginManager.getPluginDescriptorFor(plugin)).thenReturn(new GoPluginDescriptor(plugin, "1", null, null, null, false));
    Property taskConfigProperty = new TaskConfigProperty("key1", null).with(Property.SECURE, true);
    storeTaskPreferences(plugin, taskConfigProperty);
    when(registry.implementersOf(Task.class)).thenReturn(Arrays.<Class<? extends Task>>asList(PluggableTask.class));
    PluggableTask pluggableTask = (PluggableTask) taskViewService.taskInstanceFor(new PluggableTask(new PluginConfiguration(plugin, "1"), null).getTaskType());
    assertTrue(pluggableTask.getConfiguration().first().isSecure());
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) TaskConfigProperty(com.thoughtworks.go.plugin.api.task.TaskConfigProperty) TaskConfigProperty(com.thoughtworks.go.plugin.api.task.TaskConfigProperty) Property(com.thoughtworks.go.plugin.api.config.Property) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) Test(org.junit.Test)

Example 42 with GoPluginDescriptor

use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.

the class ArtifactPluginInfoBuilderTest method shouldBuildPluginInfoWithFetchArtifactConfigSettings.

@Test
public void shouldBuildPluginInfoWithFetchArtifactConfigSettings() {
    GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
    List<PluginConfiguration> pluginConfigurations = Arrays.asList(new PluginConfiguration("FILENAME", new Metadata(true, false)), new PluginConfiguration("SECURE", new Metadata(true, true)));
    when(extension.getFetchArtifactMetadata(descriptor.id())).thenReturn(pluginConfigurations);
    when(extension.getFetchArtifactView(descriptor.id())).thenReturn("fetch_artifact_view");
    ArtifactPluginInfo pluginInfo = new ArtifactPluginInfoBuilder(extension).pluginInfoFor(descriptor);
    assertThat(pluginInfo.getFetchArtifactSettings(), is(new PluggableInstanceSettings(pluginConfigurations, new PluginView("fetch_artifact_view"))));
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) ArtifactPluginInfo(com.thoughtworks.go.plugin.domain.artifact.ArtifactPluginInfo) Test(org.junit.jupiter.api.Test)

Example 43 with GoPluginDescriptor

use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.

the class ArtifactPluginInfoBuilderTest method shouldContinueWithBuildingPluginInfoIfPluginSettingsIsNotProvidedByPlugin.

@Test
public void shouldContinueWithBuildingPluginInfoIfPluginSettingsIsNotProvidedByPlugin() {
    GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
    doThrow(new RuntimeException("foo")).when(extension).getPluginSettingsConfiguration("plugin1");
    ArtifactPluginInfo artifactPluginInfo = new ArtifactPluginInfoBuilder(extension).pluginInfoFor(descriptor);
    assertThat(artifactPluginInfo.getDescriptor(), is(descriptor));
    assertThat(artifactPluginInfo.getExtensionName(), is(PluginConstants.ARTIFACT_EXTENSION));
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) ArtifactPluginInfo(com.thoughtworks.go.plugin.domain.artifact.ArtifactPluginInfo) Test(org.junit.jupiter.api.Test)

Example 44 with GoPluginDescriptor

use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.

the class ArtifactPluginInfoBuilderTest method shouldBuildPluginInfoWithStoreSettings.

@Test
public void shouldBuildPluginInfoWithStoreSettings() {
    GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
    List<PluginConfiguration> pluginConfigurations = Arrays.asList(new PluginConfiguration("S3_BUCKET", new Metadata(true, false)), new PluginConfiguration("AWS_ACCESS_KEY_ID", new Metadata(true, true)));
    when(extension.getArtifactStoreMetadata(descriptor.id())).thenReturn(pluginConfigurations);
    when(extension.getArtifactStoreView(descriptor.id())).thenReturn("store_config");
    ArtifactPluginInfo pluginInfo = new ArtifactPluginInfoBuilder(extension).pluginInfoFor(descriptor);
    assertThat(pluginInfo.getStoreConfigSettings(), is(new PluggableInstanceSettings(pluginConfigurations, new PluginView("store_config"))));
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) ArtifactPluginInfo(com.thoughtworks.go.plugin.domain.artifact.ArtifactPluginInfo) Test(org.junit.jupiter.api.Test)

Example 45 with GoPluginDescriptor

use of com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor in project gocd by gocd.

the class AuthorizationMetadataLoaderTest method onPluginLoaded_shouldAddPluginInfoToMetadataStore.

@Test
public void onPluginLoaded_shouldAddPluginInfoToMetadataStore() throws Exception {
    GoPluginDescriptor descriptor = GoPluginDescriptor.builder().id("plugin1").build();
    AuthorizationMetadataLoader metadataLoader = new AuthorizationMetadataLoader(pluginManager, metadataStore, infoBuilder, extension);
    AuthorizationPluginInfo pluginInfo = new AuthorizationPluginInfo(descriptor, null, null, null, null);
    when(extension.canHandlePlugin(descriptor.id())).thenReturn(true);
    when(infoBuilder.pluginInfoFor(descriptor)).thenReturn(pluginInfo);
    metadataLoader.pluginLoaded(descriptor);
    verify(metadataStore).setPluginInfo(pluginInfo);
}
Also used : AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)214 Test (org.junit.jupiter.api.Test)114 Test (org.junit.Test)53 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)20 File (java.io.File)19 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)16 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)14 AuthorizationPluginInfo (com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)12 Capabilities (com.thoughtworks.go.plugin.domain.elastic.Capabilities)12 Before (org.junit.Before)12 AnalyticsPluginInfo (com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo)11 GoPluginBundleDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginBundleDescriptor)11 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)11 Bundle (org.osgi.framework.Bundle)10 GoPlugin (com.thoughtworks.go.plugin.api.GoPlugin)9 PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)9 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)8 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)8 ArrayList (java.util.ArrayList)8 InvocationOnMock (org.mockito.invocation.InvocationOnMock)8