Search in sources :

Example 21 with P4MaterialConfig

use of com.thoughtworks.go.config.materials.perforce.P4MaterialConfig in project gocd by gocd.

the class CruiseConfigTestBase method shouldCollectAllTheErrorsInTheChildrenHelper.

protected void shouldCollectAllTheErrorsInTheChildrenHelper(CruiseConfig config) {
    SecurityAuthConfig ldapConfig = new SecurityAuthConfig("ldap", "cd.go.authorization.ldap");
    ldapConfig.errors().add("uri", "invalid ldap uri");
    ldapConfig.errors().add("searchBase", "invalid search base");
    config.server().security().securityAuthConfigs().add(ldapConfig);
    PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString("pipeline-1"));
    pipelineConfig.errors().add("base", "Some base errors");
    P4MaterialConfig p4MaterialConfig = new P4MaterialConfig("localhost:1999", "view");
    p4MaterialConfig.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "p4_folder"));
    pipelineConfig.addMaterialConfig(p4MaterialConfig);
    p4MaterialConfig.errors().add("materialName", "material name does not follow pattern");
    StageConfig stage = pipelineConfig.first();
    stage.errors().add("role", "Roles must be proper");
    List<ConfigErrors> allErrors = config.validateAfterPreprocess();
    assertThat(allErrors.size(), is(5));
    assertThat(allErrors.get(0).on("uri"), is("invalid ldap uri"));
    assertThat(allErrors.get(0).on("searchBase"), is("invalid search base"));
    assertThat(allErrors.get(1).on("base"), is("Some base errors"));
    assertThat(allErrors.get(2).on("role"), is("Roles must be proper"));
    assertThat(allErrors.get(3).on(ScmMaterialConfig.FOLDER), is("Destination directory is required when specifying multiple scm materials"));
    assertThat(allErrors.get(4).on("materialName"), is("material name does not follow pattern"));
}
Also used : P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)

Example 22 with P4MaterialConfig

use of com.thoughtworks.go.config.materials.perforce.P4MaterialConfig in project gocd by gocd.

the class MaterialConfigsTest method shouldSetP4ConfigAttributesForMaterial.

@Test
public void shouldSetP4ConfigAttributesForMaterial() {
    MaterialConfigs materialConfigs = new MaterialConfigs();
    Map<String, String> hashMap = new HashMap<>();
    hashMap.put(P4MaterialConfig.SERVER_AND_PORT, "localhost:1666");
    hashMap.put(P4MaterialConfig.USERNAME, "username");
    hashMap.put(P4MaterialConfig.PASSWORD, "password");
    hashMap.put(P4MaterialConfig.VIEW, "foo");
    Map<String, Object> attributeMap = new HashMap<>();
    attributeMap.put(AbstractMaterialConfig.MATERIAL_TYPE, P4MaterialConfig.TYPE);
    attributeMap.put(P4MaterialConfig.TYPE, hashMap);
    materialConfigs.setConfigAttributes(attributeMap);
    assertThat(materialConfigs.size(), is(1));
    P4MaterialConfig expected = new P4MaterialConfig("localhost:1666", "foo", "username");
    expected.setPassword("password");
    assertThat(materialConfigs.first(), is(expected));
}
Also used : HashMap(java.util.HashMap) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 23 with P4MaterialConfig

use of com.thoughtworks.go.config.materials.perforce.P4MaterialConfig in project gocd by gocd.

the class PipelineConfigDependencyGraphTest method shouldReturnIfSharedRevisionsAreIgnoredByAllDaddys.

