Search in sources :

Example 11 with P4MaterialConfig

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

the class CruiseConfigTestBase method getAllErrors_shouldCollectAllErrorsInTheChildren.

@Test
public void getAllErrors_shouldCollectAllErrorsInTheChildren() {
    CruiseConfig config = GoConfigMother.configWithPipelines("pipeline-1");
    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");
    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.getAllErrors();
    assertThat(allErrors.size(), is(4));
    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("materialName"), is("material name does not follow pattern"));
}
Also used : P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) Test(org.junit.Test)

Example 12 with P4MaterialConfig

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

the class ParamResolverTest method shouldErrorOutIfCannotResolveParamForP4View.

@Test
public void shouldErrorOutIfCannotResolveParamForP4View() {
    P4MaterialConfig p4MaterialConfig = new P4MaterialConfig("server:port", "#");
    new ParamResolver(new ParamSubstitutionHandlerFactory(params(param("foo", "pavan"), param("bar", "jj"))), fieldCache).resolve(p4MaterialConfig);
    assertThat(p4MaterialConfig.getP4MaterialView().errors().on(P4MaterialConfig.VIEW), is("Error when processing params for '#' used in field 'view', # must be followed by a parameter pattern or escaped by another #"));
}
Also used : P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) Test(org.junit.Test)

Example 13 with P4MaterialConfig

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

the class MaterialConfigsTest method shouldValidateTree.

@Test
public void shouldValidateTree() {
    GitMaterialConfig git = new GitMaterialConfig();
    git.setName(new CaseInsensitiveString("mat-name"));
    SvnMaterialConfig svn = new SvnMaterialConfig("url", true);
    svn.setName(new CaseInsensitiveString("mat-name"));
    P4MaterialConfig p4 = new P4MaterialConfig();
    TfsMaterialConfig tfs = new TfsMaterialConfig();
    HgMaterialConfig hg = new HgMaterialConfig();
    MaterialConfigs materialConfigs = new MaterialConfigs(git, svn, p4, tfs, hg);
    PipelineConfig pipelineConfig = new PipelineConfig(new CaseInsensitiveString("p1"), new MaterialConfigs(svn));
    materialConfigs.validateTree(PipelineConfigSaveValidationContext.forChain(true, "group", new BasicCruiseConfig(new BasicPipelineConfigs(pipelineConfig)), pipelineConfig));
    assertThat(git.errors().on(GitMaterialConfig.MATERIAL_NAME), contains("You have defined multiple materials called 'mat-name'"));
    assertThat(git.errors().on(GitMaterialConfig.URL), is("URL cannot be blank"));
    assertThat(svn.errors().on(SvnMaterialConfig.MATERIAL_NAME), contains("You have defined multiple materials called 'mat-name'"));
    assertThat(p4.errors().on(P4MaterialConfig.VIEW), contains("P4 view cannot be empty."));
    assertThat(tfs.errors().on(TfsMaterialConfig.URL), contains("URL cannot be blank"));
    assertThat(hg.errors().on(HgMaterialConfig.URL), is("URL cannot be blank"));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) Test(org.junit.Test)

Example 14 with P4MaterialConfig

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

the class MaterialConfigsMother method p4MaterialConfig.

public static P4MaterialConfig p4MaterialConfig(String serverAndPort, String userName, String password, String view, boolean useTickets) {
    final P4MaterialConfig material = new P4MaterialConfig(serverAndPort, view);
    material.setConfigAttributes(m(P4MaterialConfig.USERNAME, userName, P4MaterialConfig.AUTO_UPDATE, "true"));
    material.setPassword(password);
    material.setUseTickets(useTickets);
    return material;
}
Also used : P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)

Example 15 with P4MaterialConfig

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

the class ConfigCipherUpdaterTest method shouldMigrateEncryptedPasswordsThatWereEncryptedWithFlawedCipher.

@Test
public void shouldMigrateEncryptedPasswordsThatWereEncryptedWithFlawedCipher() throws Exception {
    String originalConfig = FileUtils.readFileToString(originalConfigFile, UTF_8);
    assertThat(originalConfig.contains("encryptedPassword=\"" + passwordEncryptedWithFlawedCipher + "\""), is(true));
    updater.migrate();
    File copyOfOldConfig = new File(systemEnvironment.getConfigDir(), "cipher.original." + timestamp);
    assertThat(copyOfOldConfig.exists(), is(true));
    assertThat(FileUtils.readFileToString(copyOfOldConfig, UTF_8).equals(ConfigCipherUpdater.FLAWED_VALUE), is(true));
    String newCipher = FileUtils.readFileToString(systemEnvironment.getCipherFile(), UTF_8);
    assertThat(newCipher.equals(ConfigCipherUpdater.FLAWED_VALUE), is(false));
    File editedConfigFile = new File(systemEnvironment.getCruiseConfigFile());
    String editedConfig = FileUtils.readFileToString(editedConfigFile, UTF_8);
    assertThat(editedConfig.contains("encryptedPassword=\"" + passwordEncryptedWithFlawedCipher + "\""), is(false));
    String passwordEncryptedWithNewCipher = new GoCipher().encrypt(password);
    CruiseConfig config = magicalGoConfigXmlLoader.loadConfigHolder(editedConfig).config;
    MaterialConfigs materialConfigs = config.getAllPipelineConfigs().get(0).materialConfigs();
    SvnMaterialConfig svnMaterial = materialConfigs.getSvnMaterial();
    assertThat(svnMaterial.getPassword(), is(password));
    assertThat(svnMaterial.getEncryptedPassword(), is(passwordEncryptedWithNewCipher));
    P4MaterialConfig p4Material = materialConfigs.getP4Material();
    assertThat(p4Material.getPassword(), is(password));
    assertThat(p4Material.getEncryptedPassword(), is(passwordEncryptedWithNewCipher));
    TfsMaterialConfig tfsMaterial = materialConfigs.getTfsMaterial();
    assertThat(tfsMaterial.getPassword(), is(password));
    assertThat(tfsMaterial.getEncryptedPassword(), is(passwordEncryptedWithNewCipher));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GoCipher(com.thoughtworks.go.security.GoCipher) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) File(java.io.File) 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