use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.
the class SvnMaterialConfigTest method shouldThrowErrorsIfBothPasswordAndEncryptedPasswordAreProvided.
@Test
public void shouldThrowErrorsIfBothPasswordAndEncryptedPasswordAreProvided() {
SvnMaterialConfig svnMaterialConfig = new SvnMaterialConfig(new UrlArgument("foo/bar"), "password", "encryptedPassword", new GoCipher(), null, false, "folder");
svnMaterialConfig.validate(new ConfigSaveValidationContext(null));
assertThat(svnMaterialConfig.errors().on("password"), is("You may only specify `password` or `encrypted_password`, not both!"));
assertThat(svnMaterialConfig.errors().on("encryptedPassword"), is("You may only specify `password` or `encrypted_password`, not both!"));
}
use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.
the class SvnMaterialConfigTest method shouldValidateWhetherTheEncryptedPasswordIsCorrect.
@Test
public void shouldValidateWhetherTheEncryptedPasswordIsCorrect() {
SvnMaterialConfig svnMaterialConfig = new SvnMaterialConfig(new UrlArgument("foo/bar"), "", "encryptedPassword", new GoCipher(), null, false, "folder");
svnMaterialConfig.validate(new ConfigSaveValidationContext(null));
assertThat(svnMaterialConfig.errors().on("encryptedPassword"), is("Encrypted password value for svn material with url 'foo/bar' is invalid. This usually happens when the cipher text is modified to have an invalid value."));
}
use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.
the class MaterialConfigsMother method tfsMaterialConfig.
public static TfsMaterialConfig tfsMaterialConfig() {
Filter filter = new Filter(new IgnoredFiles("**/*.html"), new IgnoredFiles("**/foobar/"));
TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(new GoCipher(), new UrlArgument("http://10.4.4.101:8080/tfs/Sample"), "loser", "some_domain", "passwd", "walk_this_path");
tfsMaterialConfig.setFilter(filter);
tfsMaterialConfig.setName(new CaseInsensitiveString("tfs-material"));
tfsMaterialConfig.setFolder("dest-folder");
return tfsMaterialConfig;
}
use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.
the class ConfigConverter method toScmMaterialConfig.
private ScmMaterialConfig toScmMaterialConfig(CRScmMaterial crScmMaterial) {
String materialName = crScmMaterial.getName();
if (crScmMaterial instanceof CRGitMaterial) {
CRGitMaterial git = (CRGitMaterial) crScmMaterial;
String gitBranch = git.getBranch();
if (StringUtils.isBlank(gitBranch))
gitBranch = GitMaterialConfig.DEFAULT_BRANCH;
GitMaterialConfig gitConfig = new GitMaterialConfig(git.getUrl(), gitBranch, git.shallowClone());
setCommonMaterialMembers(gitConfig, crScmMaterial);
setCommonScmMaterialMembers(gitConfig, git);
return gitConfig;
} else if (crScmMaterial instanceof CRHgMaterial) {
CRHgMaterial hg = (CRHgMaterial) crScmMaterial;
return new HgMaterialConfig(new HgUrlArgument(hg.getUrl()), hg.isAutoUpdate(), toFilter(crScmMaterial), false, hg.getDirectory(), toMaterialName(materialName));
} else if (crScmMaterial instanceof CRP4Material) {
CRP4Material crp4Material = (CRP4Material) crScmMaterial;
P4MaterialConfig p4MaterialConfig = new P4MaterialConfig(crp4Material.getServerAndPort(), crp4Material.getView(), cipher);
if (crp4Material.getEncryptedPassword() != null) {
p4MaterialConfig.setEncryptedPassword(crp4Material.getEncryptedPassword());
} else {
p4MaterialConfig.setPassword(crp4Material.getPassword());
}
p4MaterialConfig.setUserName(crp4Material.getUserName());
p4MaterialConfig.setUseTickets(crp4Material.getUseTickets());
setCommonMaterialMembers(p4MaterialConfig, crScmMaterial);
setCommonScmMaterialMembers(p4MaterialConfig, crp4Material);
return p4MaterialConfig;
} else if (crScmMaterial instanceof CRSvnMaterial) {
CRSvnMaterial crSvnMaterial = (CRSvnMaterial) crScmMaterial;
SvnMaterialConfig svnMaterialConfig = new SvnMaterialConfig(crSvnMaterial.getUrl(), crSvnMaterial.getUserName(), crSvnMaterial.isCheckExternals(), cipher);
if (crSvnMaterial.getEncryptedPassword() != null) {
svnMaterialConfig.setEncryptedPassword(crSvnMaterial.getEncryptedPassword());
} else {
svnMaterialConfig.setPassword(crSvnMaterial.getPassword());
}
setCommonMaterialMembers(svnMaterialConfig, crScmMaterial);
setCommonScmMaterialMembers(svnMaterialConfig, crSvnMaterial);
return svnMaterialConfig;
} else if (crScmMaterial instanceof CRTfsMaterial) {
CRTfsMaterial crTfsMaterial = (CRTfsMaterial) crScmMaterial;
TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(cipher, new UrlArgument(crTfsMaterial.getUrl()), crTfsMaterial.getUserName(), crTfsMaterial.getDomain(), crTfsMaterial.getProjectPath());
if (crTfsMaterial.getEncryptedPassword() != null) {
tfsMaterialConfig.setEncryptedPassword(crTfsMaterial.getEncryptedPassword());
} else {
tfsMaterialConfig.setPassword(crTfsMaterial.getPassword());
}
setCommonMaterialMembers(tfsMaterialConfig, crTfsMaterial);
setCommonScmMaterialMembers(tfsMaterialConfig, crTfsMaterial);
return tfsMaterialConfig;
} else
throw new ConfigConvertionException(String.format("unknown scm material type '%s'", crScmMaterial));
}
use of com.thoughtworks.go.util.command.UrlArgument in project gocd by gocd.
the class GitPostCommitHookImplementerTest method shouldReturnListOfMaterialMatchingThePayloadURL.
@Test
public void shouldReturnListOfMaterialMatchingThePayloadURL() throws Exception {
GitMaterial material1 = mock(GitMaterial.class);
when(material1.getUrlArgument()).thenReturn(new UrlArgument("https://other_repo.local.git"));
GitMaterial material2 = mock(GitMaterial.class);
when(material2.getUrlArgument()).thenReturn(new UrlArgument("https://other_repo.local.git"));
GitMaterial material3 = mock(GitMaterial.class);
when(material3.getUrlArgument()).thenReturn(new UrlArgument("https://machine.local.git"));
GitMaterial material4 = mock(GitMaterial.class);
when(material4.getUrlArgument()).thenReturn(new UrlArgument("https://machine.local.git"));
Set<Material> materials = new HashSet<>(Arrays.asList(material1, material2, material3, material4));
HashMap params = new HashMap();
params.put(GitPostCommitHookImplementer.REPO_URL_PARAM_KEY, "https://machine.local.git");
Set<Material> actual = implementer.prune(materials, params);
assertThat(actual.size(), is(2));
assertThat(actual, hasItem(material3));
assertThat(actual, hasItem(material4));
verify(material1).getUrlArgument();
verify(material2).getUrlArgument();
verify(material3).getUrlArgument();
verify(material4).getUrlArgument();
}
Aggregations