use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class TfsMaterialTest method shouldGetLongDescriptionForMaterial.
@Test
public void shouldGetLongDescriptionForMaterial() {
TfsMaterial material = new TfsMaterial(new GoCipher(), new UrlArgument("http://url/"), "user", "domain", "password", "$project/path/");
assertThat(material.getLongDescription(), is("URL: http://url/, Username: user, Domain: domain, ProjectPath: $project/path/"));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class TfsMaterialTest method shouldReturnUrlForCommandLine_asUrl_IfSet.
@Test
public void shouldReturnUrlForCommandLine_asUrl_IfSet() {
TfsMaterial tfsMaterial = new TfsMaterial(new GoCipher(), new UrlArgument("http://foo:bar@my-url.com"), "loser", DOMAIN, "foo_bar_baz", "/dev/null");
assertThat(tfsMaterial.getUrl(), is("http://foo:bar@my-url.com"));
tfsMaterial = new TfsMaterial(new GoCipher(), null, "loser", DOMAIN, "foo_bar_baz", "/dev/null");
assertThat(tfsMaterial.getUrl(), is(nullValue()));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class TfsMaterialTest method shouldDecryptTfsPassword.
@Test
public void shouldDecryptTfsPassword() throws Exception {
GoCipher mockGoCipher = mock(GoCipher.class);
when(mockGoCipher.decrypt("encrypted")).thenReturn("password");
TfsMaterial tfsMaterial = new TfsMaterial(mockGoCipher, new UrlArgument("/foo"), "username", DOMAIN, null, "");
ReflectionUtil.setField(tfsMaterial, "encryptedPassword", "encrypted");
tfsMaterial.ensureEncrypted();
assertThat(tfsMaterial.getPassword(), is("password"));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class TfsMaterialTest method shouldGetAttributesWithoutSecureFields.
@Test
public void shouldGetAttributesWithoutSecureFields() {
TfsMaterial material = new TfsMaterial(new GoCipher(), new UrlArgument("http://username:password@tfsrepo.com"), "username", "domain", "password", "$project/path/");
Map<String, Object> attributes = material.getAttributes(false);
assertThat(attributes.get("type"), is("tfs"));
Map<String, Object> configuration = (Map<String, Object>) attributes.get("tfs-configuration");
assertThat(configuration.get("url"), is("http://username:******@tfsrepo.com"));
assertThat(configuration.get("domain"), is("domain"));
assertThat(configuration.get("username"), is("username"));
assertThat(configuration.get("password"), is(nullValue()));
assertThat(configuration.get("project-path"), is("$project/path/"));
}
use of com.thoughtworks.go.security.GoCipher in project gocd by gocd.
the class TfsMaterialTest method shouldErrorOutIfEncryptionFails.
@Test
public void shouldErrorOutIfEncryptionFails() throws Exception {
GoCipher mockGoCipher = mock(GoCipher.class);
when(mockGoCipher.encrypt("password")).thenThrow(new InvalidCipherTextException("exception"));
try {
new TfsMaterial(mockGoCipher, new UrlArgument("/foo"), "username", DOMAIN, "password", "");
fail("Should have thrown up");
} catch (Exception e) {
assertThat(e.getMessage(), is("Password encryption failed. Please verify your cipher key."));
}
}
Aggregations