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