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"));
}
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!"));
}
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()));
}
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."));
}
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));
}
Aggregations