Search in sources :

Example 16 with PackageConfigurations

use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations in project gocd by gocd.

the class PluginInfoBuilderTest method setUp.

@Before
public void setUp() {
    initMocks(this);
    githubDescriptor = new GoPluginDescriptor("github.oauth", "version1", new GoPluginDescriptor.About("Github OAuth Plugin", "1.0", null, null, null, null), null, null, false);
    emailNotifier = new GoPluginDescriptor("email.notifier", "version1", new GoPluginDescriptor.About("Email Notifier", "1.0", null, null, null, null), null, null, false);
    yumPoller = new GoPluginDescriptor("yum.poller", "version1", new GoPluginDescriptor.About("Yum Poller", "1.0", null, null, null, null), null, null, false);
    xunitConvertor = new GoPluginDescriptor("xunit.convertor", "version1", new GoPluginDescriptor.About("Xunit Convertor", "1.0", null, null, null, null), null, null, false);
    githubPR = new GoPluginDescriptor("github.pr", "version1", new GoPluginDescriptor.About("Github PR", "1.0", null, null, null, null), null, null, false);
    dockerElasticAgentPlugin = new GoPluginDescriptor("cd.go.elastic-agent.docker", "1.0", new GoPluginDescriptor.About("GoCD Docker Elastic Agent Plugin", "1.0", null, null, null, null), null, null, false);
    ldapAuthPlugin = new GoPluginDescriptor("cd.go.authorization.ldap", "1.0", new GoPluginDescriptor.About("GoCD LDAP Plugin", "1.0", null, null, null, null), null, null, false);
    JsonBasedPluggableTask jsonBasedPluggableTask = mock(JsonBasedPluggableTask.class);
    TaskView taskView = new TaskView() {

        @Override
        public String displayValue() {
            return "task display value";
        }

        @Override
        public String template() {
            return "pluggable task view template";
        }
    };
    when(authenticationPluginRegistry.getAuthenticationPlugins()).thenReturn(new HashSet<>(Arrays.asList("github.oauth")));
    when(notificationPluginRegistry.getNotificationPlugins()).thenReturn(new HashSet<>(Arrays.asList("email.notifier")));
    when(elasticPluginConfigMetadataStore.getPlugins()).thenReturn(new ArrayList<>(Arrays.asList(dockerElasticAgentPlugin)));
    when(authorizationPluginConfigMetadataStore.getPlugins()).thenReturn(new ArrayList<>(Arrays.asList(ldapAuthPlugin)));
    when(jsonBasedPluggableTask.view()).thenReturn(taskView);
    when(manager.getPluginDescriptorFor("github.oauth")).thenReturn(githubDescriptor);
    when(manager.getPluginDescriptorFor("email.notifier")).thenReturn(emailNotifier);
    when(manager.getPluginDescriptorFor("yum.poller")).thenReturn(yumPoller);
    when(manager.getPluginDescriptorFor("xunit.convertor")).thenReturn(xunitConvertor);
    when(manager.getPluginDescriptorFor("github.pr")).thenReturn(githubPR);
    when(manager.getPluginDescriptorFor("cd.go.elastic-agent.docker")).thenReturn(dockerElasticAgentPlugin);
    when(manager.getPluginDescriptorFor(ldapAuthPlugin.id())).thenReturn(ldapAuthPlugin);
    MetadataStoreHelper.clear();
    PackageMetadataStore.getInstance().addMetadataFor(yumPoller.id(), new PackageConfigurations());
    PluggableTaskConfigStore.store().setPreferenceFor("xunit.convertor", new TaskPreference(jsonBasedPluggableTask));
    SCMMetadataStore.getInstance().setPreferenceFor("github.pr", new SCMPreference(new SCMConfigurations(), mock(SCMView.class)));
    pluginViewModelBuilder = new PluginInfoBuilder(authenticationPluginRegistry, notificationPluginRegistry, elasticPluginConfigMetadataStore, authorizationPluginConfigMetadataStore, manager);
}
Also used : TaskView(com.thoughtworks.go.plugin.api.task.TaskView) JsonBasedPluggableTask(com.thoughtworks.go.plugin.access.pluggabletask.JsonBasedPluggableTask) SCMPreference(com.thoughtworks.go.plugin.access.scm.SCMPreference) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) SCMConfigurations(com.thoughtworks.go.plugin.access.scm.SCMConfigurations) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Before(org.junit.Before)

