use of com.thoughtworks.go.config.rules.RuleAwarePluginProfile in project gocd by gocd.
the class ConfigRepoConfigTest method newPluginProfile.
@Override
protected RuleAwarePluginProfile newPluginProfile(String id, String pluginId, ConfigurationProperty... configurationProperties) {
RuleAwarePluginProfile profile = new ConfigRepoConfig().setId(id).setPluginId(pluginId);
profile.addConfigurations(Arrays.asList(configurationProperties));
((ConfigRepoConfig) profile).setRepo(new GitMaterialConfig());
return profile;
}
use of com.thoughtworks.go.config.rules.RuleAwarePluginProfile in project gocd by gocd.
the class AbstractRuleAwarePluginProfileTest method shouldValidateConfigPropertyNameUniqueness.
@Test
public void shouldValidateConfigPropertyNameUniqueness() throws Exception {
ConfigurationProperty prop1 = ConfigurationPropertyMother.create("USERNAME");
ConfigurationProperty prop2 = ConfigurationPropertyMother.create("USERNAME");
RuleAwarePluginProfile profile = newPluginProfile("docker.unit-test", "cd.go.elastic-agent.docker", prop1, prop2);
profile.validate(getValidationContext(profile));
assertThat(profile.errors().size()).isEqualTo(0);
ConfigurationProperty configProp1 = profile.getConfiguration().get(0);
ConfigurationProperty configProp2 = profile.getConfiguration().get(1);
assertThat(configProp1.errors().size()).isEqualTo(1);
assertThat(configProp2.errors().size()).isEqualTo(1);
assertThat(configProp1.errors().on("configurationKey")).isEqualTo(format("Duplicate key 'USERNAME' found for %s 'docker.unit-test'", getObjectDescription()));
assertThat(configProp2.errors().on("configurationKey")).isEqualTo(format("Duplicate key 'USERNAME' found for %s 'docker.unit-test'", getObjectDescription()));
}
use of com.thoughtworks.go.config.rules.RuleAwarePluginProfile in project gocd by gocd.
the class AbstractRuleAwarePluginProfileTest method shouldNotAllowNullPluginIdOrProfileId.
@Test
public void shouldNotAllowNullPluginIdOrProfileId() throws Exception {
RuleAwarePluginProfile profile = newPluginProfile(null, null);
profile.validate(getValidationContext(profile));
assertThat(profile.errors().size()).isEqualTo(2);
assertThat(profile.errors().on("pluginId")).isEqualTo(format("%s cannot have a blank plugin id.", getObjectDescription()));
assertThat(profile.errors().on("id")).isEqualTo(format("%s cannot have a blank id.", getObjectDescription()));
}
use of com.thoughtworks.go.config.rules.RuleAwarePluginProfile in project gocd by gocd.
the class AbstractRuleAwarePluginProfileTest method shouldValidatePluginIdPattern.
@Test
public void shouldValidatePluginIdPattern() throws Exception {
RuleAwarePluginProfile profile = newPluginProfile("!123", "docker");
profile.validate(getValidationContext(profile));
assertThat(profile.errors().size()).isEqualTo(1);
assertThat(profile.errors().on("id")).isEqualTo("Invalid id '!123'. This must be alphanumeric and can contain underscores, hyphens and periods (however, it cannot start with a period). The maximum allowed length is 255 characters.");
}
Aggregations