Search in sources :

Example 76 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class MaterialConfigsMother method pluggableSCMMaterialConfigWithConfigProperties.

public static PluggableSCMMaterialConfig pluggableSCMMaterialConfigWithConfigProperties(String... properties) {
    SCM scmConfig = SCMMother.create("scm-id");
    Configuration configuration = new Configuration();
    for (String property : properties) {
        ConfigurationProperty configurationProperty = new ConfigurationProperty(new ConfigurationKey(property), new ConfigurationValue(property + "-value"));
        configuration.add(configurationProperty);
    }
    scmConfig.setConfiguration(configuration);
    return new PluggableSCMMaterialConfig(null, scmConfig, "des-folder", null);
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) ConfigurationValue(com.thoughtworks.go.domain.config.ConfigurationValue) Configuration(com.thoughtworks.go.domain.config.Configuration) ConfigurationKey(com.thoughtworks.go.domain.config.ConfigurationKey) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) SCM(com.thoughtworks.go.domain.scm.SCM)

Example 77 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class PluggableTaskTest method taskTypeShouldBeSanitizedToHaveNoSpecialCharacters.

@Test
public void taskTypeShouldBeSanitizedToHaveNoSpecialCharacters() throws Exception {
    assertThat(new PluggableTask(new PluginConfiguration("abc.def", "1"), new Configuration()).getTaskType(), is("pluggable_task_abc_def"));
    assertThat(new PluggableTask(new PluginConfiguration("abc_def", "1"), new Configuration()).getTaskType(), is("pluggable_task_abc_def"));
    assertThat(new PluggableTask(new PluginConfiguration("abcdef", "1"), new Configuration()).getTaskType(), is("pluggable_task_abcdef"));
    assertThat(new PluggableTask(new PluginConfiguration("abc#def", "1"), new Configuration()).getTaskType(), is("pluggable_task_abc_def"));
    assertThat(new PluggableTask(new PluginConfiguration("abc#__def", "1"), new Configuration()).getTaskType(), is("pluggable_task_abc___def"));
    assertThat(new PluggableTask(new PluginConfiguration("Abc#dEF", "1"), new Configuration()).getTaskType(), is("pluggable_task_Abc_dEF"));
    assertThat(new PluggableTask(new PluginConfiguration("1234567890#ABCDEF", "1"), new Configuration()).getTaskType(), is("pluggable_task_1234567890_ABCDEF"));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Test(org.junit.Test)

Example 78 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class PluggableTaskTest method validateTreeShouldVerifyIfPluggableTaskHasErrors.

@Test
public void validateTreeShouldVerifyIfPluggableTaskHasErrors() {
    PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration(), new Configuration());
    pluggableTask.addError("task", "invalid plugin");
    assertFalse(pluggableTask.validateTree(null));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Test(org.junit.Test)

Example 79 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class PluggableTaskTest method postConstructShouldHandleSecureConfigurationForConfigurationProperties.

@Test
public void postConstructShouldHandleSecureConfigurationForConfigurationProperties() throws Exception {
    TaskPreference taskPreference = mock(TaskPreference.class);
    ConfigurationProperty configurationProperty = ConfigurationPropertyMother.create("KEY1");
    Configuration configuration = new Configuration(configurationProperty);
    PluggableTaskConfigStore.store().setPreferenceFor("abc.def", taskPreference);
    TaskConfig taskConfig = new TaskConfig();
    taskConfig.addProperty("KEY1").with(Property.SECURE, true);
    when(taskPreference.getConfig()).thenReturn(taskConfig);
    PluggableTask task = new PluggableTask(new PluginConfiguration("abc.def", "1"), configuration);
    assertFalse(configurationProperty.isSecure());
    task.applyPluginMetadata();
    assertTrue(configurationProperty.isSecure());
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) Test(org.junit.Test)

Example 80 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class PluggableTaskTest method shouldPopulatePropertiesForDisplay.

@Test
public void shouldPopulatePropertiesForDisplay() throws Exception {
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1", false, "value1"), ConfigurationPropertyMother.create("Key2", false, "value2"), ConfigurationPropertyMother.create("key3", true, "encryptedValue1"));
    PluggableTask task = new PluggableTask(new PluginConfiguration("abc.def", "1"), configuration);
    List<TaskProperty> propertiesForDisplay = task.getPropertiesForDisplay();
    assertThat(propertiesForDisplay.size(), is(3));
    assertProperty(propertiesForDisplay.get(0), "KEY1", "value1", "key1");
    assertProperty(propertiesForDisplay.get(1), "Key2", "value2", "key2");
    assertProperty(propertiesForDisplay.get(2), "key3", "****", "key3");
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) TaskProperty(com.thoughtworks.go.domain.TaskProperty) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) Test(org.junit.Test)

Aggregations

Configuration (com.thoughtworks.go.domain.config.Configuration)136 Test (org.junit.Test)114 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)97 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)34 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)29 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)20 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)18 SCM (com.thoughtworks.go.domain.scm.SCM)17 SCMConfiguration (com.thoughtworks.go.plugin.access.scm.SCMConfiguration)17 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)17 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)16 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)15 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)14 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)13 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)12 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)12 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)11 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)11 SCMConfigurations (com.thoughtworks.go.plugin.access.scm.SCMConfigurations)10 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)9