Search in sources :

Example 51 with UrlArgument

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())));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) Test(org.junit.Test)

Example 52 with UrlArgument

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."));
    }
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) InvalidCipherTextException(org.bouncycastle.crypto.InvalidCipherTextException) GoCipher(com.thoughtworks.go.security.GoCipher) InvalidCipherTextException(org.bouncycastle.crypto.InvalidCipherTextException) IOException(java.io.IOException) Test(org.junit.Test)

Example 53 with UrlArgument

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)));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) Test(org.junit.Test)

Example 54 with UrlArgument

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"));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) Test(org.junit.Test)

Example 55 with UrlArgument

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()));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) Test(org.junit.Test)

Aggregations

UrlArgument (com.thoughtworks.go.util.command.UrlArgument)63 Test (org.junit.Test)47 GoCipher (com.thoughtworks.go.security.GoCipher)37 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)9 ConfigSaveValidationContext (com.thoughtworks.go.config.ConfigSaveValidationContext)7 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)7 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)5 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)5 Material (com.thoughtworks.go.domain.materials.Material)5 HgUrlArgument (com.thoughtworks.go.util.command.HgUrlArgument)5 File (java.io.File)5 Map (java.util.Map)5 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)4 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)4 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)4 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)4 TfsMaterial (com.thoughtworks.go.config.materials.tfs.TfsMaterial)4 InvalidCipherTextException (org.bouncycastle.crypto.InvalidCipherTextException)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)3