Search in sources :

Example 6 with PluginDescriptor

use of com.thoughtworks.go.plugin.api.info.PluginDescriptor in project gocd by gocd.

the class PluginRoleConfigTest method setAuthorizationPluginInfo.

private void setAuthorizationPluginInfo() {
    PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
    PluginConfiguration k1 = new PluginConfiguration("k1", new Metadata(false, true));
    PluginConfiguration k2 = new PluginConfiguration("k2", new Metadata(false, false));
    PluginConfiguration k3 = new PluginConfiguration("k3", new Metadata(false, true));
    PluggableInstanceSettings authConfigSettins = new PluggableInstanceSettings(asList(k1, k2, k3));
    PluggableInstanceSettings roleConfigSettings = new PluggableInstanceSettings(asList(k1, k2, k3));
    com.thoughtworks.go.plugin.domain.authorization.Capabilities capabilities = new com.thoughtworks.go.plugin.domain.authorization.Capabilities(SupportedAuthType.Web, true, true, true);
    AuthorizationPluginInfo artifactPluginInfo = new AuthorizationPluginInfo(pluginDescriptor, authConfigSettins, roleConfigSettings, null, capabilities);
    when(pluginDescriptor.id()).thenReturn("cd.go.github");
    AuthorizationMetadataStore.instance().setPluginInfo(artifactPluginInfo);
}
Also used : Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration)

Example 7 with PluginDescriptor

use of com.thoughtworks.go.plugin.api.info.PluginDescriptor in project gocd by gocd.

the class BasicCruiseConfigTest method setEAPluginInfo.

private void setEAPluginInfo() {
    PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
    PluginConfiguration k1 = new PluginConfiguration("k1", new Metadata(false, true));
    PluginConfiguration k2 = new PluginConfiguration("k2", new Metadata(false, false));
    PluginConfiguration k3 = new PluginConfiguration("k3", new Metadata(false, true));
    PluggableInstanceSettings clusterProfileSettings = new PluggableInstanceSettings(asList(k1, k2, k3));
    PluggableInstanceSettings profileSettings = new PluggableInstanceSettings(asList(k1, k2, k3));
    com.thoughtworks.go.plugin.domain.elastic.Capabilities capabilities = new com.thoughtworks.go.plugin.domain.elastic.Capabilities(true);
    ElasticAgentPluginInfo ecsPluginInfo = new ElasticAgentPluginInfo(pluginDescriptor, clusterProfileSettings, profileSettings, null, null, capabilities);
    when(pluginDescriptor.id()).thenReturn("ecs");
    ElasticAgentMetadataStore.instance().setPluginInfo(ecsPluginInfo);
}
Also used : ElasticAgentPluginInfo(com.thoughtworks.go.plugin.domain.elastic.ElasticAgentPluginInfo) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) Capabilities(com.thoughtworks.go.plugin.domain.artifact.Capabilities) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration)

Example 8 with PluginDescriptor

use of com.thoughtworks.go.plugin.api.info.PluginDescriptor in project gocd by gocd.

the class BasicCruiseConfigTest method setAuthorizationPluginInfo.

private void setAuthorizationPluginInfo() {
    PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
    PluginConfiguration k1 = new PluginConfiguration("k1", new Metadata(false, true));
    PluginConfiguration k2 = new PluginConfiguration("k2", new Metadata(false, false));
    PluginConfiguration k3 = new PluginConfiguration("k3", new Metadata(false, true));
    PluggableInstanceSettings authConfigSettins = new PluggableInstanceSettings(asList(k1, k2, k3));
    PluggableInstanceSettings roleConfigSettings = new PluggableInstanceSettings(asList(k1, k2, k3));
    com.thoughtworks.go.plugin.domain.authorization.Capabilities capabilities = new com.thoughtworks.go.plugin.domain.authorization.Capabilities(SupportedAuthType.Web, true, true, true);
    AuthorizationPluginInfo artifactPluginInfo = new AuthorizationPluginInfo(pluginDescriptor, authConfigSettins, roleConfigSettings, null, capabilities);
    when(pluginDescriptor.id()).thenReturn("cd.go.github");
    AuthorizationMetadataStore.instance().setPluginInfo(artifactPluginInfo);
}
Also used : Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) AuthorizationPluginInfo(com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo) PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) Capabilities(com.thoughtworks.go.plugin.domain.artifact.Capabilities) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration)

