Search in sources :

Example 6 with TfsMaterialConfig

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;
}
Also used : HgUrlArgument(com.thoughtworks.go.util.command.HgUrlArgument) UrlArgument(com.thoughtworks.go.util.command.UrlArgument) GoCipher(com.thoughtworks.go.security.GoCipher) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 7 with 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));
}
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)

Example 8 with TfsMaterialConfig

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"));
}
Also used : TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) Test(org.junit.Test)

Example 9 with TfsMaterialConfig

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"));
}
Also used : TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) Test(org.junit.Test)

Example 10 with TfsMaterialConfig

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())));
}
Also used : TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Aggregations

TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)14 Test (org.junit.Test)12 GoCipher (com.thoughtworks.go.security.GoCipher)8 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)5 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)5 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)5 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)3 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)3 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)2 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 HgUrlArgument (com.thoughtworks.go.util.command.HgUrlArgument)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)1 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)1 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)1 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)1 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)1 File (java.io.File)1 HashMap (java.util.HashMap)1