Search in sources :

Example 11 with Property

use of com.thoughtworks.go.plugin.api.config.Property in project gocd by gocd.

the class ConfigurationPropertyBuilderTest method shouldCreateWithEncyrptedValueForOnlyPlainTextInputForSecureProperty.

@Test
public void shouldCreateWithEncyrptedValueForOnlyPlainTextInputForSecureProperty() throws Exception {
    Property key = new Property("key");
    key.with(Property.SECURE, true);
    ConfigurationProperty property = new ConfigurationPropertyBuilder().create("key", "value", null, true);
    assertThat(property.getConfigKeyName(), is("key"));
    assertThat(property.getEncryptedValue(), is(new GoCipher().encrypt("value")));
    assertNull(property.getConfigurationValue());
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) GoCipher(com.thoughtworks.go.security.GoCipher) Property(com.thoughtworks.go.plugin.api.config.Property) ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Test(org.junit.Test)

Example 12 with Property

use of com.thoughtworks.go.plugin.api.config.Property in project gocd by gocd.

the class ConfigurationPropertyBuilderTest method shouldCreateWithErrorsIfBothPlainAndEncryptedTextInputAreSpecifiedForUnSecuredProperty.

@Test
public void shouldCreateWithErrorsIfBothPlainAndEncryptedTextInputAreSpecifiedForUnSecuredProperty() {
    Property key = new Property("key");
    key.with(Property.SECURE, false);
    ConfigurationProperty property = new ConfigurationPropertyBuilder().create("key", "value", "enc_value", false);
    assertThat(property.errors().get("configurationValue").get(0), is("You may only specify `value` or `encrypted_value`, not both!"));
    assertThat(property.errors().get("encryptedValue").get(0), is("You may only specify `value` or `encrypted_value`, not both!"));
    assertThat(property.getConfigurationValue().getValue(), is("value"));
    assertThat(property.getEncryptedValue(), is("enc_value"));
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Property(com.thoughtworks.go.plugin.api.config.Property) ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Test(org.junit.Test)

Example 13 with Property

use of com.thoughtworks.go.plugin.api.config.Property in project gocd by gocd.

the class ConfigurationPropertyBuilderTest method shouldCreateConfigurationPropertyWithEncyrptedValueForSecureProperty.

@Test
public void shouldCreateConfigurationPropertyWithEncyrptedValueForSecureProperty() {
    Property key = new Property("key");
    key.with(Property.SECURE, true);
    ConfigurationProperty property = new ConfigurationPropertyBuilder().create("key", null, "enc_value", true);
    assertThat(property.getConfigKeyName(), is("key"));
    assertThat(property.getEncryptedValue(), is("enc_value"));
    assertNull(property.getConfigurationValue());
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Property(com.thoughtworks.go.plugin.api.config.Property) ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) Test(org.junit.Test)

Example 14 with Property

use of com.thoughtworks.go.plugin.api.config.Property in project gocd by gocd.

the class TaskViewServiceTest method shouldFetchPluggableTasksWithSecureConfigurations.

@Test
public void shouldFetchPluggableTasksWithSecureConfigurations() throws Exception {
    String plugin = "task-plugin";
    when(pluginManager.getPluginDescriptorFor(plugin)).thenReturn(new GoPluginDescriptor(plugin, "1", null, null, null, false));
    Property taskConfigProperty = new TaskConfigProperty("key1", null).with(Property.SECURE, true);
    storeTaskPreferences(plugin, taskConfigProperty);
    when(registry.implementersOf(Task.class)).thenReturn(Arrays.<Class<? extends Task>>asList(PluggableTask.class));
    PluggableTask pluggableTask = (PluggableTask) taskViewService.taskInstanceFor(new PluggableTask(new PluginConfiguration(plugin, "1"), null).getTaskType());
    assertTrue(pluggableTask.getConfiguration().first().isSecure());
}
Also used : PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) TaskConfigProperty(com.thoughtworks.go.plugin.api.task.TaskConfigProperty) TaskConfigProperty(com.thoughtworks.go.plugin.api.task.TaskConfigProperty) Property(com.thoughtworks.go.plugin.api.config.Property) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) Test(org.junit.Test)

Example 15 with Property

use of com.thoughtworks.go.plugin.api.config.Property in project gocd by gocd.

the class TaskViewServiceTest method shouldStoreDefaultValuesGivenForPropertiesInAPluginWhenInitializingANewTaskPlugin.

@Test
public void shouldStoreDefaultValuesGivenForPropertiesInAPluginWhenInitializingANewTaskPlugin() throws Exception {
    String plugin = "task-plugin";
    when(pluginManager.getPluginDescriptorFor(plugin)).thenReturn(new GoPluginDescriptor(plugin, "1", null, null, null, false));
    Property taskConfigProperty1 = new TaskConfigProperty("key1", null);
    Property taskConfigProperty2 = new TaskConfigProperty("key2", null);
    Property taskConfigProperty3 = new TaskConfigProperty("key3", null);
    storeTaskPreferences(plugin, taskConfigProperty1.withDefault("default1"), taskConfigProperty2.withDefault("default2"), taskConfigProperty3);
    when(registry.implementersOf(Task.class)).thenReturn(Arrays.<Class<? extends Task>>asList(PluggableTask.class));
    PluggableTask pluggableTask = (PluggableTask) taskViewService.taskInstanceFor(new PluggableTask(new PluginConfiguration(plugin, "1"), new Configuration()).getTaskType());
    assertThat(pluggableTask.getConfiguration().getProperty("key1").getValue(), is("default1"));
    assertThat(pluggableTask.getConfiguration().getProperty("key2").getValue(), is("default2"));
    assertNull(pluggableTask.getConfiguration().getProperty("key3").getValue());
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) GoPluginDescriptor(com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor) TaskConfigProperty(com.thoughtworks.go.plugin.api.task.TaskConfigProperty) TaskConfigProperty(com.thoughtworks.go.plugin.api.task.TaskConfigProperty) Property(com.thoughtworks.go.plugin.api.config.Property) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) Test(org.junit.Test)

Aggregations

Property (com.thoughtworks.go.plugin.api.config.Property)26 Test (org.junit.Test)15 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)13 TaskConfigProperty (com.thoughtworks.go.plugin.api.task.TaskConfigProperty)8 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)4 TaskProperty (com.thoughtworks.go.domain.TaskProperty)3 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)3 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)3 ArrayList (java.util.ArrayList)3 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)2 Configuration (com.thoughtworks.go.domain.config.Configuration)2 GoPluginDescriptor (com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor)2 PluginConfiguration (com.thoughtworks.go.server.ui.plugins.PluginConfiguration)2 HashMap (java.util.HashMap)2 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)1 PluginSettingsProperty (com.thoughtworks.go.plugin.access.common.settings.PluginSettingsProperty)1 GoPluginApiRequest (com.thoughtworks.go.plugin.api.request.GoPluginApiRequest)1 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)1 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)1 GoCipher (com.thoughtworks.go.security.GoCipher)1