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