Search in sources :

Example 56 with SvnMaterial

use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.

the class SvnMaterialTest method shouldNotUsePasswordForEquality.

@Test
public void shouldNotUsePasswordForEquality() {
    SvnMaterial svnBoozer = new SvnMaterial("foo.com", "loser", "boozer", true);
    SvnMaterial svnZooser = new SvnMaterial("foo.com", "loser", "zooser", true);
    assertThat(svnBoozer.hashCode(), is(svnZooser.hashCode()));
    assertThat(svnBoozer, is(svnZooser));
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Test(org.junit.Test)

Example 57 with SvnMaterial

use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.

the class SvnMaterialTest method shouldGetLongDescriptionForMaterial.

@Test
public void shouldGetLongDescriptionForMaterial() {
    SvnMaterial material = new SvnMaterial("http://url/", "user", "password", true, "folder");
    assertThat(material.getLongDescription(), is("URL: http://url/, Username: user, CheckExternals: true"));
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Test(org.junit.Test)

Example 58 with SvnMaterial

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

Example 59 with SvnMaterial

use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.

the class SvnMaterialTest method shouldReturnEqualsEvenIfPasswordsAreDifferent.

@Test
public void shouldReturnEqualsEvenIfPasswordsAreDifferent() throws Exception {
    SvnMaterial material = MaterialsMother.svnMaterial();
    material.setPassword("password");
    SvnMaterial other = MaterialsMother.svnMaterial();
    other.setPassword("password1");
    assertThat(material, is(other));
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Test(org.junit.Test)

Example 60 with SvnMaterial

use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.

the class SvnMaterialTest method shouldGetAttributesWithoutSecureFields.

@Test
public void shouldGetAttributesWithoutSecureFields() {
    SvnMaterial material = new SvnMaterial("http://username:password@svnrepo.com", "user", "password", true);
    Map<String, Object> attributes = material.getAttributes(false);
    assertThat(attributes.get("type"), is("svn"));
    Map<String, Object> configuration = (Map<String, Object>) attributes.get("svn-configuration");
    assertThat(configuration.get("url"), is("http://username:******@svnrepo.com"));
    assertThat(configuration.get("username"), is("user"));
    assertThat(configuration.get("password"), is(nullValue()));
    assertThat(configuration.get("check-externals"), is(true));
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) 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