Search in sources :

Example 1 with PackageConfiguration

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

the class PackageDefinitionTest method shouldNotConsiderPropertiesMarkedAsNotPartOfIdentity_GetFingerprint.

@Test
public void shouldNotConsiderPropertiesMarkedAsNotPartOfIdentity_GetFingerprint() {
    String pluginId = "plugin-id";
    PackageConfigurations repositoryConfigurations = new PackageConfigurations();
    repositoryConfigurations.add(new PackageConfiguration("rk1", "rv1").with(PackageConfiguration.PART_OF_IDENTITY, true));
    repositoryConfigurations.add(new PackageConfiguration("rk2", "rv2").with(PackageConfiguration.PART_OF_IDENTITY, false));
    RepositoryMetadataStore.getInstance().addMetadataFor(pluginId, repositoryConfigurations);
    PackageConfigurations packageConfigurations = new PackageConfigurations();
    packageConfigurations.add(new PackageConfiguration("pk1", "pv1").with(PackageConfiguration.PART_OF_IDENTITY, false));
    packageConfigurations.add(new PackageConfiguration("pk2", "pv2").with(PackageConfiguration.PART_OF_IDENTITY, true));
    PackageMetadataStore.getInstance().addMetadataFor(pluginId, packageConfigurations);
    PackageRepository repository = PackageRepositoryMother.create("repo-id", "repo", pluginId, "version", new Configuration(create("rk1", false, "rv1"), create("rk2", false, "rv2")));
    PackageDefinition packageDefinition = PackageDefinitionMother.create("p-id", "name", new Configuration(create("pk1", false, "pv1"), create("pk2", false, "pv2")), repository);
    String fingerprint = packageDefinition.getFingerprint(AbstractMaterial.FINGERPRINT_DELIMITER);
    assertThat(fingerprint, is(CachedDigestUtils.sha256Hex("plugin-id=plugin-id<|>pk2=pv2<|>rk1=rv1")));
}
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)

Example 2 with PackageConfiguration

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

the class PackageMaterialUpdaterIntegrationTest method addMetadata.

private void addMetadata(PackageMaterial material, String field, boolean partOfIdentity) {
    PackageConfigurations packageConfigurations = new PackageConfigurations();
    packageConfigurations.addConfiguration(new PackageConfiguration(field).with(PackageConfiguration.PART_OF_IDENTITY, partOfIdentity));
    PackageMetadataStore.getInstance().addMetadataFor(material.getPluginId(), packageConfigurations);
}
Also used : PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)

Example 3 with PackageConfiguration

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

the class PackageRepositoryPluginInfoBuilder method configurations.

static List<PluginConfiguration> configurations(PackageConfigurations packageConfigurations) {
    ArrayList<PluginConfiguration> pluginConfigurations = new ArrayList<>();
    for (PackageConfiguration configuration : packageConfigurations.list()) {
        Map<String, Object> metaData = new HashMap<>();
        metaData.put("required", configuration.getOption(Property.REQUIRED));
        metaData.put("secure", configuration.getOption(Property.SECURE));
        metaData.put("part_of_identity", configuration.getOption(Property.PART_OF_IDENTITY));
        metaData.put("display_name", configuration.getOption(Property.DISPLAY_NAME));
        metaData.put("display_order", configuration.getOption(Property.DISPLAY_ORDER));
        pluginConfigurations.add(new PluginConfiguration(configuration.getKey(), metaData));
    }
    return pluginConfigurations;
}
Also used : PluginConfiguration(com.thoughtworks.go.server.ui.plugins.PluginConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)

Example 4 with PackageConfiguration

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

the class PackageRepositoryTest method shouldOnlyDisplayFieldsWhichAreNonSecureAndPartOfIdentityInGetConfigForDisplayWhenPluginExists.

@Test
public void shouldOnlyDisplayFieldsWhichAreNonSecureAndPartOfIdentityInGetConfigForDisplayWhenPluginExists() throws Exception {
    PackageConfigurations repositoryConfiguration = new PackageConfigurations();
    repositoryConfiguration.addConfiguration(new PackageConfiguration("key1").with(PART_OF_IDENTITY, true).with(SECURE, false));
    repositoryConfiguration.addConfiguration(new PackageConfiguration("key2").with(PART_OF_IDENTITY, false).with(SECURE, false));
    repositoryConfiguration.addConfiguration(new PackageConfiguration("key3").with(PART_OF_IDENTITY, true).with(SECURE, true));
    repositoryConfiguration.addConfiguration(new PackageConfiguration("key4").with(PART_OF_IDENTITY, false).with(SECURE, true));
    repositoryConfiguration.addConfiguration(new PackageConfiguration("key5").with(PART_OF_IDENTITY, true).with(SECURE, false));
    RepositoryMetadataStore.getInstance().addMetadataFor("plugin1", repositoryConfiguration);
    Configuration configuration = new Configuration(create("key1", false, "value1"), create("key2", false, "value2"), create("key3", true, "value3"), create("key4", true, "value4"), create("key5", false, "value5"));
    PackageRepository repository = PackageRepositoryMother.create("repo1", "repo1-name", "plugin1", "1", configuration);
    assertThat(repository.getConfigForDisplay(), is("Repository: [key1=value1, key5=value5]"));
}
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)

Example 5 with PackageConfiguration

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

the class PackageConfigurationTest method shouldGetOptionValue.

@Test
public void shouldGetOptionValue() {
    PackageConfiguration packageConfiguration = new PackageConfiguration("key");
    packageConfiguration.with(PackageConfiguration.DISPLAY_NAME, "some display name");
    packageConfiguration.with(PackageConfiguration.DISPLAY_ORDER, 3);
    assertThat(packageConfiguration.getOption(PackageConfiguration.DISPLAY_NAME), is("some display name"));
    assertThat(packageConfiguration.getOption(PackageConfiguration.DISPLAY_ORDER), is(3));
}
Also used : PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) Test(org.junit.Test)

Aggregations

PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)23 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)19 Test (org.junit.Test)15 Configuration (com.thoughtworks.go.domain.config.Configuration)9 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)7 GoCipher (com.thoughtworks.go.security.GoCipher)6 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)4 HashMap (java.util.HashMap)3 ConfigurationHolder (com.thoughtworks.go.config.helper.ConfigurationHolder)2 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)2 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)2 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)2 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)2 SecureKeyInfoProvider (com.thoughtworks.go.domain.config.SecureKeyInfoProvider)2 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)2 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)2 Map (java.util.Map)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Before (org.junit.Before)2 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)1