use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldWriteSvnMaterialToXmlPartial.
@Test
public void shouldWriteSvnMaterialToXmlPartial() throws Exception {
String encryptedPassword = new GoCipher().encrypt("password");
SvnMaterialConfig material = com.thoughtworks.go.helper.MaterialConfigsMother.svnMaterialConfig("http://user:pass@svn", null, "cruise", "password", false, null);
assertThat(xmlWriter.toXmlPartial(material), is("<svn url=\"http://user:pass@svn\" username=\"cruise\" encryptedPassword=\"" + encryptedPassword + "\" materialName=\"http___user_pass@svn\" />"));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class MagicalGoConfigXmlLoaderTest method shouldMigrateDESEncryptedMaterialPassword_XslMigrationFrom108To109.
@Test
void shouldMigrateDESEncryptedMaterialPassword_XslMigrationFrom108To109(ResetCipher resetCipher) throws Exception {
resetCipher.setupDESCipherFile();
String clearText = "user-password!";
// "user-password!" encrypted using the above key
String desEncryptedPassword = "mvcX9yrQsM4iPgm1tDxN1A==";
String content = configWithPipeline("<pipeline name='some_pipeline'>" + " <materials>" + " <svn url='asdsa' username='user' encryptedPassword='" + desEncryptedPassword + "' dest='svn'/>" + " <tfs url='tfsurl' username='user' domain='domain' encryptedPassword='" + desEncryptedPassword + "' projectPath='path' dest='tfs' />" + " <p4 port='host:9999' username='user' encryptedPassword='" + desEncryptedPassword + "' dest='perforce'>" + " <view><![CDATA[view]]></view>" + " </p4>" + " </materials>" + " <stage name='some_stage'>" + " <jobs>" + " <job name='some_job'><tasks><exec command='echo'><runif status='passed' /></exec></tasks>" + " </job>" + " </jobs>" + " </stage>" + "</pipeline>", 108);
CruiseConfig config = ConfigMigrator.loadWithMigration(content).config;
MaterialConfigs materialConfigs = config.allPipelines().get(0).materialConfigs();
SvnMaterialConfig svnMaterialConfig = (SvnMaterialConfig) materialConfigs.get(0);
assertThat(svnMaterialConfig.getPassword()).isEqualTo(clearText);
assertThat(svnMaterialConfig.getEncryptedPassword()).startsWith("AES:");
TfsMaterialConfig tfs = (TfsMaterialConfig) materialConfigs.get(1);
assertThat(tfs.getPassword()).isEqualTo(clearText);
assertThat(tfs.getEncryptedPassword()).startsWith("AES:");
assertThat(tfs.getUrl()).isEqualTo("tfsurl");
P4MaterialConfig p4 = (P4MaterialConfig) materialConfigs.get(2);
assertThat(p4.getPassword()).isEqualTo(clearText);
assertThat(p4.getEncryptedPassword()).startsWith("AES:");
assertThat(p4.getServerAndPort()).isEqualTo("host:9999");
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class MaterialExpansionService method expandExternals.
private void expandExternals(MaterialConfig configuredMaterial, MaterialConfigs expandedMaterials) {
SvnMaterialConfig svnMaterialConfig = (SvnMaterialConfig) configuredMaterial;
if (!svnMaterialConfig.isCheckExternals()) {
return;
}
List<SvnExternal> urLs = svn(svnMaterialConfig).getAllExternalURLs();
for (SvnExternal externalUrl : urLs) {
SvnMaterialConfig svnMaterial = new SvnMaterialConfig();
svnMaterial.setUrl(externalUrl.getURL());
svnMaterial.setUserName(svnMaterialConfig.getUserName());
svnMaterial.setPassword(svnMaterialConfig.getPassword());
svnMaterial.setCheckExternals(true);
svnMaterial.setFolder(svnMaterialConfig.folderFor(externalUrl.getFolder()));
svnMaterial.setFilter(svnMaterialConfig.filter());
expandedMaterials.add(svnMaterial);
}
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class ParamResolverTest method shouldNotResolveOptedOutConfigAttributes.
@Test
public void shouldNotResolveOptedOutConfigAttributes() throws NoSuchFieldException {
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("cruise-#{foo}-#{bar}", "dev", "ant");
SvnMaterialConfig svn = (SvnMaterialConfig) pipelineConfig.materialConfigs().get(0);
svn.setPassword("#quux-#{foo}-#{bar}");
pipelineConfig.setLabelTemplate("2.1-${COUNT}-#{foo}-bar-#{bar}");
new ParamResolver(new ParamSubstitutionHandlerFactory(params(param("foo", "pavan"), param("bar", "jj"))), fieldCache).resolve(pipelineConfig);
assertThat(pipelineConfig.getLabelTemplate(), is("2.1-${COUNT}-pavan-bar-jj"));
assertThat(pipelineConfig.name(), is(new CaseInsensitiveString("cruise-#{foo}-#{bar}")));
assertThat(((SvnMaterialConfig) pipelineConfig.materialConfigs().get(0)).getPassword(), is("#quux-#{foo}-#{bar}"));
assertThat(pipelineConfig.getClass().getDeclaredField("name").getAnnotation(SkipParameterResolution.class), isA(SkipParameterResolution.class));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterialConfig in project gocd by gocd.
the class ConfigRepoConfigTest method validate_shouldNotAllowPipelineWithSameRepositoryAndDifferentAutoUpdate.
@Test
public void validate_shouldNotAllowPipelineWithSameRepositoryAndDifferentAutoUpdate() {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
GoConfigMother mother = new GoConfigMother();
MaterialConfigs materialConfigs = new MaterialConfigs();
SvnMaterialConfig svnInConfigRepo = svn("url", false);
SvnMaterialConfig svnInPipelineConfig = svn("url", false);
svnInConfigRepo.setAutoUpdate(false);
svnInPipelineConfig.setAutoUpdate(true);
materialConfigs.add(svnInPipelineConfig);
ConfigRepoConfig configRepoConfig = ConfigRepoConfig.createConfigRepoConfig(svnInConfigRepo, "plug", "id");
cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepoConfig));
PipelineConfig pipeline1 = mother.addPipeline(cruiseConfig, "badpipe", "build", materialConfigs, "build");
configRepoConfig.validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline1));
assertThat(svnInConfigRepo.errors().isEmpty()).isFalse();
assertThat(svnInConfigRepo.errors().on("autoUpdate")).isEqualTo("The material of type Subversion (url) is used elsewhere with a different value for autoUpdate (\"Poll for changes\"). All copies of this material must have the same autoUpdate setting or configuration repository must be removed.\n Config Repository: id (auto update disabled).\n Pipelines: badpipe (auto update enabled)");
}
Aggregations