Search in sources :

Example 6 with ConfigSaveValidationContext

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

the class P4MaterialConfigTest method shouldThrowErrorsIfBothPasswordAndEncryptedPasswordAreProvided.

@Test
public void shouldThrowErrorsIfBothPasswordAndEncryptedPasswordAreProvided() {
    P4MaterialConfig materialConfig = new P4MaterialConfig("foo/bar, 80", "password", "encryptedPassword", new GoCipher());
    materialConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(materialConfig.errors().on("password"), is("You may only specify `password` or `encrypted_password`, not both!"));
    assertThat(materialConfig.errors().on("encryptedPassword"), is("You may only specify `password` or `encrypted_password`, not both!"));
}
Also used : GoCipher(com.thoughtworks.go.security.GoCipher) ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) Test(org.junit.Test)

Example 7 with ConfigSaveValidationContext

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

the class P4MaterialConfigTest method shouldValidateWhetherTheEncryptedPasswordIsCorrect.

@Test
public void shouldValidateWhetherTheEncryptedPasswordIsCorrect() {
    P4MaterialConfig materialConfig = new P4MaterialConfig("foo/bar, 80", "", "encryptedPassword", new GoCipher());
    materialConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(materialConfig.errors().on("encryptedPassword"), is("Encrypted password value for P4 material with serverAndPort 'foo/bar, 80' is invalid. This usually happens when the cipher text is modified to have an invalid value."));
}
Also used : GoCipher(com.thoughtworks.go.security.GoCipher) ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) Test(org.junit.Test)

Example 8 with ConfigSaveValidationContext

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

the class P4MaterialConfigTest method assertNoError.

private void assertNoError(String port, String view, String expectedKeyForError) {
    P4MaterialConfig p4MaterialConfig = new P4MaterialConfig(port, view);
    p4MaterialConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(p4MaterialConfig.errors().on(expectedKeyForError), is(nullValue()));
}
Also used : ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext)

Example 9 with ConfigSaveValidationContext

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

the class P4MaterialConfigTest method assertError.

private void assertError(String port, String view, String expectedKeyForError, String expectedErrorMessage) {
    P4MaterialConfig p4MaterialConfig = new P4MaterialConfig(port, view);
    p4MaterialConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(p4MaterialConfig.errors().on(expectedKeyForError), is(expectedErrorMessage));
}
Also used : ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext)

Example 10 with ConfigSaveValidationContext

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

the class SvnMaterialConfigTest method validate_shouldEnsureUrlIsNotBlank.

@Test
public void validate_shouldEnsureUrlIsNotBlank() {
    SvnMaterialConfig svnMaterialConfig = new SvnMaterialConfig("", "", "", false);
    svnMaterialConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(svnMaterialConfig.errors().on(SvnMaterialConfig.URL), is("URL cannot be blank"));
}
Also used : 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