use of com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig in project gocd by gocd.
the class MaterialConfigsMother method tfsMaterialConfig.
public static TfsMaterialConfig tfsMaterialConfig() {
Filter filter = new Filter(new IgnoredFiles("**/*.html"), new IgnoredFiles("**/foobar/"));
TfsMaterialConfig tfsMaterialConfig = new TfsMaterialConfig(new GoCipher(), new UrlArgument("http://10.4.4.101:8080/tfs/Sample"), "loser", "some_domain", "passwd", "walk_this_path");
tfsMaterialConfig.setFilter(filter);
tfsMaterialConfig.setName(new CaseInsensitiveString("tfs-material"));
tfsMaterialConfig.setFolder("dest-folder");
return tfsMaterialConfig;
}
use of com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig 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));
}
use of com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertTfsMaterialWhenPlainPassword.
@Test
public void shouldConvertTfsMaterialWhenPlainPassword() {
CRTfsMaterial crTfsMaterial = CRTfsMaterial.withPlainPassword("name", "folder", false, false, filter, "url", "domain", "user", "secret", "project");
TfsMaterialConfig tfsMaterialConfig = (TfsMaterialConfig) configConverter.toMaterialConfig(crTfsMaterial, context);
assertThat(tfsMaterialConfig.getName().toLower(), is("name"));
assertThat(tfsMaterialConfig.getFolder(), is("folder"));
assertThat(tfsMaterialConfig.getAutoUpdate(), is(false));
assertThat(tfsMaterialConfig.getFilterAsString(), is("filter"));
assertThat(tfsMaterialConfig.getUrl(), is("url"));
assertThat(tfsMaterialConfig.getUserName(), is("user"));
assertThat(tfsMaterialConfig.getPassword(), is("secret"));
assertThat(tfsMaterialConfig.getDomain(), is("domain"));
assertThat(tfsMaterialConfig.getProjectPath(), is("project"));
}
use of com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertTfsMaterialWhenEncryptedPassword.
@Test
public void shouldConvertTfsMaterialWhenEncryptedPassword() {
CRTfsMaterial crTfsMaterial = CRTfsMaterial.withEncryptedPassword("name", "folder", false, false, filter, "url", "domain", "user", "encryptedvalue", "project");
TfsMaterialConfig tfsMaterialConfig = (TfsMaterialConfig) configConverter.toMaterialConfig(crTfsMaterial, context);
assertThat(tfsMaterialConfig.getName().toLower(), is("name"));
assertThat(tfsMaterialConfig.getFolder(), is("folder"));
assertThat(tfsMaterialConfig.getAutoUpdate(), is(false));
assertThat(tfsMaterialConfig.getFilterAsString(), is("filter"));
assertThat(tfsMaterialConfig.getUrl(), is("url"));
assertThat(tfsMaterialConfig.getUserName(), is("user"));
assertThat(tfsMaterialConfig.getPassword(), is("secret"));
assertThat(tfsMaterialConfig.getDomain(), is("domain"));
assertThat(tfsMaterialConfig.getProjectPath(), is("project"));
}
use of com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig in project gocd by gocd.
the class GoFileConfigDataSourceTest method shouldEncryptTfsPasswordWhenConfigIsChangedViaFileSystem.
@Test
public void shouldEncryptTfsPasswordWhenConfigIsChangedViaFileSystem() throws Exception {
String configContent = ConfigFileFixture.configWithPipeline(String.format("<pipeline name='pipeline1'>" + " <materials>" + " <tfs url='http://some.repo.local' username='username@domain' password='password' projectPath='$/project_path' />" + " </materials>" + " <stage name='mingle'>" + " <jobs>" + " <job name='do-something'>" + " </job>" + " </jobs>" + " </stage>" + "</pipeline>", "hello"), GoConstants.CONFIG_SCHEMA_VERSION);
FileUtils.writeStringToFile(dataSource.fileLocation(), configContent, UTF_8);
GoConfigHolder configHolder = dataSource.load();
PipelineConfig pipelineConfig = configHolder.config.pipelineConfigByName(new CaseInsensitiveString("pipeline1"));
TfsMaterialConfig tfsMaterial = (TfsMaterialConfig) pipelineConfig.materialConfigs().get(0);
assertThat(tfsMaterial.getEncryptedPassword(), is(not(nullValue())));
}
Aggregations