use of org.bouncycastle.crypto.InvalidCipherTextException in project gocd by gocd.
the class SvnMaterialTest method shouldErrorOutIfEncryptionFails.
@Test
public void shouldErrorOutIfEncryptionFails() throws Exception {
GoCipher mockGoCipher = mock(GoCipher.class);
when(mockGoCipher.encrypt("password")).thenThrow(new InvalidCipherTextException("exception"));
try {
new SvnMaterial("/foo", "username", "password", false, mockGoCipher);
fail("Should have thrown up");
} catch (Exception e) {
assertThat(e.getMessage(), is("Password encryption failed. Please verify your cipher key."));
}
}
use of org.bouncycastle.crypto.InvalidCipherTextException in project gocd by gocd.
the class TfsMaterialConfigUpdateTest method shouldErrorOutIfEncryptionFails.
@Test
public void shouldErrorOutIfEncryptionFails() throws Exception {
GoCipher mockGoCipher = mock(GoCipher.class);
when(mockGoCipher.encrypt("password")).thenThrow(new InvalidCipherTextException("exception"));
try {
new TfsMaterialConfig(mockGoCipher, new UrlArgument("http://10.4.4.101:8080/tfs/Sample"), "loser", "CORPORATE", "password", "walk_this_path");
fail("Should have thrown up");
} catch (Exception e) {
assertThat(e.getMessage(), is("Password encryption failed. Please verify your cipher key."));
}
}
use of org.bouncycastle.crypto.InvalidCipherTextException in project gocd by gocd.
the class TfsMaterialTest method shouldErrorOutIfEncryptionFails.
@Test
public void shouldErrorOutIfEncryptionFails() throws Exception {
GoCipher mockGoCipher = mock(GoCipher.class);
when(mockGoCipher.encrypt("password")).thenThrow(new InvalidCipherTextException("exception"));
try {
new TfsMaterial(mockGoCipher, new UrlArgument("/foo"), "username", DOMAIN, "password", "");
fail("Should have thrown up");
} catch (Exception e) {
assertThat(e.getMessage(), is("Password encryption failed. Please verify your cipher key."));
}
}
use of org.bouncycastle.crypto.InvalidCipherTextException in project gocd by gocd.
the class TfsMaterialTest 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"));
TfsMaterial material = new TfsMaterial(mockGoCipher, new UrlArgument("/foo"), "username", DOMAIN, "password", "");
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 org.bouncycastle.crypto.InvalidCipherTextException in project gocd by gocd.
the class EnvrionmentVariableRepresenter method fromJSON.
public static EnvironmentVariableConfig fromJSON(JsonReader jsonReader) {
String name = jsonReader.getString("name");
Boolean secure = jsonReader.optBoolean("secure").orElse(false);
String value = secure ? jsonReader.optString("value").orElse(null) : jsonReader.getString("value");
String encryptedValue = jsonReader.optString("encrypted_value").orElse(null);
try {
EnvironmentVariableConfig environmentVariableConfig = new EnvironmentVariableConfig();
environmentVariableConfig.deserialize(name, value, secure, encryptedValue);
return environmentVariableConfig;
} catch (InvalidCipherTextException e) {
throw new InvalidGoCipherTextException(e.getMessage(), e);
}
}
Aggregations