Search in sources :

Example 86 with GoPluginDescriptor

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

the class PluginSettingsMetadataLoaderTest method shouldNotFetchPluginSettingsMetadataForTaskPlugin.

@Test
public void shouldNotFetchPluginSettingsMetadataForTaskPlugin() throws Exception {
    PluginSettingsConfiguration configuration = new PluginSettingsConfiguration();
    configuration.add(new PluginSettingsProperty("k1").with(Property.REQUIRED, true).with(Property.SECURE, false));
    GoPluginDescriptor pluginDescriptor = new GoPluginDescriptor(UUID.randomUUID().toString(), "1.0", null, null, null, true);
    setupSettingsResponses(taskExtension, pluginDescriptor.id(), configuration, "template");
    metadataLoader.fetchPluginSettingsMetaData(pluginDescriptor);
    verify(taskExtension, never()).getPluginSettingsConfiguration(pluginDescriptor.id());
    verify(taskExtension, never()).getPluginSettingsView(pluginDescriptor.id());
    assertThat(PluginSettingsMetadataStore.getInstance().configuration(pluginDescriptor.id()), is(nullValue()));
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 87 with GoPluginDescriptor

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

the class PluginSettingsMetadataLoaderTest method shouldNotStoreMetadataIfConfigurationIsMissing.

@Test
public void shouldNotStoreMetadataIfConfigurationIsMissing() {
    PluginSettingsConfiguration configuration = new PluginSettingsConfiguration();
    configuration.add(new PluginSettingsProperty("k1").with(Property.REQUIRED, true).with(Property.SECURE, false));
    GoPluginDescriptor pluginDescriptor = new GoPluginDescriptor("plugin-id", "1.0", null, null, null, true);
    setupSettingsResponses(packageRepositoryExtension, pluginDescriptor.id(), null, "template");
    metadataLoader.fetchPluginSettingsMetaData(pluginDescriptor);
    assertThat(PluginSettingsMetadataStore.getInstance().hasPlugin(pluginDescriptor.id()), is(false));
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Example 88 with GoPluginDescriptor

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

the class PluginServiceTest method shouldGetPluginInfoFromTheExtensionWhichImplementsPluginSettingsIfThePluginImplementsMultipleExtensions.

@Test
public void shouldGetPluginInfoFromTheExtensionWhichImplementsPluginSettingsIfThePluginImplementsMultipleExtensions() {
    String pluginId = "plugin-id-1";
    CombinedPluginInfo combinedPluginInfo = new CombinedPluginInfo();
    PluggableInstanceSettings pluginSettings = new PluggableInstanceSettings(Arrays.asList(new PluginConfiguration("key", new Metadata(false, false))));
    GoPluginDescriptor pluginDescriptor = new GoPluginDescriptor(pluginId, "1", null, "location", new File(""), false);
    NotificationPluginInfo notificationPluginInfo = new NotificationPluginInfo(pluginDescriptor, null);
    combinedPluginInfo.add(notificationPluginInfo);
    SCMPluginInfo scmPluginInfo = new SCMPluginInfo(pluginDescriptor, "display_name", new PluggableInstanceSettings(null), pluginSettings);
    combinedPluginInfo.add(scmPluginInfo);
    PluginSettingsMetadataStore.getInstance().addMetadataFor(pluginId, PluginConstants.SCM_EXTENSION, new PluginSettingsConfiguration(), "template-1");
    when(defaultPluginInfoFinder.pluginInfoFor(pluginId)).thenReturn(combinedPluginInfo);
    when(notificationExtension.canHandlePlugin(pluginId)).thenReturn(true);
    when(scmExtension.canHandlePlugin(pluginId)).thenReturn(true);
    PluginInfo pluginInfo = pluginService.pluginInfoForExtensionThatHandlesPluginSettings(pluginId);
    assertTrue(pluginInfo instanceof SCMPluginInfo);
    assertThat(pluginInfo, is(scmPluginInfo));
}
Also used : SCMPluginInfo(com.thoughtworks.go.plugin.domain.scm.SCMPluginInfo) NotificationPluginInfo(com.thoughtworks.go.plugin.domain.notification.NotificationPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) SCMPluginInfo(com.thoughtworks.go.plugin.domain.scm.SCMPluginInfo) NotificationPluginInfo(com.thoughtworks.go.plugin.domain.notification.NotificationPluginInfo) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) PluginSettingsConfiguration(com.thoughtworks.go.plugin.access.common.settings.PluginSettingsConfiguration) File(java.io.File) Test(org.junit.Test)

Example 89 with GoPluginDescriptor

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

the class SecurityAuthConfigServiceTest method pluginInfo.

private AuthorizationPluginInfo pluginInfo(String githubPluginId, String name, SupportedAuthType supportedAuthType) {
    GoPluginDescriptor.About about = new GoPluginDescriptor.About(name, "1.0", null, null, null, null);
    GoPluginDescriptor descriptor = new GoPluginDescriptor(githubPluginId, "1.0", about, null, null, false);
    return new AuthorizationPluginInfo(descriptor, null, null, new Image("svg", "data", "hash"), new Capabilities(supportedAuthType, true, true));
}
Also used : Capabilities(com.thoughtworks.go.plugin.domain.authorization.Capabilities) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Image(com.thoughtworks.go.plugin.domain.common.Image)

Example 90 with GoPluginDescriptor

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

the class ElasticAgentPluginServiceTest method shouldErrorOutWhenPluginDoesNotAgentSupportStatusReport.

@Test
public void shouldErrorOutWhenPluginDoesNotAgentSupportStatusReport() {
    final Capabilities capabilities = new Capabilities(true, false);
    final GoPluginDescriptor descriptor = new GoPluginDescriptor("cd.go.example.plugin", null, null, null, null, false);
    elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, capabilities));
    thrown.expect(UnsupportedOperationException.class);
    thrown.expectMessage("Plugin does not support agent status report.");
    service.getAgentStatusReport("cd.go.example.plugin", null, null);
}
Also used : ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) Capabilities(com.thoughtworks.go.plugin.domain.elastic.Capabilities) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) Test(org.junit.Test)

Aggregations

GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)197 Test (org.junit.Test)155 File (java.io.File)17 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)16 TinyBundle (org.ops4j.pax.tinybundles.core.TinyBundle)15 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)14 Before (org.junit.Before)14 AnalyticsPluginInfo (com.thoughtworks.go.plugin.domain.analytics.AnalyticsPluginInfo)12 AuthorizationPluginInfo (com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)12 ElasticAgentPluginInfo (com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo)11 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)11 GoPlugin (com.thoughtworks.go.plugin.api.GoPlugin)10 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)9 PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)9 InvocationOnMock (org.mockito.invocation.InvocationOnMock)9 Answer (org.mockito.stubbing.Answer)9 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)8 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)8 ArrayList (java.util.ArrayList)8 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)7