Search in sources :

Example 21 with UrlArgument

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

the class GitPostCommitHookImplementerTest method shouldReturnEmptyListIfParamIsMissingForRepoURL.

@Test
public void shouldReturnEmptyListIfParamIsMissingForRepoURL() throws Exception {
    GitMaterial material1 = mock(GitMaterial.class);
    when(material1.getUrlArgument()).thenReturn(new UrlArgument("https://machine.local.git"));
    Set<Material> materials = new HashSet<>(Arrays.asList(material1));
    Set<Material> actual = implementer.prune(materials, new HashMap());
    assertThat(actual.size(), is(0));
    verifyNoMoreInteractions(material1);
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Material(com.thoughtworks.go.domain.materials.Material) Test(org.junit.Test)

Example 22 with UrlArgument

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

the class MercurialPostCommitHookImplementerTest method shouldPruneMercurialMaterialsWhichMatchIncomingURL.

@Test
public void shouldPruneMercurialMaterialsWhichMatchIncomingURL() throws Exception {
    HgMaterial material1 = mock(HgMaterial.class);
    when(material1.getUrlArgument()).thenReturn(new UrlArgument("http://repo1.something.local"));
    HgMaterial material2 = mock(HgMaterial.class);
    when(material2.getUrlArgument()).thenReturn(new UrlArgument("http://repo1.something.local"));
    HgMaterial material3 = mock(HgMaterial.class);
    when(material3.getUrlArgument()).thenReturn(new UrlArgument("ssh://repo1.something.local"));
    GitMaterial material4 = mock(GitMaterial.class);
    when(material4.getUrlArgument()).thenReturn(new UrlArgument("http://repo1.something.local"));
    Set<Material> materials = new HashSet<>(Arrays.asList(material1, material2, material3, material4));
    Map params = new HashMap();
    params.put(MercurialPostCommitHookImplementer.REPO_URL_PARAM_KEY, "http://repo1.something.local");
    Set<Material> actual = implementer.prune(materials, params);
    assertThat(actual.size(), is(2));
    assertThat(actual, hasItem(material1));
    assertThat(actual, hasItem(material2));
    verify(material1).getUrlArgument();
    verify(material2).getUrlArgument();
    verify(material3).getUrlArgument();
    verify(material4, times(0)).getUrlArgument();
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) Material(com.thoughtworks.go.domain.materials.Material) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 23 with UrlArgument

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

the class CruiseConfigTestBase method shouldReturnAllUniqueSchedulableScmMaterials.

@Test
public void shouldReturnAllUniqueSchedulableScmMaterials() {
    final MaterialConfig svnMaterialConfig = new SvnMaterialConfig("http://svn_url_1", "username", "password", false);
    svnMaterialConfig.setAutoUpdate(false);
    final MaterialConfig svnMaterialConfigWithAutoUpdate = new SvnMaterialConfig("http://svn_url_2", "username", "password", false);
    svnMaterialConfigWithAutoUpdate.setAutoUpdate(true);
    final MaterialConfig hgMaterialConfig = new HgMaterialConfig("http://hg_url", null);
    hgMaterialConfig.setAutoUpdate(false);
    final MaterialConfig gitMaterialConfig = new GitMaterialConfig("http://git_url");
    gitMaterialConfig.setAutoUpdate(false);
    final MaterialConfig tfsMaterialConfig = new TfsMaterialConfig(mock(GoCipher.class), new UrlArgument("http://tfs_url"), "username", "domain", "password", "project_path");
    tfsMaterialConfig.setAutoUpdate(false);
    final MaterialConfig p4MaterialConfig = new P4MaterialConfig("http://p4_url", "view", "username");
    p4MaterialConfig.setAutoUpdate(false);
    final MaterialConfig dependencyMaterialConfig = MaterialConfigsMother.dependencyMaterialConfig();
    final PluggableSCMMaterialConfig pluggableSCMMaterialConfig = MaterialConfigsMother.pluggableSCMMaterialConfig("scm-id-1", null, null);
    pluggableSCMMaterialConfig.getSCMConfig().setAutoUpdate(false);
    final PipelineConfig p1 = PipelineConfigMother.pipelineConfig("pipeline1", new MaterialConfigs(svnMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
    final PipelineConfig p2 = PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(svnMaterialConfig, gitMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
    final PipelineConfig p3 = PipelineConfigMother.pipelineConfig("pipeline3", new MaterialConfigs(hgMaterialConfig, dependencyMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
    final PipelineConfig p4 = PipelineConfigMother.pipelineConfig("pipeline4", new MaterialConfigs(p4MaterialConfig, pluggableSCMMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
    final PipelineConfig p5 = PipelineConfigMother.pipelineConfig("pipeline5", new MaterialConfigs(svnMaterialConfigWithAutoUpdate, tfsMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
    cruiseConfig.getGroups().add(new BasicPipelineConfigs(p1, p2, p3, p4, p5));
    final Set<MaterialConfig> materials = cruiseConfig.getAllUniquePostCommitSchedulableMaterials();
    assertThat(materials.size(), is(6));
    assertThat(materials, hasItems(svnMaterialConfig, hgMaterialConfig, gitMaterialConfig, tfsMaterialConfig, p4MaterialConfig, pluggableSCMMaterialConfig));
    assertThat(materials, not(hasItem(svnMaterialConfigWithAutoUpdate)));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GoCipher(com.thoughtworks.go.security.GoCipher) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) Test(org.junit.Test)

Example 24 with UrlArgument

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

the class MaterialConfigsTest method shouldSetTfsConfigAttributesForMaterial.

@Test
public void shouldSetTfsConfigAttributesForMaterial() {
    MaterialConfigs materialConfigs = new MaterialConfigs();
    Map<String, String> tfsAttrMap = new HashMap<>();
    tfsAttrMap.put(TfsMaterialConfig.URL, "foo");
    tfsAttrMap.put(TfsMaterialConfig.USERNAME, "bar");
    tfsAttrMap.put(TfsMaterialConfig.PASSWORD, "baz");
    tfsAttrMap.put(TfsMaterialConfig.PROJECT_PATH, "to_hell");
    tfsAttrMap.put(TfsMaterialConfig.MATERIAL_NAME, "crapy_material");
    tfsAttrMap.put(TfsMaterialConfig.DOMAIN, "CORPORATE");
    Map<String, Object> attributeMap = new HashMap<>();
    attributeMap.put(AbstractMaterialConfig.MATERIAL_TYPE, TfsMaterialConfig.TYPE);
    attributeMap.put(TfsMaterialConfig.TYPE, tfsAttrMap);
    materialConfigs.setConfigAttributes(attributeMap);
    TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(new GoCipher(), new UrlArgument("foo"), "bar", "CORPORATE", "baz", "to_hell");
    tfsMaterialConfig.setName(new CaseInsensitiveString("crapy_material"));
    assertThat(materialConfigs.first(), is(tfsMaterialConfig));
    assertThat(tfsMaterialConfig.getPassword(), is("baz"));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) HashMap(java.util.HashMap) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 25 with UrlArgument

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

the class HgCommandTest method makeACommitToSecondBranch.

private void makeACommitToSecondBranch() {
    HgCommand hg = new HgCommand(null, secondBranchWorkingCopy, "second", serverRepo.getAbsolutePath(), null);
    hg.clone(outputStreamConsumer, new UrlArgument(serverRepo.getAbsolutePath()));
    createNewFileAndPushUpstream(secondBranchWorkingCopy);
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument)

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