Search in sources :

Example 1 with ConfigSaveValidationContext

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

the class HgMaterialConfigTest method validate_shouldEnsureUrlIsNotBlank.

@Test
public void validate_shouldEnsureUrlIsNotBlank() {
    HgMaterialConfig hgMaterialConfig = new HgMaterialConfig("", null);
    hgMaterialConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(hgMaterialConfig.errors().on(HgMaterialConfig.URL), is("URL cannot be blank"));
}
Also used : ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) Test(org.junit.Test)

Example 2 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 3 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 4 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 5 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)

Aggregations

ConfigSaveValidationContext (com.thoughtworks.go.config.ConfigSaveValidationContext)38 Test (org.junit.Test)18 Test (org.junit.jupiter.api.Test)10 GoCipher (com.thoughtworks.go.security.GoCipher)9 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)7 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)5 PipelineConfigSaveValidationContext (com.thoughtworks.go.config.PipelineConfigSaveValidationContext)3 ConfigErrors (com.thoughtworks.go.domain.ConfigErrors)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 MingleConfig (com.thoughtworks.go.config.MingleConfig)2 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)2 AgentConfig (com.thoughtworks.go.config.AgentConfig)1 Agents (com.thoughtworks.go.config.Agents)1 ElasticProfiles (com.thoughtworks.go.config.elastic.ElasticProfiles)1 SCM (com.thoughtworks.go.domain.scm.SCM)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1