use of com.thoughtworks.go.domain.cctray.viewers.AllowedViewers 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));
}
use of com.thoughtworks.go.domain.cctray.viewers.AllowedViewers in project gocd by gocd.
the class CcTrayViewAuthority method groupsAndTheirViewers.
public Map<String, Viewers> groupsAndTheirViewers() {
final Map<String, Viewers> pipelinesAndViewers = new HashMap<>();
SecurityConfig security = goConfigService.security();
final Map<String, Collection<String>> rolesToUsers = rolesToUsers(security);
final Set<String> superAdmins = namesOf(security.adminsConfig(), rolesToUsers);
goConfigService.groups().accept(new PipelineGroupVisitor() {
@Override
public void visit(PipelineConfigs pipelineConfigs) {
if (!pipelineConfigs.hasAuthorizationDefined()) {
pipelinesAndViewers.put(pipelineConfigs.getGroup(), Everyone.INSTANCE);
return;
}
Set<String> pipelineGroupAdmins = namesOf(pipelineConfigs.getAuthorization().getAdminsConfig(), rolesToUsers);
Set<String> pipelineGroupViewers = namesOf(pipelineConfigs.getAuthorization().getViewConfig(), rolesToUsers);
Set<String> viewers = new HashSet<>();
viewers.addAll(superAdmins);
viewers.addAll(pipelineGroupAdmins);
viewers.addAll(pipelineGroupViewers);
pipelinesAndViewers.put(pipelineConfigs.getGroup(), new AllowedViewers(viewers));
}
});
return pipelinesAndViewers;
}
use of com.thoughtworks.go.domain.cctray.viewers.AllowedViewers in project gocd by gocd.
the class ProjectStatusTest method shouldNotBeViewableByAnyoneTillViewersAreUpdated.
@Test
public void shouldNotBeViewableByAnyoneTillViewersAreUpdated() throws Exception {
ProjectStatus status = new ProjectStatus("name", "activity", "web-url");
assertThat(status.canBeViewedBy("abc"), is(false));
assertThat(status.canBeViewedBy("def"), is(false));
status.updateViewers(new AllowedViewers(s("abc", "ghi")));
assertThat(status.canBeViewedBy("abc"), is(true));
assertThat(status.canBeViewedBy("def"), is(false));
assertThat(status.canBeViewedBy("ghi"), is(true));
}
Aggregations