Search in sources :

Example 6 with PluginConfiguration

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

the class PluggableTaskTest method shouldAddPropertyComingFromAttributesMapIfPresentInConfigStoreEvenIfItISNotPresentInCurrentConfiguration.

@Test
public void shouldAddPropertyComingFromAttributesMapIfPresentInConfigStoreEvenIfItISNotPresentInCurrentConfiguration() throws Exception {
    TaskPreference taskPreference = mock(TaskPreference.class);
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
    PluggableTaskConfigStore.store().setPreferenceFor("abc.def", taskPreference);
    PluggableTask task = new PluggableTask(new PluginConfiguration("abc.def", "1"), configuration);
    Map<String, String> attributeMap = DataStructureUtils.m("KEY1", "value1", "Key2", "value2");
    TaskConfig taskConfig = new TaskConfig();
    TaskProperty property1 = new TaskProperty("KEY1", "value1");
    TaskProperty property2 = new TaskProperty("Key2", "value2");
    taskConfig.addProperty(property1.getName());
    taskConfig.addProperty(property2.getName());
    when(taskPreference.getConfig()).thenReturn(taskConfig);
    task.setTaskConfigAttributes(attributeMap);
    assertThat(task.configAsMap().get("KEY1").get(PluggableTask.VALUE_KEY), is("value1"));
    assertThat(task.configAsMap().get("Key2").get(PluggableTask.VALUE_KEY), is("value2"));
}
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) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) Test(org.junit.Test)

Example 7 with PluginConfiguration

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

the class PluggableTaskTest method postConstructShouldDoNothingForAInvalidConfigurationProperty.

@Test
public void postConstructShouldDoNothingForAInvalidConfigurationProperty() 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();
    when(taskPreference.getConfig()).thenReturn(taskConfig);
    PluggableTask task = new PluggableTask(new PluginConfiguration("abc.def", "1"), configuration);
    assertFalse(configurationProperty.isSecure());
    task.applyPluginMetadata();
    assertFalse(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 8 with PluginConfiguration

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

the class PluggableTaskTest method shouldHandleSecureConfigurations.

@Test
public void shouldHandleSecureConfigurations() throws Exception {
    TaskPreference taskPreference = mock(TaskPreference.class);
    Configuration configuration = new Configuration();
    PluggableTaskConfigStore.store().setPreferenceFor("abc.def", taskPreference);
    PluggableTask task = new PluggableTask(new PluginConfiguration("abc.def", "1"), configuration);
    Map<String, String> attributeMap = DataStructureUtils.m("KEY1", "value1");
    TaskConfig taskConfig = new TaskConfig();
    taskConfig.addProperty("KEY1").with(Property.SECURE, true);
    when(taskPreference.getConfig()).thenReturn(taskConfig);
    task.setTaskConfigAttributes(attributeMap);
    assertThat(task.getConfiguration().size(), is(1));
    assertTrue(task.getConfiguration().first().isSecure());
    assertThat(task.getConfiguration().first().getValue(), is("value1"));
}
Also used : 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 9 with PluginConfiguration

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

the class PluggableTaskTest method shouldIgnoreKeysPresentInConfigAttributesMapButNotPresentInConfigStore.

@Test
public void shouldIgnoreKeysPresentInConfigAttributesMapButNotPresentInConfigStore() throws Exception {
    TaskPreference taskPreference = mock(TaskPreference.class);
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
    PluggableTaskConfigStore.store().setPreferenceFor("abc.def", taskPreference);
    PluggableTask task = new PluggableTask(new PluginConfiguration("abc.def", "1"), configuration);
    Map<String, String> attributeMap = DataStructureUtils.m("KEY1", "value1", "Key2", "value2");
    TaskConfig taskConfig = new TaskConfig();
    TaskProperty property1 = new TaskProperty("KEY1", "value1");
    taskConfig.addProperty(property1.getName());
    when(taskPreference.getConfig()).thenReturn(taskConfig);
    task.setTaskConfigAttributes(attributeMap);
    assertThat(task.configAsMap().get("KEY1").get(PluggableTask.VALUE_KEY), is("value1"));
    assertFalse(task.configAsMap().containsKey("Key2"));
}
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) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) Test(org.junit.Test)

Example 10 with PluginConfiguration

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

the class PluggableTaskTest method shouldPopulatePropertiesForDisplayRetainingOrderAndDisplayNameIfConfigured.

@Test
public void shouldPopulatePropertiesForDisplayRetainingOrderAndDisplayNameIfConfigured() throws Exception {
    Task taskDetails = mock(Task.class);
    TaskConfig taskConfig = new TaskConfig();
    addProperty(taskConfig, "KEY2", "Key 2", 1);
    addProperty(taskConfig, "KEY1", "Key 1", 0);
    addProperty(taskConfig, "KEY3", "Key 3", 2);
    when(taskDetails.config()).thenReturn(taskConfig);
    when(taskDetails.view()).thenReturn(mock(TaskView.class));
    String pluginId = "plugin_with_all_details";
    PluggableTaskConfigStore.store().setPreferenceFor(pluginId, new TaskPreference(taskDetails));
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY3", true, "encryptedValue1"), ConfigurationPropertyMother.create("KEY1", false, "value1"), ConfigurationPropertyMother.create("KEY2", false, "value2"));
    PluggableTask task = new PluggableTask(new PluginConfiguration(pluginId, "1"), configuration);
    List<TaskProperty> propertiesForDisplay = task.getPropertiesForDisplay();
    assertThat(propertiesForDisplay.size(), is(3));
    assertProperty(propertiesForDisplay.get(0), "Key 1", "value1", "key1");
    assertProperty(propertiesForDisplay.get(1), "Key 2", "value2", "key2");
    assertProperty(propertiesForDisplay.get(2), "Key 3", "****", "key3");
}
Also used : Task(com.thoughtworks.go.plugin.api.task.Task) AntTask(com.thoughtworks.go.config.AntTask) TaskView(com.thoughtworks.go.plugin.api.task.TaskView) 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) TaskConfig(com.thoughtworks.go.plugin.api.task.TaskConfig) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) Test(org.junit.Test)

Aggregations

PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)83 Test (org.junit.Test)72 Configuration (com.thoughtworks.go.domain.config.Configuration)61 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)28 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)18 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)18 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)13 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)12 SCM (com.thoughtworks.go.domain.scm.SCM)11 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)10 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)9 TaskProperty (com.thoughtworks.go.domain.TaskProperty)8 Map (java.util.Map)8 SCMConfiguration (com.thoughtworks.go.plugin.access.scm.SCMConfiguration)7 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)6 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)5 SCMConfigurations (com.thoughtworks.go.plugin.access.scm.SCMConfigurations)5 HashMap (java.util.HashMap)5 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)4 SCMPreference (com.thoughtworks.go.plugin.access.scm.SCMPreference)4