Search in sources :

Example 6 with UrlArgument

use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.

the class TfsMaterialConfigUpdateTest method shouldValidateWhetherTheEncryptedPasswordIsCorrect.

@Test
public void shouldValidateWhetherTheEncryptedPasswordIsCorrect() {
    TfsMaterialConfig materialConfig = new TfsMaterialConfig(new UrlArgument("foo/bar"), "", "encryptedPassword", new GoCipher());
    materialConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(materialConfig.errors().on("encryptedPassword"), is("Encrypted password value for TFS material with url 'foo/bar' is invalid. This usually happens when the cipher text is modified to have an invalid value."));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) Test(org.junit.Test)

Example 7 with UrlArgument

use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.

the class TfsMaterialConfigUpdateTest method shouldThrowErrorsIfBothPasswordAndEncryptedPasswordAreProvided.

@Test
public void shouldThrowErrorsIfBothPasswordAndEncryptedPasswordAreProvided() {
    TfsMaterialConfig materialConfig = new TfsMaterialConfig(new UrlArgument("foo/bar"), "password", "encryptedPassword", new GoCipher());
    materialConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(materialConfig.errors().on("password"), is("You may only specify `password` or `encrypted_password`, not both!"));
    assertThat(materialConfig.errors().on("encryptedPassword"), is("You may only specify `password` or `encrypted_password`, not both!"));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) Test(org.junit.Test)

Example 8 with UrlArgument

use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.

the class TfsMaterialConfigUpdateTest method validate_shouldEnsureDestFilePathIsValid.

@Test
public void validate_shouldEnsureDestFilePathIsValid() {
    TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(new GoCipher(), new UrlArgument("http://10.4.4.101:8080/tfs/Sample"), "loser", "CORPORATE", "passwd", "walk_this_path");
    tfsMaterialConfig.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "../a"));
    tfsMaterialConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(tfsMaterialConfig.errors().on(TfsMaterialConfig.FOLDER), is("Dest folder '../a' is not valid. It must be a sub-directory of the working folder."));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) Test(org.junit.Test)

Example 9 with UrlArgument

use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.

the class TfsMaterialTest method shouldInjectAllRelevantAttributesInSqlCriteriaMap.

@Test
public void shouldInjectAllRelevantAttributesInSqlCriteriaMap() {
    TfsMaterial tfsMaterial = new TfsMaterial(new GoCipher(), new UrlArgument("my-url"), "loser", DOMAIN, "foo_bar_baz", "/dev/null");
    assertThat(tfsMaterial.getSqlCriteria(), Is.is(DataStructureUtils.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 10 with UrlArgument

use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.

the class TfsMaterialTest method shouldEncryptTfsPasswordAndMarkPasswordAsNull.

@Test
public void shouldEncryptTfsPasswordAndMarkPasswordAsNull() throws Exception {
    GoCipher mockGoCipher = mock(GoCipher.class);
    when(mockGoCipher.encrypt("password")).thenReturn("encrypted");
    TfsMaterial tfsMaterial = new TfsMaterial(mockGoCipher, new UrlArgument("/foo"), "username", DOMAIN, "password", "");
    tfsMaterial.ensureEncrypted();
    assertThat(tfsMaterial.getPassword(), is(nullValue()));
    assertThat(tfsMaterial.getEncryptedPassword(), is("encrypted"));
}
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)58 Test (org.junit.Test)44 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 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 HgUrlArgument (com.thoughtworks.go.util.command.HgUrlArgument)4 InvalidCipherTextException (org.bouncycastle.crypto.InvalidCipherTextException)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)3 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)3