use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class SCMTest method shouldNotDisplayEmptyValuesInGetConfigForDisplay.
@Test
public void shouldNotDisplayEmptyValuesInGetConfigForDisplay() throws Exception {
SCMMetadataStore.getInstance().addMetadataFor("plugin-id", new SCMConfigurations(), null);
Configuration configuration = new Configuration(create("rk1", false, ""), create("rk2", false, "some-non-empty-value"), create("rk3", false, null));
SCM scm = SCMMother.create("scm", "scm-name", "plugin-id", "1.0", configuration);
assertThat(scm.getConfigForDisplay(), is("[rk2=some-non-empty-value]"));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class SCMTest method shouldDisplayAllNonSecureFieldsInGetConfigForDisplayWhenPluginDoesNotExist.
@Test
public void shouldDisplayAllNonSecureFieldsInGetConfigForDisplayWhenPluginDoesNotExist() {
Configuration configuration = new Configuration(create("key1", false, "value1"), create("key2", true, "value2"), create("key3", false, "value3"));
SCM scm = SCMMother.create("scm", "scm-name", "some-plugin-which-does-not-exist", "1.0", configuration);
assertThat(scm.getConfigForDisplay(), is("WARNING! Plugin missing. [key1=value1, key3=value3]"));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class SCMTest method shouldMakeConfigurationSecureBasedOnMetadata.
@Test
public void shouldMakeConfigurationSecureBasedOnMetadata() throws Exception {
GoCipher goCipher = new GoCipher();
// meta data of SCM
SCMConfigurations scmConfiguration = new SCMConfigurations();
scmConfiguration.add(new SCMConfiguration("key1").with(SECURE, true));
scmConfiguration.add(new SCMConfiguration("key2").with(SECURE, false));
SCMMetadataStore.getInstance().addMetadataFor("plugin-id", scmConfiguration, null);
/*secure property is set based on metadata*/
ConfigurationProperty secureProperty = new ConfigurationProperty(new ConfigurationKey("key1"), new ConfigurationValue("value1"), null, goCipher);
ConfigurationProperty nonSecureProperty = new ConfigurationProperty(new ConfigurationKey("key2"), new ConfigurationValue("value2"), null, goCipher);
SCM scm = SCMMother.create("scm-id", "scm-name", "plugin-id", "1.0", new Configuration(secureProperty, nonSecureProperty));
scm.applyPluginMetadata();
// assert SCM properties
assertThat(secureProperty.isSecure(), is(true));
assertThat(secureProperty.getEncryptedConfigurationValue(), is(notNullValue()));
assertThat(secureProperty.getEncryptedValue(), is(goCipher.encrypt("value1")));
assertThat(nonSecureProperty.isSecure(), is(false));
assertThat(nonSecureProperty.getValue(), is("value2"));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class SCMTest method shouldValidateUniqueKeysInConfiguration.
@Test
public void shouldValidateUniqueKeysInConfiguration() {
ConfigurationProperty one = create("one", false, "value1");
ConfigurationProperty duplicate1 = create("ONE", false, "value2");
ConfigurationProperty duplicate2 = create("ONE", false, "value3");
ConfigurationProperty two = create("two", false, null);
SCM scm = new SCM();
scm.setConfiguration(new Configuration(one, duplicate1, duplicate2, two));
scm.setName("git");
scm.validate(null);
assertThat(one.errors().isEmpty(), is(false));
assertThat(one.errors().getAllOn(ConfigurationProperty.CONFIGURATION_KEY).contains("Duplicate key 'ONE' found for SCM 'git'"), is(true));
assertThat(duplicate1.errors().isEmpty(), is(false));
assertThat(one.errors().getAllOn(ConfigurationProperty.CONFIGURATION_KEY).contains("Duplicate key 'ONE' found for SCM 'git'"), is(true));
assertThat(duplicate2.errors().isEmpty(), is(false));
assertThat(one.errors().getAllOn(ConfigurationProperty.CONFIGURATION_KEY).contains("Duplicate key 'ONE' found for SCM 'git'"), is(true));
assertThat(two.errors().isEmpty(), is(true));
}
use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.
the class SCMTest method shouldCheckForFieldAssignments.
@Test
public void shouldCheckForFieldAssignments() {
Configuration configuration = new Configuration();
SCM scm = SCMMother.create("id", "name", "plugin-id", "version", configuration);
assertThat(scm.getId(), is("id"));
assertThat(scm.getName(), is("name"));
assertThat(scm.getPluginConfiguration().getId(), is("plugin-id"));
assertThat(scm.getPluginConfiguration().getVersion(), is("version"));
assertThat(scm.getConfiguration().listOfConfigKeys().isEmpty(), is(true));
}
Aggregations