Search in sources :

Example 51 with MaterialConfigs

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

the class MaterialConfigService method getMaterialConfigs.

public MaterialConfigs getMaterialConfigs(String username) {
    MaterialConfigs materialConfigs = new MaterialConfigs();
    Set<String> materialFingerprints = new HashSet<>();
    for (PipelineConfigs pipelineGroup : goConfigService.groups()) {
        if (securityService.hasViewPermissionForGroup(username, pipelineGroup.getGroup())) {
            for (PipelineConfig pipelineConfig : pipelineGroup) {
                for (MaterialConfig currentMaterialConfig : pipelineConfig.materialConfigs()) {
                    if (!materialFingerprints.contains(currentMaterialConfig.getFingerprint())) {
                        materialConfigs.add(currentMaterialConfig);
                        materialFingerprints.add(currentMaterialConfig.getFingerprint());
                    }
                }
            }
        }
    }
    return materialConfigs;
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) HashSet(java.util.HashSet)

Example 52 with MaterialConfigs

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

the class MaterialExpansionService method expandForScheduling.

public void expandForScheduling(Material material, Materials addTheExpandedMaterialsHere) {
    MaterialConfigs materialConfigs = new MaterialConfigs();
    expandForScheduling(material.config(), materialConfigs);
    addTheExpandedMaterialsHere.addAll(materialConfigConverter.toMaterials(materialConfigs));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs)

Example 53 with MaterialConfigs

use of com.thoughtworks.go.config.materials.MaterialConfigs 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 54 with MaterialConfigs

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

the class BuildCauseProducerServiceIntegrationTest method setup.

@Before
public void setup() throws Exception {
    diskSpaceSimulator = new DiskSpaceSimulator();
    new HgTestRepo("testHgRepo", temporaryFolder);
    svnRepository = new SvnTestRepo(temporaryFolder);
    dbHelper.onSetUp();
    configHelper.onSetUp();
    configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
    repository = new SvnCommand(null, svnRepository.projectRepositoryUrl());
    PipelineConfig goParentPipelineConfig = configHelper.addPipeline(GO_PIPELINE_UPSTREAM, STAGE_NAME, new MaterialConfigs(new GitMaterialConfig("foo-bar")), "unit");
    goPipelineConfig = configHelper.addPipeline(GO_PIPELINE_NAME, STAGE_NAME, repository, "unit");
    svnMaterialRevs = new MaterialRevisions();
    svnMaterial = SvnMaterial.createSvnMaterialWithMock(repository);
    svnMaterialRevs.addRevision(svnMaterial, svnMaterial.latestModification(null, new ServerSubprocessExecutionContext(goConfigService, new SystemEnvironment())));
    final MaterialRevisions materialRevisions = new MaterialRevisions();
    SvnMaterial anotherSvnMaterial = SvnMaterial.createSvnMaterialWithMock(repository);
    materialRevisions.addRevision(anotherSvnMaterial, anotherSvnMaterial.latestModification(null, subprocessExecutionContext));
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            materialRepository.save(svnMaterialRevs);
        }
    });
    BuildCause buildCause = BuildCause.createWithModifications(svnMaterialRevs, "");
    mingleConfig = configHelper.addPipeline(MINGLE_PIPELINE_NAME, STAGE_NAME, repository, new Filter(new IgnoredFiles("**/*.doc")), "unit", "functional");
    latestPipeline = PipelineMother.schedule(this.mingleConfig, buildCause);
    latestPipeline = pipelineDao.saveWithStages(latestPipeline);
    dbHelper.passStage(latestPipeline.getStages().first());
    pipelineScheduleQueue.clear();
    result = new HttpOperationResult();
    scheduleOptions = new ScheduleOptions();
    u = new ScheduleTestUtil(transactionTemplate, materialRepository, dbHelper, configHelper);
    materialForManualTriggerPipeline = u.wf(new SvnMaterial("svn", "username", "password", false), "folder1");
    u.checkinInOrder(materialForManualTriggerPipeline, u.d(1), "s1");
    manualTriggerPipeline = configHelper.addPipeline(UUID.randomUUID().toString(), STAGE_NAME, materialForManualTriggerPipeline.config(), "build");
    username = Username.ANONYMOUS;
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) TransactionStatus(org.springframework.transaction.TransactionStatus) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ScheduleOptions(com.thoughtworks.go.server.scheduling.ScheduleOptions) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) SvnCommand(com.thoughtworks.go.domain.materials.svn.SvnCommand) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) Before(org.junit.Before)

Example 55 with MaterialConfigs

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

the class BuildCauseProducerServiceWithFlipModificationTest method preparePipelineWithMaterial.

private void preparePipelineWithMaterial() throws Exception {
    SvnMaterial svnMaterial = SvnMaterial.createSvnMaterialWithMock(repository);
    ReflectionUtil.setField(svnMaterial, ScmMaterialConfig.FOLDER, "asc");
    ReflectionUtil.invoke(svnMaterial, "resetCachedIdentityAttributes");
    MaterialConfigs materialConfigs = new MaterialConfigs();
    materialConfigs.add(svnMaterial.config());
    configHelper.addPipeline("cruise", STAGE_NAME, materialConfigs, "unit", "functional");
    MaterialRevisions materialRevisions = new MaterialRevisions();
    materialRevisions.addRevision(svnMaterial, svnMaterial.latestModification(null, subprocessExecutionContext));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial)

Aggregations

MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)218 Test (org.junit.Test)158 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)35 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)33 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)32 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)32 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)27 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)25 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)25 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)25 TimeProvider (com.thoughtworks.go.util.TimeProvider)25 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)21 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)19 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)19 ValueStreamMapPresentationModel (com.thoughtworks.go.server.presentation.models.ValueStreamMapPresentationModel)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)15 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)14 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)14 Material (com.thoughtworks.go.domain.materials.Material)14 Materials (com.thoughtworks.go.config.materials.Materials)12