Example 17 with PackageConfigurations

use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations in project gocd by gocd.

the class PackageRepositoryPluginInfoBuilderTest method pluginInfoFor_ShouldProvidePluginInfoForAPlugin.

@Test
public void pluginInfoFor_ShouldProvidePluginInfoForAPlugin() 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);
    PluginManager pluginManager = mock(PluginManager.class);
    PackageMetadataStore packageMetadataStore = mock(PackageMetadataStore.class);
    RepositoryMetadataStore repositoryMetadataStore = mock(RepositoryMetadataStore.class);
    when(packageMetadataStore.getPlugins()).thenReturn(Collections.singletonList(plugin.id()));
    when(pluginManager.getPluginDescriptorFor(plugin.id())).thenReturn(plugin);
    PackageConfigurations packageConfigurations = new PackageConfigurations();
    packageConfigurations.add(new com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration("key1"));
    packageConfigurations.add(new com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration("key2"));
    PackageConfigurations repoConfigurations = new PackageConfigurations();
    repoConfigurations.add(new com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration("key1"));
    repoConfigurations.add(new com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration("key2"));
    when(packageMetadataStore.getMetadata(plugin.id())).thenReturn(packageConfigurations);
    when(repositoryMetadataStore.getMetadata(plugin.id())).thenReturn(repoConfigurations);
    PackageRepositoryPluginInfoBuilder builder = new PackageRepositoryPluginInfoBuilder(pluginManager, packageMetadataStore, repositoryMetadataStore);
    PackageRepositoryPluginInfo pluginInfo = builder.pluginInfoFor(plugin.id());
    PackageRepositoryPluginInfo expectedPluginInfo = new PackageRepositoryPluginInfo(plugin, new PluggableInstanceSettings(configurations(packageConfigurations)), new PluggableInstanceSettings(configurations(repoConfigurations)));
    assertEquals(expectedPluginInfo, pluginInfo);
}
Also used : RepositoryMetadataStore(com.thoughtworks.go.plugin.access.packagematerial.RepositoryMetadataStore) PluginManager(com.thoughtworks.go.plugin.infra.PluginManager) PackageMetadataStore(com.thoughtworks.go.plugin.access.packagematerial.PackageMetadataStore) PackageRepositoryPluginInfo(com.thoughtworks.go.server.ui.plugins.PackageRepositoryPluginInfo) PluggableInstanceSettings(com.thoughtworks.go.server.ui.plugins.PluggableInstanceSettings) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Test(org.junit.Test)

Example 18 with PackageConfigurations

use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations in project gocd by gocd.

the class GoConfigMother method configWithPackageRepo.

public static CruiseConfig configWithPackageRepo(String... ids) throws Exception {
    final CruiseConfig config = new BasicCruiseConfig();
    PackageConfigurations configuration = new PackageConfigurations();
    configuration.addConfiguration(new PackageConfiguration("key1"));
    configuration.addConfiguration(new PackageConfiguration("key2").with(PackageConfiguration.SECURE, true));
    RepositoryMetadataStore.getInstance().addMetadataFor("plugin-1", configuration);
    for (String id : ids) {
        PackageRepository packageRepository = new PackageRepository();
        packageRepository.setId(id);
        packageRepository.setName("name" + id);
        packageRepository.setPluginConfiguration(new PluginConfiguration("plugin-1", "1.0.0"));
        packageRepository.setPackages(new Packages(PackageDefinitionMother.create(id + "-pkg-1", packageRepository), PackageDefinitionMother.create(id + "-pkg-2", packageRepository)));
        GoCipher cipher = new GoCipher();
        ConfigurationProperty p1 = new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1"));
        ConfigurationProperty p2 = new ConfigurationProperty(new ConfigurationKey("key2"), null, new EncryptedConfigurationValue(cipher.encrypt("value2")), cipher);
        packageRepository.setConfiguration(new Configuration(p1, p2));
        config.setPackageRepositories(new PackageRepositories(packageRepository));
    }
    return config;
}
Also used : GoCipher(com.thoughtworks.go.security.GoCipher) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Packages(com.thoughtworks.go.domain.packagerepository.Packages) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)

