Search in sources :

Example 6 with PackageConfiguration

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

the class PackageConfigurationTest method shouldSortPackageConfigurationByDisplayOrder.

@Test
public void shouldSortPackageConfigurationByDisplayOrder() throws Exception {
    PackageConfiguration p1 = new PackageConfiguration("k1").with(PackageConfiguration.DISPLAY_ORDER, 1);
    PackageConfiguration p2 = new PackageConfiguration("k2").with(PackageConfiguration.DISPLAY_ORDER, 3);
    assertThat(p2.compareTo(p1), Is.is(2));
}
Also used : PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) Test(org.junit.Test)

Example 7 with PackageConfiguration

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

the class PackageDefinitionServiceTest method setUp.

@Before
public void setUp() throws Exception {
    initMocks(this);
    when(localizer.localize(eq("MANDATORY_CONFIGURATION_FIELD_WITH_NAME"), anyString())).thenReturn("mandatory field");
    service = new PackageDefinitionService(packageRepositoryExtension, localizer, entityHashingService, goConfigService);
    PackageConfigurations configurations = new PackageConfigurations();
    configurations.add(new PackageConfiguration("required").with(PackageConfiguration.REQUIRED, true));
    configurations.add(new PackageConfiguration("required_secure").with(PackageConfiguration.REQUIRED, true).with(PackageConfiguration.SECURE, true));
    configurations.add(new PackageConfiguration("secure").with(PackageConfiguration.SECURE, true).with(PackageConfiguration.REQUIRED, false));
    configurations.add(new PackageConfiguration("not_required_not_secure").with(PackageConfiguration.REQUIRED, false));
    configurations.add(new PackageConfiguration("spec"));
    String pluginId = "yum";
    PackageMetadataStore.getInstance().addMetadataFor(pluginId, configurations);
    packageRepository = PackageRepositoryMother.create("1", "repo", pluginId, "1", new Configuration());
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PackageMaterialTestHelper.assertPackageConfiguration(com.thoughtworks.go.server.service.materials.PackageMaterialTestHelper.assertPackageConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration) PackageMaterialTestHelper.assertPackageConfiguration(com.thoughtworks.go.server.service.materials.PackageMaterialTestHelper.assertPackageConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Before(org.junit.Before)

Example 8 with PackageConfiguration

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

the class PackageRepositoryServiceTest method shouldPerformPluginValidationsUsingMetaDataBeforeSavingPackageRepository.

@Test
public void shouldPerformPluginValidationsUsingMetaDataBeforeSavingPackageRepository() throws Exception {
    //metadata setup
    String pluginId = "yum";
    PackageConfigurations repositoryConfiguration = new PackageConfigurations();
    repositoryConfiguration.add(new PackageConfiguration("required").with(PackageConfiguration.REQUIRED, true));
    repositoryConfiguration.add(new PackageConfiguration("required_secure").with(PackageConfiguration.REQUIRED, true).with(PackageConfiguration.SECURE, true));
    repositoryConfiguration.add(new PackageConfiguration("secure").with(PackageConfiguration.SECURE, true).with(PackageConfiguration.REQUIRED, false));
    repositoryConfiguration.add(new PackageConfiguration("not_required_not_secure"));
    RepositoryMetadataStore.getInstance().addMetadataFor(pluginId, repositoryConfiguration);
    PackageRepository packageRepository = new PackageRepository();
    packageRepository.setPluginConfiguration(new PluginConfiguration(pluginId, "1.0"));
    packageRepository.getConfiguration().add(ConfigurationPropertyMother.create("required", false, ""));
    packageRepository.getConfiguration().add(ConfigurationPropertyMother.create("required_secure", true, ""));
    packageRepository.getConfiguration().add(ConfigurationPropertyMother.create("secure", true, ""));
    packageRepository.getConfiguration().add(ConfigurationPropertyMother.create("not_required_not_secure", false, ""));
    when(packageRepositoryExtension.isRepositoryConfigurationValid(eq(pluginId), any(RepositoryConfiguration.class))).thenReturn(new ValidationResult());
    when(pluginManager.getPluginDescriptorFor(pluginId)).thenReturn(new GoPluginDescriptor(pluginId, "1.0", null, null, null, true));
    when(localizer.localize("MANDATORY_CONFIGURATION_FIELD")).thenReturn("mandatory field");
    service.performPluginValidationsFor(packageRepository);
    assertThat(packageRepository.getConfiguration().get(0).getConfigurationValue().errors().getAllOn("value"), is(Arrays.asList("mandatory field")));
    assertThat(packageRepository.getConfiguration().get(1).getEncryptedConfigurationValue().errors().getAllOn("value"), is(Arrays.asList("mandatory field")));
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration) ValidationResult(com.thoughtworks.go.plugin.api.response.validation.ValidationResult) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Test(org.junit.Test)

Example 9 with PackageConfiguration

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

the class PackageViewModelBuilderTest method setUp.

@Before
public void setUp() {
    initMocks(this);
    builder = new PackageViewModelBuilder(manager);
    yumPoller = new GoPluginDescriptor("yum.poller", "version1", new GoPluginDescriptor.About("Yum Poller", "1.0", null, null, null, null), null, null, false);
    npmPoller = new GoPluginDescriptor("npm.poller", "version1", new GoPluginDescriptor.About("NPM Poller", "2.0", null, null, null, null), null, null, false);
    PackageConfigurations packageConfigurations = new PackageConfigurations();
    packageConfigurations.add(new PackageConfiguration("key1"));
    packageConfigurations.add(new PackageConfiguration("key2"));
    PackageConfigurations repositoryConfigurations = new PackageConfigurations();
    repositoryConfigurations.add(new PackageConfiguration("key1"));
    PackageMetadataStore.getInstance().addMetadataFor(yumPoller.id(), packageConfigurations);
    PackageMetadataStore.getInstance().addMetadataFor(npmPoller.id(), new PackageConfigurations());
    RepositoryMetadataStore.getInstance().addMetadataFor(yumPoller.id(), repositoryConfigurations);
}
Also used : GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations) Before(org.junit.Before)

Example 10 with PackageConfiguration

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

the class PackageDefinition method getSecureKeyInfoProvider.

private SecureKeyInfoProvider getSecureKeyInfoProvider() {
    PackageMetadataStore packageMetadataStore = PackageMetadataStore.getInstance();
    final PackageConfigurations metadata = packageMetadataStore.getMetadata(pluginId());
    if (metadata == null) {
        return null;
    }
    return new SecureKeyInfoProvider() {

        @Override
        public boolean isSecure(String key) {
            PackageConfiguration packageConfiguration = metadata.get(key);
            return packageConfiguration.getOption(PackageConfiguration.SECURE);
        }
    };
}
Also used : PackageMetadataStore(com.thoughtworks.go.plugin.access.packagematerial.PackageMetadataStore) SecureKeyInfoProvider(com.thoughtworks.go.domain.config.SecureKeyInfoProvider) PackageConfiguration(com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration) PackageConfigurations(com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)

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