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());
}
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;
}
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"));
}
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."));
}
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."));
}
}
Aggregations