use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class ServerConfigServiceIntegrationTest method shouldNotUpdateWhenEmailIsInvalid.
@Test
public void shouldNotUpdateWhenEmailIsInvalid() {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
serverConfigService.updateServerConfig(new MailHost("boo", 1, "username", "password", true, true, "from", "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("From address is not a valid email address."));
assertThat(goConfigService.getMailHost(), is(new MailHost(new GoCipher())));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class ServerConfigServiceIntegrationTest method updateServerConfig_ShouldFailWhenAllowAutoLoginIsTurnedOffWithNoAdminsRemaining.
@Test
public void updateServerConfig_ShouldFailWhenAllowAutoLoginIsTurnedOffWithNoAdminsRemaining() throws IOException {
configHelper.enableSecurity();
userService.deleteAll();
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
serverConfigService.updateServerConfig(new MailHost(new GoCipher()), "artifacts", null, null, "42", false, "http://site_url", "https://secure_site_url", "default", result, goConfigDao.md5OfConfigFile());
assertThat(result.isSuccessful(), is(false));
assertThat(result.message(localizer), containsString("Cannot disable auto login with no admins enabled."));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class SvnMaterialTest method shouldErrorOutIfDecryptionFails.
@Test
public void shouldErrorOutIfDecryptionFails() throws InvalidCipherTextException {
GoCipher mockGoCipher = mock(GoCipher.class);
String fakeCipherText = "fake cipher text";
when(mockGoCipher.decrypt(fakeCipherText)).thenThrow(new InvalidCipherTextException("exception"));
SvnMaterial material = new SvnMaterial("/foo", "username", null, false, mockGoCipher);
ReflectionUtil.setField(material, "encryptedPassword", fakeCipherText);
try {
material.getPassword();
fail("Should have thrown up");
} catch (Exception e) {
assertThat(e.getMessage(), is("Could not decrypt the password to get the real password"));
}
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class TfsMaterialConfigUpdateTest method shouldDecryptTfsPassword.
@Test
public void shouldDecryptTfsPassword() throws Exception {
GoCipher mockGoCipher = mock(GoCipher.class);
when(mockGoCipher.decrypt("encrypted")).thenReturn("password");
TfsMaterialConfig materialConfig = new TfsMaterialConfig(mockGoCipher, new UrlArgument("http://10.4.4.101:8080/tfs/Sample"), "loser", "CORPORATE", "secret", "walk_this_path");
ReflectionUtil.setField(materialConfig, "encryptedPassword", "encrypted");
materialConfig.ensureEncrypted();
assertThat(materialConfig.getPassword(), is("password"));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class TfsMaterialConfigUpdateTest method shouldEncryptTfsPasswordAndMarkPasswordAsNull.
@Test
public void shouldEncryptTfsPasswordAndMarkPasswordAsNull() throws Exception {
GoCipher mockGoCipher = mock(GoCipher.class);
when(mockGoCipher.encrypt("password")).thenReturn("encrypted");
TfsMaterialConfig materialConfig = new TfsMaterialConfig(mockGoCipher, new UrlArgument("http://10.4.4.101:8080/tfs/Sample"), "loser", "CORPORATE", "password", "walk_this_path");
materialConfig.ensureEncrypted();
assertThat(materialConfig.getPassword(), is(nullValue()));
assertThat(materialConfig.getEncryptedPassword(), is("encrypted"));
}
Aggregations