Search in sources :

Example 21 with RepoConfigOrigin

use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.

the class MergePipelineConfigsTest method shouldAddPipelineAtIndex_WhenWouldLandInEditablePart.

@Test
public void shouldAddPipelineAtIndex_WhenWouldLandInEditablePart() {
    PipelineConfig pipeline0 = PipelineConfigMother.pipelineConfig("pipeline0");
    PipelineConfig pipeline1 = PipelineConfigMother.pipelineConfig("pipeline1");
    PipelineConfig pipeline3 = PipelineConfigMother.pipelineConfig("pipeline3");
    PipelineConfig pipeline5 = PipelineConfigMother.pipelineConfig("pipeline5");
    PipelineConfig pipeline2 = PipelineConfigMother.pipelineConfig("pipeline2");
    PipelineConfig pipeline4 = PipelineConfigMother.pipelineConfig("pipeline4");
    BasicPipelineConfigs pipelineConfigsMiddle = new BasicPipelineConfigs(pipeline3);
    pipelineConfigsMiddle.setOrigin(new FileConfigOrigin());
    BasicPipelineConfigs bottom = new BasicPipelineConfigs(pipeline0, pipeline1, pipeline2);
    BasicPipelineConfigs top = new BasicPipelineConfigs(pipeline4, pipeline5);
    bottom.setOrigin(new RepoConfigOrigin());
    top.setOrigin(new RepoConfigOrigin());
    PipelineConfigs group = new MergePipelineConfigs(bottom, pipelineConfigsMiddle, top);
    PipelineConfig p1 = PipelineConfigMother.pipelineConfig("pipelineToInsert");
    group.add(3, p1);
    assertThat(group, hasItem(p1));
    assertThat(pipelineConfigsMiddle, hasItem(p1));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Test(org.junit.Test)

Example 22 with RepoConfigOrigin

use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.

the class MergePipelineConfigsTest method shouldReturnOriginAsASumOfAllOrigins.

@Test
public void shouldReturnOriginAsASumOfAllOrigins() {
    BasicPipelineConfigs fileConfigs = new BasicPipelineConfigs(PipelineConfigMother.pipelineConfig("pipeline1"));
    fileConfigs.setOrigin(new FileConfigOrigin());
    BasicPipelineConfigs remoteConfigs = new BasicPipelineConfigs(PipelineConfigMother.pipelineConfig("pipeline2"));
    remoteConfigs.setOrigin(new RepoConfigOrigin());
    PipelineConfigs group = new MergePipelineConfigs(fileConfigs, remoteConfigs);
    ConfigOrigin allOrigins = group.getOrigin();
    assertThat(allOrigins instanceof MergeConfigOrigin, is(true));
    MergeConfigOrigin mergeConfigOrigin = (MergeConfigOrigin) allOrigins;
    assertThat(mergeConfigOrigin.size(), is(2));
    assertThat(mergeConfigOrigin.contains(new FileConfigOrigin()), is(true));
    assertThat(mergeConfigOrigin.contains(new RepoConfigOrigin()), is(true));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) ConfigOrigin(com.thoughtworks.go.config.remote.ConfigOrigin) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Test(org.junit.Test)

Example 23 with RepoConfigOrigin

use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.

the class EnvironmentConfigMother method remote.

public static BasicEnvironmentConfig remote(String name) {
    BasicEnvironmentConfig env = environment(name);
    env.setOrigins(new RepoConfigOrigin());
    return env;
}
Also used : BasicEnvironmentConfig(com.thoughtworks.go.config.BasicEnvironmentConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin)

Example 24 with RepoConfigOrigin

use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.

the class MaterialConfigsTest method shouldNotAllowToDependOnPipelineDefinedInConfigRepository_WhenDownstreamInFile.

@Test
public void shouldNotAllowToDependOnPipelineDefinedInConfigRepository_WhenDownstreamInFile() throws Exception {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    PipelineConfig pipeline1 = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
    PipelineConfig pipeline2 = goConfigMother.addPipeline(cruiseConfig, "pipeline2", "stage", "build");
    goConfigMother.setDependencyOn(cruiseConfig, pipeline2, "pipeline1", "stage");
    pipeline1.setOrigin(new RepoConfigOrigin());
    pipeline2.setOrigin(new FileConfigOrigin());
    pipeline1.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline1));
    assertThat(pipeline1.materialConfigs().errors().isEmpty(), is(true));
    pipeline2.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline2));
    DependencyMaterialConfig invalidDependency = pipeline2.materialConfigs().findDependencyMaterial(new CaseInsensitiveString("pipeline1"));
    assertThat(invalidDependency.errors().isEmpty(), is(false));
    assertThat(invalidDependency.errors().on(DependencyMaterialConfig.ORIGIN), startsWith("Dependency from pipeline defined in"));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.Test)

Example 25 with RepoConfigOrigin

use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.

the class PipelineConfigsTestBase method shouldErrorWhenAuthorizationIsDefinedInConfigRepo.

@Test
public void shouldErrorWhenAuthorizationIsDefinedInConfigRepo() {
    BasicPipelineConfigs group = new BasicPipelineConfigs(new RepoConfigOrigin());
    group.setGroup("gr");
    group.setConfigAttributes(m(BasicPipelineConfigs.AUTHORIZATION, a(m(Authorization.NAME, "loser", Authorization.TYPE, USER.toString(), Authorization.PRIVILEGES, privileges(ON, DISABLED, DISABLED)), m(Authorization.NAME, "boozer", Authorization.TYPE, USER.toString(), Authorization.PRIVILEGES, privileges(OFF, ON, ON)), m(Authorization.NAME, "geezer", Authorization.TYPE, USER.toString(), Authorization.PRIVILEGES, privileges(DISABLED, OFF, ON)), m(Authorization.NAME, "gang_of_losers", Authorization.TYPE, ROLE.toString(), Authorization.PRIVILEGES, privileges(DISABLED, OFF, ON)), m(Authorization.NAME, "blinds", Authorization.TYPE, ROLE.toString(), Authorization.PRIVILEGES, privileges(ON, ON, OFF)))));
    group.validate(null);
    assertThat(group.errors().on(BasicPipelineConfigs.NO_REMOTE_AUTHORIZATION), is("Authorization can be defined only in configuration file"));
}
Also used : RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Test(org.junit.Test)

Aggregations

RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)97 Test (org.junit.Test)74 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)34 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)29 FileConfigOrigin (com.thoughtworks.go.config.remote.FileConfigOrigin)23 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)15 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)13 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)11 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)11 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)11 StringContains.containsString (org.hamcrest.core.StringContains.containsString)11 File (java.io.File)9 IOException (java.io.IOException)8 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)8 ExpectedException (org.junit.rules.ExpectedException)8 Cloner (com.rits.cloning.Cloner)7 FullConfigUpdateCommand (com.thoughtworks.go.config.update.FullConfigUpdateCommand)7 Modification (com.thoughtworks.go.domain.materials.Modification)7 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)6 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)6