use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class SvnMaterialConfigTest method shouldValidateWhetherTheEncryptedPasswordIsCorrect.
@Test
public void shouldValidateWhetherTheEncryptedPasswordIsCorrect() {
SvnMaterialConfig svnMaterialConfig = new SvnMaterialConfig(new UrlArgument("foo/bar"), "", "encryptedPassword", new GoCipher(), null, false, "folder");
svnMaterialConfig.validate(new ConfigSaveValidationContext(null));
assertThat(svnMaterialConfig.errors().on("encryptedPassword"), is("Encrypted password value for svn material with url 'foo/bar' is invalid. This usually happens when the cipher text is modified to have an invalid value."));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class SvnMaterialConfigTest method shouldThrowErrorsIfBothPasswordAndEncryptedPasswordAreProvided.
@Test
public void shouldThrowErrorsIfBothPasswordAndEncryptedPasswordAreProvided() {
SvnMaterialConfig svnMaterialConfig = new SvnMaterialConfig(new UrlArgument("foo/bar"), "password", "encryptedPassword", new GoCipher(), null, false, "folder");
svnMaterialConfig.validate(new ConfigSaveValidationContext(null));
assertThat(svnMaterialConfig.errors().on("password"), is("You may only specify `password` or `encrypted_password`, not both!"));
assertThat(svnMaterialConfig.errors().on("encryptedPassword"), is("You may only specify `password` or `encrypted_password`, not both!"));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class MagicalGoConfigXmlLoaderTest method shouldMigrateServerMailhostEncryptedPasswordWithNewlineAndSpaces_XslMigrationFrom88To90.
@Test
public void shouldMigrateServerMailhostEncryptedPasswordWithNewlineAndSpaces_XslMigrationFrom88To90() throws Exception {
String plainText = "something";
String encryptedValue = new GoCipher().encrypt(plainText);
String encryptedValueWithWhitespaceAndNewline = new StringBuilder(encryptedValue).insert(2, "\r\n" + " ").toString();
String content = config("<server artifactsdir='artifacts'>\n" + " <mailhost hostname='host' port='25' username='user' encryptedPassword='" + encryptedValueWithWhitespaceAndNewline + "' tls='false' from='user@domain.com' admin='admin@domain.com' />\n" + " </server>", 88);
CruiseConfig config = ConfigMigrator.loadWithMigration(content).config;
assertThat(config.server().mailHost().getPassword(), is(plainText));
assertThat(config.server().mailHost().getEncryptedPassword(), is(encryptedValue));
assertThat(config.server().mailHost().getHostName(), is("host"));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class ServerConfigServiceIntegrationTest method shouldUpdateServerConfig.
@Test
public void shouldUpdateServerConfig() throws InvalidCipherTextException {
MailHost mailHost = new MailHost("boo", 1, "username", "password", new GoCipher().encrypt("password"), true, true, "from@from.com", "admin@admin.com", new GoCipher());
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
serverConfigService.updateServerConfig(mailHost, "newArtifactsDir", 10.0, 20.0, "42", true, "http://site_url", "https://secure_site_url", "gist-repo/folder", result, goConfigDao.md5OfConfigFile());
assertThat(goConfigService.getMailHost(), is(mailHost));
assertThat(goConfigService.serverConfig().artifactsDir(), is("newArtifactsDir"));
assertThat(goConfigService.serverConfig().getSiteUrl().getUrl(), is("http://site_url"));
assertThat(goConfigService.serverConfig().getSecureSiteUrl().getUrl(), is("https://secure_site_url"));
assertThat(goConfigService.serverConfig().getJobTimeout(), is("42"));
assertThat(goConfigService.serverConfig().getPurgeStart(), is(10.0));
assertThat(goConfigService.serverConfig().getPurgeUpto(), is(20.0));
assertThat(goConfigService.serverConfig().getCommandRepositoryLocation(), is("gist-repo/folder"));
assertThat(result.isSuccessful(), is(true));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class ServerConfigServiceIntegrationTest method shouldNotUpdateWhenPortIsInvalid.
@Test
public void shouldNotUpdateWhenPortIsInvalid() {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
serverConfigService.updateServerConfig(new MailHost("boo", -1, "username", "password", true, true, "from@from.com", "admin@admin.com"), "artifacts", null, null, "42", true, "http://site_url", "https://secure_site_url", "default", result, goConfigDao.md5OfConfigFile());
assertThat(result.isSuccessful(), is(false));
assertThat(result.message(localizer), is("Invalid port."));
assertThat(goConfigService.getMailHost(), is(new MailHost(new GoCipher())));
}
Aggregations