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")));
}
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);
}
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;
}
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]"));
}
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));
}
Aggregations