Example 9 with PluginDescriptor

use of com.thoughtworks.go.plugin.api.info.PluginDescriptor in project gocd by gocd.

the class FetchPluggableArtifactTaskTest method setUp.

@BeforeEach
void setUp() {
    config = GoConfigMother.configWithPipelines("random_pipeline", "uppest_lookalike", "uppest_stream", "upstreams_peer", "upstream", "downstream", "dummy");
    PipelineConfig randomPipeline = config.pipelineConfigByName(new CaseInsensitiveString("random_pipeline"));
    randomPipeline.add(StageConfigMother.stageConfig("random-stage1", new JobConfigs(new JobConfig("random-job1"))));
    PipelineConfig uppestLookalike = config.pipelineConfigByName(new CaseInsensitiveString("uppest_lookalike"));
    uppestLookalike.add(StageConfigMother.stageConfig("uppest-stage1", new JobConfigs(new JobConfig("uppest-job1"))));
    uppestStream = config.pipelineConfigByName(new CaseInsensitiveString("uppest_stream"));
    uppestStream.add(StageConfigMother.stageConfig("uppest-stage1", new JobConfigs(new JobConfig("uppest-job1"))));
    uppestStream.add(StageConfigMother.stageConfig("uppest-stage2", new JobConfigs(new JobConfig("uppest-job2"))));
    uppestStream.add(StageConfigMother.stageConfig("uppest-stage3", new JobConfigs(new JobConfig("uppest-job3"))));
    upstream = config.pipelineConfigByName(new CaseInsensitiveString("upstream"));
    upstream.setMaterialConfigs(new MaterialConfigs(MaterialConfigsMother.dependencyMaterialConfig("uppest_stream", "uppest-stage2")));
    upstream.add(StageConfigMother.stageConfig("up-stage1", new JobConfigs(new JobConfig("up-job1"))));
    upstream.add(StageConfigMother.stageConfig("up-stage2", new JobConfigs(new JobConfig("up-job2"))));
    downstream = config.pipelineConfigByName(new CaseInsensitiveString("downstream"));
    downstream.setMaterialConfigs(new MaterialConfigs(MaterialConfigsMother.dependencyMaterialConfig("upstream", "up-stage1")));
    downstream.get(0).getJobs().get(0).addTask(new FetchPluggableArtifactTask(new CaseInsensitiveString("foo"), new CaseInsensitiveString("bar"), new CaseInsensitiveString("baz"), "s3"));
    artifactPluginInfo = mock(ArtifactPluginInfo.class);
    PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
    when(artifactPluginInfo.getDescriptor()).thenReturn(pluginDescriptor);
    when(pluginDescriptor.id()).thenReturn("cd.go.s3");
    ArtifactMetadataStore.instance().setPluginInfo(artifactPluginInfo);
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) ArtifactPluginInfo(com.thoughtworks.go.plugin.domain.artifact.ArtifactPluginInfo) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 10 with PluginDescriptor

use of com.thoughtworks.go.plugin.api.info.PluginDescriptor in project gocd by gocd.

the class ArtifactTypeConfigsTest method setConfigAttributes_shouldSetExternalArtifactWithPlainTextValuesIfPluginIdIsProvided.

