use of com.thoughtworks.go.config.materials.svn.SvnMaterial 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 com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnMaterialTest method shouldDecryptSvnPassword.
@Test
public void shouldDecryptSvnPassword() throws Exception {
GoCipher mockGoCipher = mock(GoCipher.class);
when(mockGoCipher.decrypt("encrypted")).thenReturn("password");
SvnMaterial material = new SvnMaterial("/foo", "username", null, false, mockGoCipher);
ReflectionUtil.setField(material, "encryptedPassword", "encrypted");
material.ensureEncrypted();
assertThat(material.getPassword(), is("password"));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnMaterialTest method shouldEncryptSvnPasswordAndMarkPasswordAsNull.
@Test
public void shouldEncryptSvnPasswordAndMarkPasswordAsNull() throws Exception {
GoCipher mockGoCipher = mock(GoCipher.class);
when(mockGoCipher.encrypt("password")).thenReturn("encrypted");
SvnMaterial material = new SvnMaterial("/foo", "username", "password", false, mockGoCipher);
material.ensureEncrypted();
assertThat(material.getPassword(), is(nullValue()));
assertThat(material.getEncryptedPassword(), is("encrypted"));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnMaterialTest method shouldCopyOverPasswordWhenConvertingToConfig.
@Test
public void shouldCopyOverPasswordWhenConvertingToConfig() throws Exception {
SvnMaterial material = new SvnMaterial("abc", "def", "ghi", false);
SvnMaterialConfig config = (SvnMaterialConfig) material.config();
assertThat(config.getEncryptedPassword(), is(not(Matchers.nullValue())));
assertThat(config.getPassword(), is("ghi"));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnMaterialTest method shouldNotDisplayPasswordInStringRepresentation.
@Test
public void shouldNotDisplayPasswordInStringRepresentation() {
SvnMaterial svn = new SvnMaterial("my-url", "user", "loser", false);
assertThat(svn.toString(), not(containsString("loser")));
svn = new SvnMaterial("https://user:loser@foo.bar/baz?quux=bang", "user", "loser", false);
assertThat(svn.toString(), not(containsString("loser")));
}
Aggregations