use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations in project gocd by gocd.
the class PackageDefinitionTest method shouldConvertKeysToLowercaseInGetConfigForDisplay.
@Test
public void shouldConvertKeysToLowercaseInGetConfigForDisplay() throws Exception {
RepositoryMetadataStore.getInstance().addMetadataFor("some-plugin", new PackageConfigurations());
PackageMetadataStore.getInstance().addMetadataFor("some-plugin", new PackageConfigurations());
PackageRepository repository = PackageRepositoryMother.create("repo-id", "repo", "some-plugin", "version", new Configuration(create("rk1", false, "rv1")));
PackageDefinition packageDefinition = PackageDefinitionMother.create("p-id", "name", new Configuration(create("pack_key_1", false, "pack_value_1"), create("PACK_KEY_2", false, "PACK_VALUE_2"), create("pacK_KeY3", false, "pacKValue_3")), repository);
packageDefinition.setRepository(repository);
assertThat(packageDefinition.getConfigForDisplay(), is("Repository: [rk1=rv1] - Package: [pack_key_1=pack_value_1, pack_key_2=PACK_VALUE_2, pack_key3=pacKValue_3]"));
}
use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations in project gocd by gocd.
the class PackageDefinitionTest method shouldNotDisplayEmptyValuesInGetConfigForDisplay.
@Test
public void shouldNotDisplayEmptyValuesInGetConfigForDisplay() throws Exception {
RepositoryMetadataStore.getInstance().addMetadataFor("some-plugin", new PackageConfigurations());
PackageMetadataStore.getInstance().addMetadataFor("some-plugin", new PackageConfigurations());
PackageRepository repository = PackageRepositoryMother.create("repo-id", "repo", "some-plugin", "version", new Configuration(create("rk1", false, "rv1")));
PackageDefinition packageDefinition = PackageDefinitionMother.create("p-id", "name", new Configuration(create("pk1", false, ""), create("pk2", false, "pack_value_2"), create("pk3", false, null)), repository);
packageDefinition.setRepository(repository);
assertThat(packageDefinition.getConfigForDisplay(), is("Repository: [rk1=rv1] - Package: [pk2=pack_value_2]"));
}
use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations 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")));
}
use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations in project gocd by gocd.
the class PackageRepositoriesTest method shouldFailValidationIfMaterialWithDuplicateFingerprintIsFound.
@Test
public void shouldFailValidationIfMaterialWithDuplicateFingerprintIsFound() {
com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration packageConfiguration = new com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration();
packageConfiguration.add(new PackageMaterialProperty("k1"));
packageConfiguration.add(new PackageMaterialProperty("k2").with(PART_OF_IDENTITY, false));
PackageMetadataStore.getInstance().addMetadataFor("plugin", new PackageConfigurations(packageConfiguration));
String expectedErrorMessage = "Cannot save package or repo, found duplicate packages. [Repo Name: 'repo-repo1', Package Name: 'pkg1'], [Repo Name: 'repo-repo1', Package Name: 'pkg3'], [Repo Name: 'repo-repo1', Package Name: 'pkg5']";
PackageRepository repository = PackageRepositoryMother.create("repo1");
PackageDefinition definition1 = PackageDefinitionMother.create("1", "pkg1", new Configuration(new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("v1"))), repository);
PackageDefinition definition2 = PackageDefinitionMother.create("2", "pkg2", new Configuration(new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("v2"))), repository);
PackageDefinition definition3 = PackageDefinitionMother.create("3", "pkg3", new Configuration(new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("v1"))), repository);
PackageDefinition definition4 = PackageDefinitionMother.create("4", "pkg4", new Configuration(new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("V1"))), repository);
PackageDefinition definition5 = PackageDefinitionMother.create("5", "pkg5", new Configuration(new ConfigurationProperty(new ConfigurationKey("k1"), new ConfigurationValue("v1")), new ConfigurationProperty(new ConfigurationKey("k2"), new ConfigurationValue("v2"))), repository);
repository.setPackages(new Packages(definition1, definition2, definition3, definition4, definition5));
PackageRepositories packageRepositories = new PackageRepositories(repository);
packageRepositories.validate(null);
assertThat(definition1.errors().getAllOn(PackageDefinition.ID), is(asList(expectedErrorMessage)));
assertThat(definition3.errors().getAllOn(PackageDefinition.ID), is(asList(expectedErrorMessage)));
assertThat(definition3.getFingerprint(AbstractMaterialConfig.FINGERPRINT_DELIMITER).equals(definition1.getFingerprint(AbstractMaterialConfig.FINGERPRINT_DELIMITER)), is(true));
assertThat(definition5.errors().getAllOn(PackageDefinition.ID), is(asList(expectedErrorMessage)));
assertThat(definition5.getFingerprint(AbstractMaterialConfig.FINGERPRINT_DELIMITER).equals(definition1.getFingerprint(AbstractMaterialConfig.FINGERPRINT_DELIMITER)), is(true));
assertThat(definition2.errors().getAllOn(PackageDefinition.ID), is(nullValue()));
assertThat(definition2.getFingerprint(AbstractMaterialConfig.FINGERPRINT_DELIMITER).equals(definition1.getFingerprint(AbstractMaterialConfig.FINGERPRINT_DELIMITER)), is(false));
assertThat(definition4.errors().getAllOn(PackageDefinition.ID), is(nullValue()));
assertThat(definition4.getFingerprint(AbstractMaterialConfig.FINGERPRINT_DELIMITER).equals(definition1.getFingerprint(AbstractMaterialConfig.FINGERPRINT_DELIMITER)), is(false));
}
use of com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations 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]"));
}
Aggregations