use of com.thoughtworks.go.config.security.users.AllowedUsers in project gocd by gocd.
the class GoDashboardPipelineGroupTest method shouldKnowWhetherAUserCanAdministerIt.
@Test
public void shouldKnowWhetherAUserCanAdministerIt() throws Exception {
Permissions permissions = new Permissions(NoOne.INSTANCE, NoOne.INSTANCE, new AllowedUsers(s("admin1"), Collections.emptySet()), NoOne.INSTANCE);
GoDashboardPipelineGroup pipelineGroup = new GoDashboardPipelineGroup("group1", permissions);
assertTrue(pipelineGroup.canBeAdministeredBy("admin1"));
assertFalse(pipelineGroup.canBeAdministeredBy("viewer1"));
}
use of com.thoughtworks.go.config.security.users.AllowedUsers in project gocd by gocd.
the class GoDashboardPipelineTest method shouldKnowWhetherAUserCanViewIt.
@Test
public void shouldKnowWhetherAUserCanViewIt() throws Exception {
Permissions permissions = new Permissions(new AllowedUsers(s("viewer1", "viewer2"), Collections.emptySet()), Everyone.INSTANCE, new AllowedUsers(s("admin", "root"), Collections.emptySet()), Everyone.INSTANCE);
GoDashboardPipeline pipeline = new GoDashboardPipeline(new PipelineModel("pipeline1", false, false, notPaused()), permissions, "group1", mock(TimeStampBasedCounter.class), new FileConfigOrigin());
assertThat(pipeline.canBeViewedBy("viewer1"), is(true));
assertThat(pipeline.canBeViewedBy("viewer2"), is(true));
assertThat(pipeline.canBeViewedBy("some-other-user-not-in-viewers-list"), is(false));
assertThat(pipeline.canBeViewedBy("admin"), is(false));
}
use of com.thoughtworks.go.config.security.users.AllowedUsers in project gocd by gocd.
the class GoDashboardPipelineTest method shouldKnowWhetherAUserCanAdministerIt.
@Test
public void shouldKnowWhetherAUserCanAdministerIt() throws Exception {
Permissions permissions = new Permissions(NoOne.INSTANCE, NoOne.INSTANCE, new AllowedUsers(s("admin1"), Collections.emptySet()), NoOne.INSTANCE);
GoDashboardPipeline pipeline = new GoDashboardPipeline(new PipelineModel("pipeline1", false, false, notPaused()), permissions, "group1", mock(TimeStampBasedCounter.class), new FileConfigOrigin());
assertTrue(pipeline.canBeAdministeredBy("admin1"));
assertFalse(pipeline.canBeAdministeredBy("viewer1"));
}
use of com.thoughtworks.go.config.security.users.AllowedUsers in project gocd by gocd.
the class GoDashboardPipelineTest method shouldKnowWhetherAUserCanOperateIt.
@Test
public void shouldKnowWhetherAUserCanOperateIt() throws Exception {
Permissions permissions = new Permissions(NoOne.INSTANCE, new AllowedUsers(s("operator1"), Collections.emptySet()), NoOne.INSTANCE, NoOne.INSTANCE);
GoDashboardPipeline pipeline = new GoDashboardPipeline(new PipelineModel("pipeline1", false, false, notPaused()), permissions, "group1", mock(TimeStampBasedCounter.class), new FileConfigOrigin());
assertTrue(pipeline.canBeOperatedBy("operator1"));
assertFalse(pipeline.canBeOperatedBy("viewer1"));
}
use of com.thoughtworks.go.config.security.users.AllowedUsers in project gocd by gocd.
the class GoDashboardServiceTest method allPipelineGroupsForDashboard_shouldRetrievePipelineGroupsBasedOnUsersPipelineSelections.
@Test
public void allPipelineGroupsForDashboard_shouldRetrievePipelineGroupsBasedOnUsersPipelineSelections() throws Exception {
PipelineSelections pipelineSelections = mock(PipelineSelections.class);
configMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1A", "job1A1");
GoDashboardPipeline pipeline1 = pipeline("pipeline1", "group1", new Permissions(new AllowedUsers(Collections.singleton("user1"), Collections.emptySet()), NoOne.INSTANCE, NoOne.INSTANCE, NoOne.INSTANCE));
configMother.addPipelineWithGroup(config, "group2", "pipeline2", "stage1A", "job1A1");
GoDashboardPipeline pipeline2 = pipeline("pipeline2", "group2", new Permissions(NoOne.INSTANCE, NoOne.INSTANCE, NoOne.INSTANCE, NoOne.INSTANCE));
addPipelinesToCache(pipeline1, pipeline2);
when(pipelineSelections.includesPipeline(any(PipelineConfig.class))).thenReturn(true);
List<GoDashboardPipelineGroup> pipelineGroups = allPipelineGroupsForDashboard(pipelineSelections, new Username("user1"));
assertThat(pipelineGroups.size(), is(1));
assertThat(pipelineGroups.get(0).allPipelineNames(), contains("pipeline1"));
assertThat(pipelineGroups.get(0).allPipelines(), contains(pipeline1));
}
Aggregations