use of com.thoughtworks.go.config.security.users.Users in project gocd by gocd.
the class CcTrayConfigChangeHandler method call.
public void call(PipelineConfig pipelineConfig) {
ArrayList<ProjectStatus> projectStatuses = new ArrayList<>();
final Permissions permissions = pipelinePermissionsAuthority.permissionsForPipeline(pipelineConfig.name());
Users usersWithViewPermissionsOfThisPipeline = viewersOrNoOne(permissions);
updateProjectStatusForPipeline(usersWithViewPermissionsOfThisPipeline, pipelineConfig, projectStatuses);
cache.putAll(projectStatuses);
}
use of com.thoughtworks.go.config.security.users.Users in project gocd by gocd.
the class CcTrayConfigChangeHandler method findAllProjectStatusesForStagesAndJobsIn.
private List<ProjectStatus> findAllProjectStatusesForStagesAndJobsIn(CruiseConfig config) {
final List<ProjectStatus> projectStatuses = new ArrayList<>();
final Map<CaseInsensitiveString, Permissions> pipelinesAndTheirPermissions = pipelinePermissionsAuthority.pipelinesAndTheirPermissions();
config.accept(new PipelineGroupVisitor() {
@Override
public void visit(PipelineConfigs group) {
for (PipelineConfig pipelineConfig : group) {
Users usersWithViewPermissionsForPipeline = usersWithViewPermissionsFor(pipelineConfig, pipelinesAndTheirPermissions);
updateProjectStatusForPipeline(usersWithViewPermissionsForPipeline, pipelineConfig, projectStatuses);
}
}
});
return projectStatuses;
}
use of com.thoughtworks.go.config.security.users.Users in project gocd by gocd.
the class ProjectStatusTest method shouldListViewers.
@Test
public void shouldListViewers() throws Exception {
Users viewers = mock(Users.class);
ProjectStatus status = new ProjectStatus("name", "activity", "web-url");
status.updateViewers(viewers);
assertThat(status.viewers(), is(viewers));
}
use of com.thoughtworks.go.config.security.users.Users in project gocd by gocd.
the class CcTrayJobStatusChangeHandlerTest method shouldReuseViewersListFromExistingStatusWhenCreatingNewStatus.
@Test
public void shouldReuseViewersListFromExistingStatusWhenCreatingNewStatus() throws Exception {
Users viewers = new AllowedUsers(s("viewer1", "viewer2"), Collections.singleton(new PluginRoleConfig("admin", "ldap")));
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.config.security.users.Users in project gocd by gocd.
the class CcTrayStageStatusChangeHandlerTest method shouldReuseViewersListFromExistingStatusWhenCreatingNewStatus.
@Test
public void shouldReuseViewersListFromExistingStatusWhenCreatingNewStatus() throws Exception {
Users viewers = viewers(Collections.singleton(new PluginRoleConfig("admin", "ldap")), "viewer1", "viewer2");
String projectName = "pipeline :: stage1";
ProjectStatus existingStageStatus = new ProjectStatus(projectName, "OldActivity", "OldStatus", "OldLabel", new Date(), webUrlFor("stage1"));
existingStageStatus.updateViewers(viewers);
when(cache.get(projectName)).thenReturn(existingStageStatus);
Stage stage = StageMother.custom("stage1", JobInstanceMother.building("job1"));
List<ProjectStatus> statuses = handler.statusesOfStageAndItsJobsFor(stage);
ProjectStatus statusOfStage = statuses.get(0);
assertThat(statusOfStage.viewers(), is(viewers));
}
Aggregations