Search in sources :

Example 26 with GoPluginDescriptor

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

the class AuthorizationPluginInfoBuilderTest method allPluginInfos_ShouldReturnAListOfAllPluginInfos.

@Test
public void allPluginInfos_ShouldReturnAListOfAllPluginInfos() throws Exception {
    GoPluginDescriptor.About about = new GoPluginDescriptor.About("Plugin Descriptor Validator", "1.0.1", "12.4", "Validates its own plugin descriptor", new GoPluginDescriptor.Vendor("ThoughtWorks Go Team", "www.thoughtworks.com"), Arrays.asList("Linux", "Windows", "Mac OS X"));
    GoPluginDescriptor plugin = new GoPluginDescriptor("docker-plugin", "1.0", about, null, null, false);
    PluginProfileMetadataKeys securityAuthConfigMetadata = new PluginProfileMetadataKeys(Arrays.asList(new PluginProfileMetadataKey("password", new PluginProfileMetadata(true, true))));
    PluginProfileMetadataKeys roleConfigMetadata = new PluginProfileMetadataKeys(Arrays.asList(new PluginProfileMetadataKey("memberOf", new PluginProfileMetadata(true, false))));
    Image image = new Image("image/png", Base64.getEncoder().encodeToString("some-base64-encoded-data".getBytes(UTF_8)));
    String securityAuthConfigView = "some html view";
    String roleConfigView = "another html view";
    AuthorizationPluginConfigMetadataStore store = mock(AuthorizationPluginConfigMetadataStore.class);
    when(store.getPlugins()).thenReturn(Arrays.asList(plugin));
    when(store.find("docker-plugin")).thenReturn(plugin);
    when(store.getProfileMetadata(plugin)).thenReturn(securityAuthConfigMetadata);
    when(store.getRoleMetadata(plugin)).thenReturn(roleConfigMetadata);
    when(store.getIcon(plugin)).thenReturn(image);
    when(store.getProfileView(plugin)).thenReturn(securityAuthConfigView);
    when(store.getRoleView(plugin)).thenReturn(roleConfigView);
    AuthorizationPluginInfoBuilder builder = new AuthorizationPluginInfoBuilder(store);
    Collection<AuthorizationPluginInfo> pluginInfos = builder.allPluginInfos();
    PluggableInstanceSettings authConfigSettings = new PluggableInstanceSettings(PluginConfiguration.getPluginConfigurations(securityAuthConfigMetadata), new PluginView(securityAuthConfigView));
    PluggableInstanceSettings roleConfigSettings = new PluggableInstanceSettings(PluginConfiguration.getPluginConfigurations(roleConfigMetadata), new PluginView(roleConfigView));
    assertEquals(Arrays.asList(new AuthorizationPluginInfo(plugin, authConfigSettings, roleConfigSettings, image)), pluginInfos);
}
Also used : PluginProfileMetadataKeys(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys) AuthorizationPluginInfo(com.thoughtworks.go.server.ui.plugins.AuthorizationPluginInfo) Image(com.thoughtworks.go.plugin.access.common.models.Image) AuthorizationPluginConfigMetadataStore(com.thoughtworks.go.plugin.access.authorization.AuthorizationPluginConfigMetadataStore) PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginProfileMetadataKey(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey) PluginProfileMetadata(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata) Test(org.junit.Test)

Example 27 with GoPluginDescriptor

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

the class ElasticAgentPluginInfoBuilderTest method allPluginInfos_ShouldReturnAListOfAllPluginInfos.

