Search in sources :

Example 86 with SvnMaterial

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

the class SvnCommandTest method buildMockSvnMaterial.

private SvnMaterial buildMockSvnMaterial(String url, String username, String password) {
    final SvnMaterial svnMaterial = mock(SvnMaterial.class);
    when(svnMaterial.getUrl()).thenReturn(url);
    when(svnMaterial.getUserName()).thenReturn(username);
    when(svnMaterial.getPassword()).thenReturn(password);
    return svnMaterial;
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial)

Example 87 with SvnMaterial

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

the class SvnMaterialTest method shouldBeAbleToConvertToJson.

@Test
public void shouldBeAbleToConvertToJson() {
    SvnMaterial material = MaterialsMother.svnMaterial("url");
    Map<String, Object> json = new LinkedHashMap<>();
    material.toJson(json, revision);
    JsonValue jsonValue = from(json);
    assertThat(jsonValue.getString("scmType"), is("Subversion"));
    assertThat(new File(jsonValue.getString("location")), is(new File(material.getUrl())));
    assertThat(jsonValue.getString("action"), is("Modified"));
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) JsonValue(com.thoughtworks.go.util.JsonValue) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 88 with SvnMaterial

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

the class SvnMaterialTest method shouldReturnNotEqualsWhenCheckExternalsIsChanged.

@Test
public void shouldReturnNotEqualsWhenCheckExternalsIsChanged() throws Exception {
    SvnMaterial material = MaterialsMother.svnMaterial("url", "svnDir", null, null, true, "*.txt");
    SvnMaterial other = MaterialsMother.svnMaterial("url", "svnDir", null, null, false, "*.txt");
    assertThat(material, is(not(other)));
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Test(org.junit.Test)

Example 89 with SvnMaterial

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

the class SvnMaterialTest method shouldApplyThePatternDirectly.

@Test
public void shouldApplyThePatternDirectly() throws Exception {
    SvnMaterial material = MaterialsMother.svnMaterial();
    assertThat(material.matches("/a.doc", "/a.doc"), is(true));
}
Also used : SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Test(org.junit.Test)

Example 90 with SvnMaterial

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

the class SvnMaterialTest method shouldNotDecryptSvnPasswordIfPasswordIsNotNull.

@Test
public void shouldNotDecryptSvnPasswordIfPasswordIsNotNull() throws Exception {
    GoCipher mockGoCipher = mock(GoCipher.class);
    when(mockGoCipher.encrypt("password")).thenReturn("encrypted");
    when(mockGoCipher.decrypt("encrypted")).thenReturn("password");
    SvnMaterial material = new SvnMaterial("/foo", "username", "password", false, mockGoCipher);
    material.ensureEncrypted();
    when(mockGoCipher.encrypt("new_password")).thenReturn("new_encrypted");
    material.setPassword("new_password");
    when(mockGoCipher.decrypt("new_encrypted")).thenReturn("new_password");
    assertThat(material.getPassword(), is("new_password"));
}
Also used : GoCipher(com.thoughtworks.go.security.GoCipher) 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