Search in sources :

Example 26 with UrlArgument

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

the class GitMaterial method isRepositoryChanged.

private boolean isRepositoryChanged(GitCommand command, File workingDirectory) {
    UrlArgument currentWorkingUrl = command.workingRepositoryUrl();
    if (LOG.isTraceEnabled()) {
        LOG.trace("Current repository url of [" + workingDirectory + "]: " + currentWorkingUrl);
        LOG.trace("Target repository url: " + url);
    }
    return !MaterialUrl.sameUrl(url.forDisplay(), currentWorkingUrl.forCommandline()) || !isBranchEqual(command) || (!shallowClone && command.isShallow());
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument)

Example 27 with UrlArgument

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

the class TfsMaterialInstance method toOldMaterial.

@Override
public Material toOldMaterial(String name, String folder, String password) {
    TfsMaterial tfsMaterial = new TfsMaterial(new GoCipher(), new UrlArgument(url), username, domain, password, projectPath);
    tfsMaterial.setFolder(folder);
    setName(name, tfsMaterial);
    return tfsMaterial;
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) GoCipher(com.thoughtworks.go.security.GoCipher)

Example 28 with UrlArgument

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

the class TfsMaterialConfigUpdateTest method shouldNotDecryptTfsPasswordIfPasswordIsNotNull.

@Test
public void shouldNotDecryptTfsPasswordIfPasswordIsNotNull() throws Exception {
    GoCipher mockGoCipher = mock(GoCipher.class);
    when(mockGoCipher.encrypt("password")).thenReturn("encrypted");
    when(mockGoCipher.decrypt("encrypted")).thenReturn("password");
    TfsMaterialConfig materialConfig = new TfsMaterialConfig(mockGoCipher, new UrlArgument("http://10.4.4.101:8080/tfs/Sample"), "loser", "CORPORATE", "password", "walk_this_path");
    materialConfig.ensureEncrypted();
    when(mockGoCipher.encrypt("new_password")).thenReturn("new_encrypted");
    materialConfig.setPassword("new_password");
    when(mockGoCipher.decrypt("new_encrypted")).thenReturn("new_password");
    assertThat(materialConfig.getPassword(), is("new_password"));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) Test(org.junit.Test)

Example 29 with UrlArgument

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

the class TfsMaterialConfigUpdateTest method validate_shouldEnsureMaterialNameIsValid.

@Test
public void validate_shouldEnsureMaterialNameIsValid() {
    TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(new GoCipher(), new UrlArgument("http://10.4.4.101:8080/tfs/Sample"), "loser", "CORPORATE", "passwd", "walk_this_path");
    tfsMaterialConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(tfsMaterialConfig.errors().on(TfsMaterialConfig.MATERIAL_NAME), is(nullValue()));
    tfsMaterialConfig.setName(new CaseInsensitiveString(".bad-name-with-dot"));
    tfsMaterialConfig.validate(new ConfigSaveValidationContext(null));
    assertThat(tfsMaterialConfig.errors().on(TfsMaterialConfig.MATERIAL_NAME), is("Invalid material name '.bad-name-with-dot'. This must be alphanumeric and can contain underscores and periods (however, it cannot start with a period). The maximum allowed length is 255 characters."));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) ConfigSaveValidationContext(com.thoughtworks.go.config.ConfigSaveValidationContext) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 30 with UrlArgument

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

the class TfsMaterialConfigUpdateTest method shouldErrorOutIfEncryptionFails.

@Test
public void shouldErrorOutIfEncryptionFails() throws Exception {
    GoCipher mockGoCipher = mock(GoCipher.class);
    when(mockGoCipher.encrypt("password")).thenThrow(new InvalidCipherTextException("exception"));
    try {
        new TfsMaterialConfig(mockGoCipher, new UrlArgument("http://10.4.4.101:8080/tfs/Sample"), "loser", "CORPORATE", "password", "walk_this_path");
        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) 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