use of com.thoughtworks.go.domain.config.ConfigurationProperty 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.ConfigurationProperty in project gocd by gocd.
the class RoleConfigCommand method validate.
private void validate(CruiseConfig preprocessedConfig) {
if (role instanceof PluginRoleConfig) {
PluginRoleConfig role = (PluginRoleConfig) this.role;
PluginRoleConfig preprocessedRole = (PluginRoleConfig) this.preprocessedRole;
SecurityAuthConfig securityAuthConfig = preprocessedConfig.server().security().securityAuthConfigs().find(role.getAuthConfigId());
if (securityAuthConfig == null) {
role.addError("authConfigId", "No such security auth configuration present " + role.getAuthConfigId());
return;
}
try {
ValidationResult result = extension.validateRoleConfiguration(securityAuthConfig.getPluginId(), role.getConfigurationAsMap(true));
if (!result.isSuccessful()) {
for (ValidationError validationError : result.getErrors()) {
ConfigurationProperty property = preprocessedRole.getProperty(validationError.getKey());
if (property == null) {
role.addNewConfiguration(validationError.getKey(), false);
preprocessedRole.addNewConfiguration(validationError.getKey(), false);
property = preprocessedRole.getProperty(validationError.getKey());
}
property.addError(validationError.getKey(), validationError.getMessage());
}
}
} catch (PluginNotFoundException e) {
role.addError("authConfigId", "Could not find a security authorization config with id '" + role.getAuthConfigId() + "'.");
}
}
}
use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class PackageMaterialPollerTest method assertConfiguration.
private void assertConfiguration(com.thoughtworks.go.plugin.api.config.Configuration configurationsSentToPlugin, Configuration configurationInMaterial) {
assertThat(configurationsSentToPlugin.size(), is(configurationInMaterial.size()));
for (ConfigurationProperty property : configurationInMaterial) {
Property configuration = configurationsSentToPlugin.get(property.getConfigurationKey().getName());
assertThat(configuration.getValue(), is(property.getValue()));
}
}
use of com.thoughtworks.go.domain.config.ConfigurationProperty in project gocd by gocd.
the class PluggableSCMMaterialPollerTest method setup.
@Before
public void setup() {
initMocks(this);
ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
ConfigurationProperty k2 = ConfigurationPropertyMother.create("k2", true, "v2");
SCM scmConfig = SCMMother.create("scm-id", "scm-name", "plugin-id", "1.0", new Configuration(k1, k2));
material = new PluggableSCMMaterial();
material.setSCMConfig(scmConfig);
MaterialInstance materialInstance = material.createMaterialInstance();
Map<String, String> data = new HashMap<>();
data.put("mk-1", "mv-1");
materialInstance.setAdditionalData(JsonHelper.toJsonString(data));
when(materialRepository.findMaterialInstance(material)).thenReturn(materialInstance);
poller = new PluggableSCMMaterialPoller(materialRepository, scmExtension, transactionTemplate);
scmConfiguration = ArgumentCaptor.forClass(SCMPropertyConfiguration.class);
materialData = ArgumentCaptor.forClass(Map.class);
flyweightFolderPath = new File(System.getProperty("java.io.tmpdir")).getAbsolutePath();
}
Aggregations