Search in sources :

Example 91 with SvnMaterial

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."));
    }
}
Also used : InvalidCipherTextException(org.bouncycastle.crypto.InvalidCipherTextException) GoCipher(com.thoughtworks.go.security.GoCipher) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) InvalidCipherTextException(org.bouncycastle.crypto.InvalidCipherTextException) Test(org.junit.Test)

Example 92 with SvnMaterial

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"));
}
Also used : GoCipher(com.thoughtworks.go.security.GoCipher) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Test(org.junit.Test)

Example 93 with SvnMaterial

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"));
}
Also used : GoCipher(com.thoughtworks.go.security.GoCipher) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Test(org.junit.Test)

Example 94 with SvnMaterial

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"));
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) Test(org.junit.Test)

Example 95 with SvnMaterial

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")));
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Test(org.junit.Test)

Aggregations

SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)140 Test (org.junit.Test)111 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)44 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)39 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)22 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)21 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)20 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)20 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)18 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)17 Material (com.thoughtworks.go.domain.materials.Material)16 Modification (com.thoughtworks.go.domain.materials.Modification)16 Materials (com.thoughtworks.go.config.materials.Materials)13 Date (java.util.Date)11 Username (com.thoughtworks.go.server.domain.Username)10 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)9 File (java.io.File)8 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)8 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)7 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)7