@Test
public void allPluginInfos_ShouldReturnAListOfAllPluginInfos() throws Exception {
    GoPluginDescriptor.About about = new GoPluginDescriptor.About("Plugin Descriptor Validator", "1.0.1", "12.4", "Validates its own plugin descriptor", new GoPluginDescriptor.Vendor("ThoughtWorks Go Team", "www.thoughtworks.com"), Arrays.asList("Linux", "Windows", "Mac OS X"));
    GoPluginDescriptor plugin = new GoPluginDescriptor("docker-plugin", "1.0", about, null, null, false);
    PluginProfileMetadataKeys metadataKeys = new PluginProfileMetadataKeys(Arrays.asList(new PluginProfileMetadataKey("password", new PluginProfileMetadata(true, true))));
    Image image = new Image("image/png", Base64.getEncoder().encodeToString("some-base64-encoded-data".getBytes(UTF_8)));
    ;
    String view = "some html view";
    ElasticPluginConfigMetadataStore store = mock(ElasticPluginConfigMetadataStore.class);
    when(store.getPlugins()).thenReturn(Arrays.asList(plugin));
    when(store.find("docker-plugin")).thenReturn(plugin);
    when(store.getProfileMetadata(plugin)).thenReturn(metadataKeys);
    when(store.getIcon(plugin)).thenReturn(image);
    when(store.getProfileView(plugin)).thenReturn(view);
    ElasticAgentPluginInfoBuilder builder = new ElasticAgentPluginInfoBuilder(store);
    Collection<ElasticPluginInfo> pluginInfos = builder.allPluginInfos();
    PluggableInstanceSettings settings = new PluggableInstanceSettings(PluginConfiguration.getPluginConfigurations(metadataKeys), new PluginView(view));
    assertEquals(Arrays.asList(new ElasticPluginInfo(plugin, settings, image)), pluginInfos);
}
Also used : PluginProfileMetadataKeys(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKeys) ElasticPluginInfo(com.thoughtworks.go.server.ui.plugins.ElasticPluginInfo) Image(com.thoughtworks.go.plugin.access.common.models.Image) ElasticPluginConfigMetadataStore(com.thoughtworks.go.plugin.access.elastic.ElasticPluginConfigMetadataStore) PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) PluginView(com.thoughtworks.go.server.ui.plugins.PluginView) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluginProfileMetadataKey(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadataKey) PluginProfileMetadata(com.thoughtworks.go.plugin.access.common.models.PluginProfileMetadata) Test(org.junit.Test)

Example 28 with GoPluginDescriptor

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

the class TaskViewService method allPluginTasks.

private List<PluggableTask> allPluginTasks() {
    final ArrayList<PluggableTask> tasks = new ArrayList<>();
    for (final String pluginId : PluggableTaskConfigStore.store().pluginIds()) {
        GoPluginDescriptor pluginDescriptor = pluginManager.getPluginDescriptorFor(pluginId);
        TaskPreference taskPreference = PluggableTaskConfigStore.store().preferenceFor(pluginId);
        if (pluginDescriptor != null && taskPreference != null) {
            tasks.add(new PluggableTask(new PluginConfiguration(pluginId, pluginDescriptor.version()), getConfiguration(taskPreference.getConfig())));
        }
    }
    return tasks;
}
Also used : ArrayList(java.util.ArrayList) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)

Example 29 with GoPluginDescriptor

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

the class GoPluginDescriptorModelTest method shouldFillDefaultValuesWhenPluginXmlIsNotPresent.

@Test
public void shouldFillDefaultValuesWhenPluginXmlIsNotPresent() throws Exception {
    GoPluginDescriptor descriptor = GoPluginDescriptor.usingId("plugin.jar", "some_path", new File("bundle_location"), true);
    GoPluginDescriptor descriptorModel = GoPluginDescriptorModel.convertToDescriptorWithAllValues(descriptor);
    assertThat(descriptor.about(), is(nullValue()));
    assertThat(descriptorModel.about(), is(notNullValue()));
    assertThat(descriptorModel.about().description(), is("No description available."));
    assertThat(descriptorModel.about().version().isEmpty(), is(true));
    assertThat(descriptorModel.about().vendor(), is(notNullValue()));
    assertThat(descriptorModel.about().vendor().name(), is("Unknown"));
    assertThat(descriptorModel.about().vendor().url(), is(nullValue()));
    assertThat(descriptorModel.about().name(), is("plugin.jar"));
    assertThat(descriptorModel.about().targetGoVersion(), is("Unknown"));
    assertThat(descriptorModel.about().targetOperatingSystems().contains("No restrictions"), is(true));
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) File(java.io.File) Test(org.junit.Test)

Example 30 with GoPluginDescriptor

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

the class GoPluginDescriptorModelTest method shouldNotAddHttpToUrlIfSecureProtocolIsAlreadyPresent.

@Test
public void shouldNotAddHttpToUrlIfSecureProtocolIsAlreadyPresent() throws Exception {
    GoPluginDescriptor.Vendor vendor = new GoPluginDescriptor.Vendor(null, "https://ali.com");
    GoPluginDescriptor.About about = new GoPluginDescriptor.About(null, null, "13.3.0", "some description", vendor, Arrays.asList("Linux", "Windows"));
    GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin.jar", "1", about, "some_path", new File("bundle_location"), false);
    GoPluginDescriptor descriptorModel = GoPluginDescriptorModel.convertToDescriptorWithAllValues(descriptor);
    assertThat(descriptorModel.about().vendor().url(), is("https://ali.com"));
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) File(java.io.File) Test(org.junit.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