use of com.thoughtworks.go.config.security.Permissions in project gocd by gocd.
the class GoDashboardCurrentStateLoader method pipelineFor.
public GoDashboardPipeline pipelineFor(PipelineConfig pipelineConfig, PipelineConfigs groupConfig) {
List<String> pipelineNames = CaseInsensitiveString.toStringList(Collections.singletonList(pipelineConfig.getName()));
PipelineInstanceModels pipelineHistoryForDashboard = loadHistoryForPipelines(pipelineNames);
syncHistoryForDashboard(pipelineHistoryForDashboard, pipelineConfig.name());
Permissions permissions = permissionsAuthority.permissionsForPipeline(pipelineConfig.name());
return createGoDashboardPipeline(pipelineConfig, permissions, pipelineHistoryForDashboard, groupConfig);
}
use of com.thoughtworks.go.config.security.Permissions in project gocd by gocd.
the class CcTrayConfigChangeHandlerTest method shouldUpdateViewPermissionsForEveryProjectBasedOnViewPermissionsOfTheGroup.
@Test
public void shouldUpdateViewPermissionsForEveryProjectBasedOnViewPermissionsOfTheGroup() throws Exception {
PluginRoleConfig admin = new PluginRoleConfig("admin", "ldap");
pluginRoleUsersStore.assignRole("user4", admin);
Permissions pipeline1Permissions = new Permissions(viewers("user1", "user2"), NoOne.INSTANCE, NoOne.INSTANCE, NoOnePermission.INSTANCE);
Permissions pipeline2Permissions = new Permissions(new AllowedUsers(s("user3"), Collections.singleton(admin)), NoOne.INSTANCE, NoOne.INSTANCE, NoOnePermission.INSTANCE);
when(pipelinePermissionsAuthority.pipelinesAndTheirPermissions()).thenReturn(m(new CaseInsensitiveString("pipeline1"), pipeline1Permissions, new CaseInsensitiveString("pipeline2"), pipeline2Permissions));
CruiseConfig config = GoConfigMother.defaultCruiseConfig();
goConfigMother.addPipelineWithGroup(config, "group2", "pipeline2", "stage2", "job2");
goConfigMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1", "job1");
handler.call(config);
verify(cache).replaceAllEntriesInCacheWith(statusesCaptor.capture());
List<ProjectStatus> statuses = statusesCaptor.getValue();
assertThat(statuses.size(), is(4));
assertThat(statuses.get(0).name(), is("pipeline1 :: stage1"));
assertThat(statuses.get(0).canBeViewedBy("user1"), is(true));
assertThat(statuses.get(0).canBeViewedBy("user2"), is(true));
assertThat(statuses.get(0).canBeViewedBy("user3"), is(false));
assertThat(statuses.get(0).canBeViewedBy("user4"), is(false));
assertThat(statuses.get(1).name(), is("pipeline1 :: stage1 :: job1"));
assertThat(statuses.get(1).canBeViewedBy("user1"), is(true));
assertThat(statuses.get(1).canBeViewedBy("user2"), is(true));
assertThat(statuses.get(1).canBeViewedBy("user3"), is(false));
assertThat(statuses.get(1).canBeViewedBy("user4"), is(false));
assertThat(statuses.get(2).name(), is("pipeline2 :: stage2"));
assertThat(statuses.get(2).canBeViewedBy("user1"), is(false));
assertThat(statuses.get(2).canBeViewedBy("user2"), is(false));
assertThat(statuses.get(2).canBeViewedBy("user3"), is(true));
assertThat(statuses.get(2).canBeViewedBy("user4"), is(true));
assertThat(statuses.get(3).name(), is("pipeline2 :: stage2 :: job2"));
assertThat(statuses.get(3).canBeViewedBy("user1"), is(false));
assertThat(statuses.get(3).canBeViewedBy("user2"), is(false));
assertThat(statuses.get(3).canBeViewedBy("user3"), is(true));
assertThat(statuses.get(3).canBeViewedBy("user4"), is(true));
}
Aggregations