@Test
public void setConfigAttributes_shouldSetExternalArtifactWithPlainTextValuesIfPluginIdIsProvided() {
    ArtifactPluginInfo artifactPluginInfo = mock(ArtifactPluginInfo.class);
    PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
    when(artifactPluginInfo.getDescriptor()).thenReturn(pluginDescriptor);
    when(pluginDescriptor.id()).thenReturn("cd.go.artifact.foo");
    PluginConfiguration image = new PluginConfiguration("Image", new Metadata(true, true));
    PluginConfiguration tag = new PluginConfiguration("Tag", new Metadata(true, false));
    ArrayList<PluginConfiguration> pluginMetadata = new ArrayList<>();
    pluginMetadata.add(image);
    pluginMetadata.add(tag);
    when(artifactPluginInfo.getArtifactConfigSettings()).thenReturn(new PluggableInstanceSettings(pluginMetadata));
    ArtifactMetadataStore.instance().setPluginInfo(artifactPluginInfo);
    HashMap<Object, Object> configurationMap1 = new HashMap<>();
    configurationMap1.put("Image", "gocd/gocd-server");
    configurationMap1.put("Tag", "v18.6.0");
    HashMap<String, Object> artifactPlan1 = new HashMap<>();
    artifactPlan1.put("artifactTypeValue", "Pluggable Artifact");
    artifactPlan1.put("id", "artifactId");
    artifactPlan1.put("storeId", "storeId");
    artifactPlan1.put("pluginId", "cd.go.artifact.foo");
    artifactPlan1.put("configuration", configurationMap1);
    List<Map> artifactPlansList = new ArrayList<>();
    artifactPlansList.add(artifactPlan1);
    ArtifactTypeConfigs artifactTypeConfigs = new ArtifactTypeConfigs();
    artifactTypeConfigs.setConfigAttributes(artifactPlansList);
    assertThat(artifactTypeConfigs.size(), is(1));
    PluggableArtifactConfig artifactConfig = (PluggableArtifactConfig) artifactTypeConfigs.get(0);
    assertThat(artifactConfig.getArtifactType(), is(ArtifactType.external));
    assertThat(artifactConfig.getId(), is("artifactId"));
    assertThat(artifactConfig.getStoreId(), is("storeId"));
    assertThat(artifactConfig.getConfiguration().getProperty("Image").isSecure(), is(false));
}
Also used : HashMap(java.util.HashMap) Metadata(com.thoughtworks.go.plugin.domain.common.Metadata) ArrayList(java.util.ArrayList) ArtifactPluginInfo(com.thoughtworks.go.plugin.domain.artifact.ArtifactPluginInfo) PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) PluggableInstanceSettings(com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings) PluginConfiguration(com.thoughtworks.go.plugin.domain.common.PluginConfiguration) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Aggregations

PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)28 Metadata (com.thoughtworks.go.plugin.domain.common.Metadata)11 PluggableInstanceSettings (com.thoughtworks.go.plugin.domain.common.PluggableInstanceSettings)11 PluginConfiguration (com.thoughtworks.go.plugin.domain.common.PluginConfiguration)11 ArtifactPluginInfo (com.thoughtworks.go.plugin.domain.artifact.ArtifactPluginInfo)10 Capabilities (com.thoughtworks.go.plugin.domain.artifact.Capabilities)8 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)7 Image (com.thoughtworks.go.plugin.access.common.models.Image)6 AuthorizationPluginInfo (com.thoughtworks.go.plugin.domain.authorization.AuthorizationPluginInfo)5 PluggableInstanceSettings (com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings)4 PluginConfiguration (com.thoughtworks.go.server.ui.plugins.PluginConfiguration)4 PluginInfo (com.thoughtworks.go.server.ui.plugins.PluginInfo)4 PluginView (com.thoughtworks.go.server.ui.plugins.PluginView)4 ArrayList (java.util.ArrayList)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 Test (org.junit.jupiter.api.Test)4 Capabilities (com.thoughtworks.go.plugin.domain.authorization.Capabilities)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 ClusterProfile (com.thoughtworks.go.config.elastic.ClusterProfile)1 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1