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));
}
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));
}
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;
}
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"));
}
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"));
}
Aggregations