Search in sources :

Example 11 with FileConfigOrigin

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

the class MergePipelineConfigsTest method shouldReturnPartWithPipelineWhenExists.

@Test
public void shouldReturnPartWithPipelineWhenExists() {
    PipelineConfig pipe1 = PipelineConfigMother.pipelineConfig("pipeline1");
    BasicPipelineConfigs part1 = new BasicPipelineConfigs(pipe1);
    part1.setOrigin(new FileConfigOrigin());
    MergePipelineConfigs group = new MergePipelineConfigs(part1, new BasicPipelineConfigs(PipelineConfigMother.pipelineConfig("pipeline2")));
    assertThat(group.getPartWithPipeline(new CaseInsensitiveString("pipeline1")), Matchers.<PipelineConfigs>is(part1));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) Test(org.junit.Test)

Example 12 with FileConfigOrigin

use of com.thoughtworks.go.config.remote.FileConfigOrigin 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 13 with FileConfigOrigin

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

the class MergePipelineConfigsTest method shouldSetAuthorizationInFile.

@Test
public void shouldSetAuthorizationInFile() {
    BasicPipelineConfigs filePart = new BasicPipelineConfigs();
    filePart.setOrigin(new FileConfigOrigin());
    MergePipelineConfigs merge = new MergePipelineConfigs(filePart, new BasicPipelineConfigs());
    Authorization auth = new Authorization(new AdminsConfig(new AdminUser(new CaseInsensitiveString("buddy"))));
    merge.setAuthorization(auth);
    assertThat(filePart.getAuthorization(), is(auth));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) Test(org.junit.Test)

Example 14 with FileConfigOrigin

use of com.thoughtworks.go.config.remote.FileConfigOrigin 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 15 with FileConfigOrigin

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

the class MergePipelineConfigsTest method shouldReturnFalseIfViewPermissionIsNotDefined_When2ConfigParts.

@Test
public void shouldReturnFalseIfViewPermissionIsNotDefined_When2ConfigParts() {
    BasicPipelineConfigs filePart = new BasicPipelineConfigs(PipelineConfigMother.pipelineConfig("pipeline3"));
    filePart.setOrigin(new FileConfigOrigin());
    PipelineConfigs group = new MergePipelineConfigs(new BasicPipelineConfigs(PipelineConfigMother.pipelineConfig("pipeline1")), new BasicPipelineConfigs(PipelineConfigMother.pipelineConfig("pipeline2")), filePart);
    group.getAuthorization().getOperationConfig().add(new AdminUser(new CaseInsensitiveString("jez")));
    assertThat(group.hasViewPermission(new CaseInsensitiveString("jez"), null), is(false));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) Test(org.junit.Test)

Aggregations

FileConfigOrigin (com.thoughtworks.go.config.remote.FileConfigOrigin)59 Test (org.junit.Test)51 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)23 PipelineModel (com.thoughtworks.go.presentation.pipelinehistory.PipelineModel)5 MergeEnvironmentConfig (com.thoughtworks.go.config.merge.MergeEnvironmentConfig)4 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)4 Permissions (com.thoughtworks.go.config.security.Permissions)4 AllowedUsers (com.thoughtworks.go.config.security.users.AllowedUsers)4 BasicPipelineConfigs (com.thoughtworks.go.config.BasicPipelineConfigs)3 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)3 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)3 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)3 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)3 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)3 MergePipelineConfigs (com.thoughtworks.go.config.merge.MergePipelineConfigs)2 BasicEnvironmentConfig (com.thoughtworks.go.config.BasicEnvironmentConfig)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)1 MergeConfigOrigin (com.thoughtworks.go.config.merge.MergeConfigOrigin)1