Search in sources :

Example 56 with PluginConfiguration

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

the class PluggableTaskTest method validateTreeShouldVerifyIfCancelTasksHasNestedCancelTask.

@Test
public void validateTreeShouldVerifyIfCancelTasksHasNestedCancelTask() {
    PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration(), new Configuration());
    pluggableTask.onCancelConfig = mock(OnCancelConfig.class);
    com.thoughtworks.go.domain.Task cancelTask = mock(com.thoughtworks.go.domain.Task.class);
    when(pluggableTask.onCancelConfig.getTask()).thenReturn(cancelTask);
    when(cancelTask.hasCancelTask()).thenReturn(true);
    when(pluggableTask.onCancelConfig.validateTree(null)).thenReturn(true);
    assertFalse(pluggableTask.validateTree(null));
    assertThat(pluggableTask.errors().get("onCancelConfig").get(0), is("Cannot nest 'oncancel' within a cancel task"));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) OnCancelConfig(com.thoughtworks.go.config.OnCancelConfig) Test(org.junit.jupiter.api.Test)

Example 57 with PluginConfiguration

use of com.thoughtworks.go.domain.config.PluginConfiguration 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.jupiter.api.Test)

Example 58 with PluginConfiguration

use of com.thoughtworks.go.domain.config.PluginConfiguration 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.jupiter.api.Test)

Example 59 with PluginConfiguration

use of com.thoughtworks.go.domain.config.PluginConfiguration 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.jupiter.api.Test)

Example 60 with PluginConfiguration

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

the class PluggableTaskTest method isValidShouldVerifyForValidConfigurationProperties.

@Test
public void isValidShouldVerifyForValidConfigurationProperties() {
    PluginConfiguration pluginConfiguration = new PluginConfiguration("github.pr", "1.1");
    Configuration configuration = mock(Configuration.class);
    PluggableTaskConfigStore.store().setPreferenceFor(pluginConfiguration.getId(), mock(TaskPreference.class));
    when(configuration.hasErrors()).thenReturn(true);
    PluggableTask pluggableTask = new PluggableTask(pluginConfiguration, configuration);
    assertFalse(pluggableTask.isValid());
    verify(configuration).validateTree();
    verify(configuration).hasErrors();
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) Test(org.junit.jupiter.api.Test)

Aggregations

PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)88 Configuration (com.thoughtworks.go.domain.config.Configuration)63 Test (org.junit.jupiter.api.Test)61 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)29 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)23 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)18 SCM (com.thoughtworks.go.domain.scm.SCM)17 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)13 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)13 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)9 Test (org.junit.Test)9 TaskProperty (com.thoughtworks.go.domain.TaskProperty)8 Map (java.util.Map)8 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)6 HashMap (java.util.HashMap)5 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)4 Result (com.thoughtworks.go.plugin.api.response.Result)4 TaskView (com.thoughtworks.go.plugin.api.task.TaskView)4 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)4 AntTask (com.thoughtworks.go.config.AntTask)3