use of com.thoughtworks.go.domain.cctray.viewers.Viewers in project gocd by gocd.
the class ProjectStatusTest method shouldListViewers.
@Test
public void shouldListViewers() throws Exception {
Viewers viewers = mock(Viewers.class);
ProjectStatus status = new ProjectStatus("name", "activity", "web-url");
status.updateViewers(viewers);
assertThat(status.viewers(), is(viewers));
}
use of com.thoughtworks.go.domain.cctray.viewers.Viewers in project gocd by gocd.
the class CcTrayViewAuthorityTest method shouldNotConsiderAllUsersAsViewersOfAGroup_WhenExplicitGroupAdminIsSetup.
@Test
public void shouldNotConsiderAllUsersAsViewersOfAGroup_WhenExplicitGroupAdminIsSetup() throws Exception {
configMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1A", "job1A1", "job1A2");
configMother.addAdminUserForPipelineGroup(config, "groupadmin1", "group1");
PipelineConfigs group = config.findGroup("group1");
assertThat(group.getAuthorization(), is(not(new Authorization())));
Viewers viewersOfGroup1 = getGroupsAndTheirViewers().get("group1");
assertThat(viewersOfGroup1.contains("groupadmin1"), is(true));
assertThat(viewersOfGroup1.contains("some-user"), is(false));
assertThat(viewersOfGroup1.contains("some-other-user"), is(false));
}
use of com.thoughtworks.go.domain.cctray.viewers.Viewers in project gocd by gocd.
the class CcTrayViewAuthorityTest method shouldConsiderAllUsersAsViewersOfAGroupWithNoAuthorizationConfigurationSetup.
@Test
public void shouldConsiderAllUsersAsViewersOfAGroupWithNoAuthorizationConfigurationSetup() throws Exception {
configMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1A", "job1A1", "job1A2");
PipelineConfigs group = config.findGroup("group1");
assertThat(group.getAuthorization(), is(new Authorization()));
Viewers viewersOfGroup1 = getGroupsAndTheirViewers().get("group1");
assertThat(viewersOfGroup1.contains("some-user"), is(true));
assertThat(viewersOfGroup1.contains("some-other-user"), is(true));
assertThat(viewersOfGroup1.contains("any-random-user"), is(true));
}
use of com.thoughtworks.go.domain.cctray.viewers.Viewers in project gocd by gocd.
the class CcTrayViewAuthorityTest method shouldConsiderAllUsersAsViewersOfAGroupWithNoAuthorizationConfigurationSetup_EvenWhenExplicitSuperAdminsAreSetup.
@Test
public void shouldConsiderAllUsersAsViewersOfAGroupWithNoAuthorizationConfigurationSetup_EvenWhenExplicitSuperAdminsAreSetup() throws Exception {
configMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1A", "job1A1", "job1A2");
configMother.addUserAsSuperAdmin(config, "superadmin1");
PipelineConfigs group = config.findGroup("group1");
assertThat(group.getAuthorization(), is(new Authorization()));
Viewers viewersOfGroup1 = getGroupsAndTheirViewers().get("group1");
assertThat(viewersOfGroup1.contains("superadmin1"), is(true));
assertThat(viewersOfGroup1.contains("some-user"), is(true));
assertThat(viewersOfGroup1.contains("some-other-user"), is(true));
assertThat(viewersOfGroup1.contains("any-random-user"), is(true));
}
use of com.thoughtworks.go.domain.cctray.viewers.Viewers in project gocd by gocd.
the class CcTrayJobStatusChangeHandlerTest method shouldReuseViewersListFromExistingStatusWhenCreatingNewStatus.
@Test
public void shouldReuseViewersListFromExistingStatusWhenCreatingNewStatus() throws Exception {
Viewers viewers = new AllowedViewers(s("viewer1", "viewer2"));
ProjectStatus oldStatusInCache = new ProjectStatus(projectNameFor("job1"), "OldActivity", "OldStatus", "OldLabel", new Date(), webUrlFor("job1"));
oldStatusInCache.updateViewers(viewers);
when(cache.get(projectNameFor("job1"))).thenReturn(oldStatusInCache);
CcTrayJobStatusChangeHandler handler = new CcTrayJobStatusChangeHandler(cache);
ProjectStatus newStatus = handler.statusFor(JobInstanceMother.building("job1"), new HashSet<>());
assertThat(newStatus.viewers(), is(viewers));
}
Aggregations