use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnMaterialMockitoTest method shouldNotDeleteWorkingDirIfSvnRepositoryUsesFileProtocol.
@Test
public void shouldNotDeleteWorkingDirIfSvnRepositoryUsesFileProtocol() throws IOException {
Subversion subversion = mock(Subversion.class);
when(subversion.getUserName()).thenReturn("");
when(subversion.getPassword()).thenReturn("");
when(subversion.isCheckExternals()).thenReturn(false);
File workingCopy = createSvnWorkingCopy(true);
when(subversion.workingRepositoryUrl(workingCopy)).thenReturn(workingCopy.getPath());
String url = "file://" + workingCopy.getPath();
when(subversion.getUrl()).thenReturn(new UrlArgument(url));
SvnMaterial svnMaterial = SvnMaterial.createSvnMaterialWithMock(subversion);
svnMaterial.setUrl(url);
svnMaterial.updateTo(outputStreamConsumer, workingCopy, new RevisionContext(revision), new TestSubprocessExecutionContext());
assertThat(workingCopy.exists(), is(true));
verify(subversion).updateTo(outputStreamConsumer, workingCopy, revision);
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnMaterialTest method shouldSerializeAndDeserializeCorrectly.
@Test
public void shouldSerializeAndDeserializeCorrectly() throws Exception {
final SvnMaterial material1 = MaterialsMother.svnMaterial("url1", "foo");
ByteArrayOutputStream buf = new ByteArrayOutputStream();
ObjectOutputStream serialized = new ObjectOutputStream(buf);
serialized.writeObject(material1);
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buf.toByteArray()));
assertThat(in.readObject(), is(material1));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnMaterialTest method shouldGeneratePipelineUniqueFingerprintBasedOnFingerprintAndDest.
@Test
public void shouldGeneratePipelineUniqueFingerprintBasedOnFingerprintAndDest() throws Exception {
SvnMaterial one = new SvnMaterial("url", "username", "password", true, "folder1");
SvnMaterial two = new SvnMaterial("url", "username", "password", true, "folder2");
assertThat(one.getPipelineUniqueFingerprint(), is(Matchers.not(two.getFingerprint())));
assertThat(one.getPipelineUniqueFingerprint(), is(DigestUtils.sha256Hex("type=SvnMaterial<|>url=url<|>username=username<|>checkExternals=true<|>dest=folder1")));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnMaterialTest method shouldGetAttributesWithSecureFields.
@Test
public void shouldGetAttributesWithSecureFields() {
SvnMaterial material = new SvnMaterial("http://username:password@svnrepo.com", "user", "password", true);
Map<String, Object> attributes = material.getAttributes(true);
assertThat(attributes.get("type"), is("svn"));
Map<String, Object> configuration = (Map<String, Object>) attributes.get("svn-configuration");
assertThat(configuration.get("url"), is("http://username:password@svnrepo.com"));
assertThat(configuration.get("username"), is("user"));
assertThat(configuration.get("password"), is("password"));
assertThat(configuration.get("check-externals"), is(true));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class SvnMaterialTest method shouldGenerateFingerprintBasedOnSqlCriteria.
@Test
public void shouldGenerateFingerprintBasedOnSqlCriteria() throws Exception {
SvnMaterial one = new SvnMaterial("url", "username", "password", true);
SvnMaterial two = new SvnMaterial("url", "username", "password", false);
assertThat(one.getFingerprint(), is(Matchers.not(two.getFingerprint())));
assertThat(one.getFingerprint(), is(DigestUtils.sha256Hex("type=SvnMaterial<|>url=url<|>username=username<|>checkExternals=true")));
}
Aggregations