Search in sources :

Example 1 with Viewers

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));
}
Also used : AllowedViewers(com.thoughtworks.go.domain.cctray.viewers.AllowedViewers) Viewers(com.thoughtworks.go.domain.cctray.viewers.Viewers) Test(org.junit.Test)

Example 2 with 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));
}
Also used : Authorization(com.thoughtworks.go.config.Authorization) AllowedViewers(com.thoughtworks.go.domain.cctray.viewers.AllowedViewers) Viewers(com.thoughtworks.go.domain.cctray.viewers.Viewers) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) Test(org.junit.Test)

Example 3 with Viewers

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));
}
Also used : Authorization(com.thoughtworks.go.config.Authorization) AllowedViewers(com.thoughtworks.go.domain.cctray.viewers.AllowedViewers) Viewers(com.thoughtworks.go.domain.cctray.viewers.Viewers) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) Test(org.junit.Test)

Example 4 with Viewers

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));
}
Also used : Authorization(com.thoughtworks.go.config.Authorization) AllowedViewers(com.thoughtworks.go.domain.cctray.viewers.AllowedViewers) Viewers(com.thoughtworks.go.domain.cctray.viewers.Viewers) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) Test(org.junit.Test)

Example 5 with Viewers

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));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) AllowedViewers(com.thoughtworks.go.domain.cctray.viewers.AllowedViewers) Viewers(com.thoughtworks.go.domain.cctray.viewers.Viewers) Date(java.util.Date) AllowedViewers(com.thoughtworks.go.domain.cctray.viewers.AllowedViewers) Test(org.junit.Test)

Aggregations

Viewers (com.thoughtworks.go.domain.cctray.viewers.Viewers)9 AllowedViewers (com.thoughtworks.go.domain.cctray.viewers.AllowedViewers)7 Test (org.junit.Test)6 ProjectStatus (com.thoughtworks.go.domain.activity.ProjectStatus)4 Authorization (com.thoughtworks.go.config.Authorization)3 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)3 PipelineGroupVisitor (com.thoughtworks.go.domain.PipelineGroupVisitor)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 NullStage (com.thoughtworks.go.domain.NullStage)1 Stage (com.thoughtworks.go.domain.Stage)1