use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.
the class TfsMaterialTest method shouldCopyOverPasswordWhenConvertingToConfig.
@Test
public void shouldCopyOverPasswordWhenConvertingToConfig() throws Exception {
TfsMaterial material = new TfsMaterial(new GoCipher(), new UrlArgument("http://url/"), "user", "domain", "password", "$project/path/");
TfsMaterialConfig config = (TfsMaterialConfig) material.config();
assertThat(config.getPassword(), is("password"));
assertThat(config.getEncryptedPassword(), is(Matchers.not(Matchers.nullValue())));
}
use of com.thoughtworks.go.util.command.UrlArgument 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."));
}
}
use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.
the class TfsMaterialTest method shouldInjectAllRelevantAttributesInAttributeMap.
@Test
public void shouldInjectAllRelevantAttributesInAttributeMap() {
TfsMaterial tfsMaterial = new TfsMaterial(new GoCipher(), new UrlArgument("my-url"), "loser", DOMAIN, "foo_bar_baz", "/dev/null");
assertThat(tfsMaterial.getAttributesForXml(), is(m(AbstractMaterial.SQL_CRITERIA_TYPE, (Object) "TfsMaterial", "url", "my-url", "username", "loser", "projectPath", "/dev/null", "domain", DOMAIN)));
}
use of com.thoughtworks.go.util.command.UrlArgument 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.util.command.UrlArgument 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()));
}
Aggregations