@Test
public void shouldReturnIfSharedRevisionsAreIgnoredByAllDaddys() throws Exception {
    SvnMaterialConfig firstOrderSVNMaterial = MaterialConfigsMother.svnMaterialConfig();
    GitMaterialConfig firstOrderGitMaterial = MaterialConfigsMother.gitMaterialConfig("url");
    P4MaterialConfig firstOrderP4Material = MaterialConfigsMother.p4MaterialConfig();
    firstOrderP4Material.setFilter(new Filter(new IgnoredFiles("foo")));
    PipelineConfig current = GoConfigMother.createPipelineConfigWithMaterialConfig("current", MaterialConfigsMother.hgMaterialConfig(), new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")), new DependencyMaterialConfig(new CaseInsensitiveString("up2"), new CaseInsensitiveString("first")));
    PipelineConfig up1 = GoConfigMother.createPipelineConfigWithMaterialConfig("up1", filteredHgMaterialConfig("phigar"), firstOrderGitMaterial, new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first")));
    PipelineConfig up2 = GoConfigMother.createPipelineConfigWithMaterialConfig("up2", firstOrderSVNMaterial, firstOrderP4Material, filteredHgMaterialConfig("phigar"), new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first")));
    PipelineConfig uppest = GoConfigMother.createPipelineConfigWithMaterialConfig("uppest", filteredHgMaterialConfig("phigar"), firstOrderP4Material);
    PipelineConfigDependencyGraph uppestGraph = new PipelineConfigDependencyGraph(uppest);
    PipelineConfigDependencyGraph up1Graph = new PipelineConfigDependencyGraph(up1, uppestGraph);
    PipelineConfigDependencyGraph up2Graph = new PipelineConfigDependencyGraph(up2, uppestGraph);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, up1Graph, up2Graph);
    Modification modification = new Modification("user", "comment", "i@u.com", new Date(), "foo");
    modification.createModifiedFile("phigar", "", ModifiedAction.added);
    boolean ignored = dependencyGraph.isRevisionsOfSharedMaterialsIgnored(ModificationsMother.createHgMaterialWithMultipleRevisions(1, modification));
    assertThat(ignored, is(true));
    ignored = dependencyGraph.isRevisionsOfSharedMaterialsIgnored(ModificationsMother.createHgMaterialWithMultipleRevisions(1, ModificationsMother.oneModifiedFile("Silly")));
    assertThat(ignored, is(false));
    MaterialRevisions materialRevisions = ModificationsMother.createSvnMaterialRevisions(modification);
    materialRevisions.addAll(ModificationsMother.createP4MaterialRevisions(modification));
    materialRevisions.addAll(ModificationsMother.createHgMaterialWithMultipleRevisions(1, modification));
    ignored = up2Graph.isRevisionsOfSharedMaterialsIgnored(materialRevisions);
    assertThat(ignored, is(true));
    ignored = up2Graph.isRevisionsOfSharedMaterialsIgnored(ModificationsMother.createHgMaterialWithMultipleRevisions(1, ModificationsMother.oneModifiedFile("Silly")));
    assertThat(ignored, is(false));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 24 with P4MaterialConfig

use of com.thoughtworks.go.config.materials.perforce.P4MaterialConfig in project gocd by gocd.

the class PipelineConfigDependencyGraphTest method shouldReturnTheListOfFirstOrderMaterialsIgnoringDestFoldersForScmMaterials.

@Test
public void shouldReturnTheListOfFirstOrderMaterialsIgnoringDestFoldersForScmMaterials() throws Exception {
    HgMaterialConfig common1 = MaterialConfigsMother.hgMaterialConfig("hg-url", "one-folder");
    HgMaterialConfig common2 = MaterialConfigsMother.hgMaterialConfig("hg-url", "another-folder");
    SvnMaterialConfig firstOrderSVNMaterial = MaterialConfigsMother.svnMaterialConfig();
    GitMaterialConfig firstOrderGitMaterial = MaterialConfigsMother.gitMaterialConfig("url", "submodule", "branch", false);
    P4MaterialConfig firstOrderP4Material = MaterialConfigsMother.p4MaterialConfig();
    DependencyMaterialConfig up1DependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first"));
    DependencyMaterialConfig up2DependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("up2"), new CaseInsensitiveString("first"));
    DependencyMaterialConfig uppestDependencyMaterial = new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first"));
    PipelineConfig current = GoConfigMother.createPipelineConfigWithMaterialConfig("current", common1, up1DependencyMaterial, up2DependencyMaterial);
    PipelineConfig up1 = GoConfigMother.createPipelineConfigWithMaterialConfig("up1", common2, firstOrderGitMaterial, uppestDependencyMaterial);
    PipelineConfig up2 = GoConfigMother.createPipelineConfigWithMaterialConfig("up2", firstOrderSVNMaterial, common2, uppestDependencyMaterial);
    PipelineConfig uppest = GoConfigMother.createPipelineConfigWithMaterialConfig("uppest", common1, firstOrderP4Material);
    PipelineConfigDependencyGraph uppestGraph = new PipelineConfigDependencyGraph(uppest);
    PipelineConfigDependencyGraph up1Graph = new PipelineConfigDependencyGraph(up1, uppestGraph);
    PipelineConfigDependencyGraph up2Graph = new PipelineConfigDependencyGraph(up2, uppestGraph);
    PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, up1Graph, up2Graph);
    assertThat(dependencyGraph.unsharedMaterialConfigs().size(), is(2));
    assertThat(dependencyGraph.unsharedMaterialConfigs().get(0), is(up1DependencyMaterial));
    assertThat(dependencyGraph.unsharedMaterialConfigs().get(1), is(up2DependencyMaterial));
    assertThat(up1Graph.unsharedMaterialConfigs().size(), is(2));
    assertThat(up1Graph.unsharedMaterialConfigs().get(0), is(firstOrderGitMaterial));
    assertThat(up1Graph.unsharedMaterialConfigs().get(1), is(uppestDependencyMaterial));
    assertThat(up2Graph.unsharedMaterialConfigs().size(), is(2));
    assertThat(up2Graph.unsharedMaterialConfigs().get(0), is(firstOrderSVNMaterial));
    assertThat(up2Graph.unsharedMaterialConfigs().get(1), is(uppestDependencyMaterial));
    assertThat(uppestGraph.unsharedMaterialConfigs().size(), is(2));
    assertThat(uppestGraph.unsharedMaterialConfigs().get(0), is(common1));
    assertThat(uppestGraph.unsharedMaterialConfigs().get(1), is(firstOrderP4Material));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) MaterialConfigsMother.filteredHgMaterialConfig(com.thoughtworks.go.helper.MaterialConfigsMother.filteredHgMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 25 with P4MaterialConfig

use of com.thoughtworks.go.config.materials.perforce.P4MaterialConfig in project gocd by gocd.

the class ConfigConverterTest method shouldConvertP4MaterialWhenEncryptedPassword.

@Test
public void shouldConvertP4MaterialWhenEncryptedPassword() {
    CRP4Material crp4Material = CRP4Material.withEncryptedPassword("name", "folder", false, false, filter, "server:port", "user", "encryptedvalue", true, "view");
    P4MaterialConfig p4MaterialConfig = (P4MaterialConfig) configConverter.toMaterialConfig(crp4Material, context);
    assertThat(p4MaterialConfig.getName().toLower(), is("name"));
    assertThat(p4MaterialConfig.getFolder(), is("folder"));
    assertThat(p4MaterialConfig.getAutoUpdate(), is(false));
    assertThat(p4MaterialConfig.getFilterAsString(), is("filter"));
    assertThat(p4MaterialConfig.getUrl(), is("server:port"));
    assertThat(p4MaterialConfig.getUserName(), is("user"));
    assertThat(p4MaterialConfig.getPassword(), is("secret"));
    assertThat(p4MaterialConfig.getUseTickets(), is(true));
    assertThat(p4MaterialConfig.getView(), is("view"));
}
Also used : P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) Test(org.junit.Test)

Aggregations

P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)30 Test (org.junit.Test)22 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)13 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)8 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)8 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)7 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)7 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)4 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)4 GoCipher (com.thoughtworks.go.security.GoCipher)4 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)3 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)3 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)2 MaterialConfigsMother.filteredHgMaterialConfig (com.thoughtworks.go.helper.MaterialConfigsMother.filteredHgMaterialConfig)2 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)2 Date (java.util.Date)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Filter (com.thoughtworks.go.config.materials.Filter)1