Search in sources :

Example 21 with ConfigSaveValidationContext

use of com.thoughtworks.go.config.ConfigSaveValidationContext in project gocd by gocd.

the class MingleConfigTest method shouldReturnInvalidIfTheURLIsNotAHTTPSURL.

@Test
public void shouldReturnInvalidIfTheURLIsNotAHTTPSURL() {
    MingleConfig mingleConfig = new MingleConfig("http://some-mingle-instance", "go");
    mingleConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(mingleConfig.errors().isEmpty(), is(false));
    assertThat(mingleConfig.errors().on(MingleConfig.PROJECT_IDENTIFIER), is(nullValue()));
    assertThat(mingleConfig.errors().on(MingleConfig.BASE_URL), is("Should be a URL starting with https://"));
}
Also used : ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) MingleConfig(com.thoughtworks.go.config.MingleConfig) Test(org.junit.Test)

Example 22 with ConfigSaveValidationContext

use of com.thoughtworks.go.config.ConfigSaveValidationContext in project gocd by gocd.

the class PackageMaterialConfigTest method shouldAddErrorIfMaterialDoesNotHaveAPackageId.

@Test
public void shouldAddErrorIfMaterialDoesNotHaveAPackageId() throws Exception {
    PackageMaterialConfig packageMaterialConfig = new PackageMaterialConfig();
    packageMaterialConfig.validateConcreteMaterial(new ConfigSaveValidationContext(null, null));
    assertThat(packageMaterialConfig.errors().getAll().size(), is(1));
    assertThat(packageMaterialConfig.errors().on(PackageMaterialConfig.PACKAGE_ID), is("Please select a repository and package"));
}
Also used : PipelineConfigSaveValidationContext(com.thoughtworks.go.config.PipelineConfigSaveValidationContext) ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) Test(org.junit.Test)

Example 23 with ConfigSaveValidationContext

use of com.thoughtworks.go.config.ConfigSaveValidationContext in project gocd by gocd.

the class SvnMaterialConfigTest method validate_shouldEnsureMaterialNameIsValid.

@Test
public void validate_shouldEnsureMaterialNameIsValid() {
    SvnMaterialConfig svnMaterialConfig = new SvnMaterialConfig("/foo", "", "", false);
    svnMaterialConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(svnMaterialConfig.errors().on(SvnMaterialConfig.MATERIAL_NAME), is(nullValue()));
    svnMaterialConfig.setName(new CaseInsensitiveString(".bad-name-with-dot"));
    svnMaterialConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(svnMaterialConfig.errors().on(SvnMaterialConfig.MATERIAL_NAME), is("Invalid material name '.bad-name-with-dot'. This must be alphanumeric and can contain underscores and periods (however, it cannot start with a period). The maximum allowed length is 255 characters."));
}
Also used : ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 24 with ConfigSaveValidationContext

use of com.thoughtworks.go.config.ConfigSaveValidationContext in project gocd by gocd.

the class PluggableSCMMaterialConfigTest method shouldAddErrorIDestinationIsNotValid.

@Test
public void shouldAddErrorIDestinationIsNotValid() throws Exception {
    ConfigSaveValidationContext configSaveValidationContext = mock(ConfigSaveValidationContext.class);
    SCM scmConfig = mock(SCM.class);
    when(configSaveValidationContext.findScmById(anyString())).thenReturn(scmConfig);
    when(scmConfig.doesPluginExist()).thenReturn(true);
    PluggableSCMMaterialConfig pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig(null, scmConfig, "/usr/home", null);
    pluggableSCMMaterialConfig.setScmId("scm-id");
    pluggableSCMMaterialConfig.validateConcreteMaterial(configSaveValidationContext);
    assertThat(pluggableSCMMaterialConfig.errors().getAll().size(), is(1));
    assertThat(pluggableSCMMaterialConfig.errors().on(PluggableSCMMaterialConfig.FOLDER), is("Dest folder '/usr/home' is not valid. It must be a sub-directory of the working folder."));
    pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig(null, scmConfig, "./../crap", null);
    pluggableSCMMaterialConfig.setScmId("scm-id");
    pluggableSCMMaterialConfig.validateConcreteMaterial(configSaveValidationContext);
    assertThat(pluggableSCMMaterialConfig.errors().getAll().size(), is(2));
    assertThat(pluggableSCMMaterialConfig.errors().on(PluggableSCMMaterialConfig.FOLDER), is("Invalid directory name './../crap'. It should be a valid relative path."));
}
Also used : PipelineConfigSaveValidationContext(com.thoughtworks.go.config.PipelineConfigSaveValidationContext) ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) SCM(com.thoughtworks.go.domain.scm.SCM) Test(org.junit.Test)

Example 25 with ConfigSaveValidationContext

use of com.thoughtworks.go.config.ConfigSaveValidationContext in project gocd by gocd.

the class PluggableSCMMaterialConfigTest method shouldAddErrorIfMaterialDoesNotHaveASCMId.

@Test
public void shouldAddErrorIfMaterialDoesNotHaveASCMId() throws Exception {
    PluggableSCMMaterialConfig pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig();
    pluggableSCMMaterialConfig.validateConcreteMaterial(new ConfigSaveValidationContext(null, null));
    assertThat(pluggableSCMMaterialConfig.errors().getAll().size(), is(1));
    assertThat(pluggableSCMMaterialConfig.errors().on(PluggableSCMMaterialConfig.SCM_ID), is("Please select a SCM"));
}
Also used : PipelineConfigSaveValidationContext(com.thoughtworks.go.config.PipelineConfigSaveValidationContext) ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) Test(org.junit.Test)

Aggregations

ConfigSaveValidationContext (com.thoughtworks.go.config.ConfigSaveValidationContext)28 Test (org.junit.Test)26 GoCipher (com.thoughtworks.go.security.GoCipher)9 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)7 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)3 PipelineConfigSaveValidationContext (com.thoughtworks.go.config.PipelineConfigSaveValidationContext)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 MingleConfig (com.thoughtworks.go.config.MingleConfig)2 SCM (com.thoughtworks.go.domain.scm.SCM)1