Example 19 with PackageConfigurations

use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations in project gocd by gocd.

the class ConfigurationPropertyTest method shouldSetConfigAttributesForNonSecureProperty.

@Test
public void shouldSetConfigAttributesForNonSecureProperty() throws Exception {
    ConfigurationProperty configurationProperty = new ConfigurationProperty();
    HashMap attributes = new HashMap();
    HashMap keyMap = new HashMap();
    keyMap.put("name", "fooKey");
    attributes.put(ConfigurationProperty.CONFIGURATION_KEY, keyMap);
    HashMap valueMap = new HashMap();
    valueMap.put("value", "fooValue");
    attributes.put(ConfigurationProperty.CONFIGURATION_VALUE, valueMap);
    PackageConfigurations metadata = new PackageConfigurations();
    metadata.addConfiguration(new PackageConfiguration("fooKey", null));
    attributes.put(Configuration.METADATA, metadata);
    configurationProperty.setConfigAttributes(attributes, null);
    assertThat(configurationProperty.getConfigurationKey().getName(), is("fooKey"));
    assertThat(configurationProperty.getConfigurationValue().getValue(), is("fooValue"));
}
Also used : HashMap(java.util.HashMap) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Test(org.junit.Test)

Example 20 with PackageConfigurations

use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations in project gocd by gocd.

the class PackageDefinitionTest method shouldGetFingerprint.

@Test
public void shouldGetFingerprint() {
    String pluginId = "pluginid";
    PackageConfigurations repositoryConfigurations = new PackageConfigurations();
    repositoryConfigurations.add(new PackageConfiguration("k1", "v1").with(PackageConfiguration.PART_OF_IDENTITY, true));
    RepositoryMetadataStore.getInstance().addMetadataFor(pluginId, repositoryConfigurations);
    PackageConfigurations packageConfigurations = new PackageConfigurations();
    packageConfigurations.add(new PackageConfiguration("k2", "v2").with(PackageConfiguration.PART_OF_IDENTITY, true));
    PackageMetadataStore.getInstance().addMetadataFor(pluginId, packageConfigurations);
    PackageRepository repository = PackageRepositoryMother.create("repo-id", "repo", pluginId, "version", new Configuration(create("k1", false, "v1")));
    PackageDefinition packageDefinition = PackageDefinitionMother.create("p-id", "name", new Configuration(create("k2", false, "v2")), repository);
    String fingerprint = packageDefinition.getFingerprint(AbstractMaterial.FINGERPRINT_DELIMITER);
    assertThat(fingerprint, is(CachedDigestUtils.sha256Hex("plugin-id=pluginid<|>k2=v2<|>k1=v1")));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Test(org.junit.Test)

Aggregations

PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)31 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)23 Test (org.junit.Test)23 Configuration (com.thoughtworks.go.domain.config.Configuration)14 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)13 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)7 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)6 GoCipher (com.thoughtworks.go.security.GoCipher)6 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)4 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)3 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)3 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)3 PackageMetadataStore (com.thoughtworks.go.plugin.access.packagematerial.PackageMetadataStore)3 RepositoryMetadataStore (com.thoughtworks.go.plugin.access.packagematerial.RepositoryMetadataStore)3 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)3 HashMap (java.util.HashMap)3 Before (org.junit.Before)3 ConfigurationHolder (com.thoughtworks.go.config.helper.ConfigurationHolder)2 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)2 SecureKeyInfoProvider (com.thoughtworks.go.domain.config.SecureKeyInfoProvider)2