Search in sources :

Example 1 with Users

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);
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) ArrayList(java.util.ArrayList) Permissions(com.thoughtworks.go.config.security.Permissions) Users(com.thoughtworks.go.config.security.users.Users)

Example 2 with Users

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;
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) ArrayList(java.util.ArrayList) Permissions(com.thoughtworks.go.config.security.Permissions) Users(com.thoughtworks.go.config.security.users.Users) PipelineGroupVisitor(com.thoughtworks.go.domain.PipelineGroupVisitor)

Example 3 with Users

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));
}
Also used : AllowedUsers(com.thoughtworks.go.config.security.users.AllowedUsers) Users(com.thoughtworks.go.config.security.users.Users) Test(org.junit.Test)

Example 4 with Users

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));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) AllowedUsers(com.thoughtworks.go.config.security.users.AllowedUsers) Users(com.thoughtworks.go.config.security.users.Users) AllowedUsers(com.thoughtworks.go.config.security.users.AllowedUsers) PluginRoleConfig(com.thoughtworks.go.config.PluginRoleConfig) Date(java.util.Date) Test(org.junit.Test)

Example 5 with Users

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));
}
Also used : ProjectStatus(com.thoughtworks.go.domain.activity.ProjectStatus) NullStage(com.thoughtworks.go.domain.NullStage) Stage(com.thoughtworks.go.domain.Stage) Users(com.thoughtworks.go.config.security.users.Users) AllowedUsers(com.thoughtworks.go.config.security.users.AllowedUsers) PluginRoleConfig(com.thoughtworks.go.config.PluginRoleConfig) Test(org.junit.Test)

Aggregations

Users (com.thoughtworks.go.config.security.users.Users)5 ProjectStatus (com.thoughtworks.go.domain.activity.ProjectStatus)4 AllowedUsers (com.thoughtworks.go.config.security.users.AllowedUsers)3 Test (org.junit.Test)3 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)2 Permissions (com.thoughtworks.go.config.security.Permissions)2 ArrayList (java.util.ArrayList)2 NullStage (com.thoughtworks.go.domain.NullStage)1 PipelineGroupVisitor (com.thoughtworks.go.domain.PipelineGroupVisitor)1 Stage (com.thoughtworks.go.domain.Stage)1 Date (java.util.Date)1