use of com.thoughtworks.go.config.PipelineConfigs 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));
}
use of com.thoughtworks.go.config.PipelineConfigs in project gocd by gocd.
the class MaterialConfigService method getMaterialConfigs.
public MaterialConfigs getMaterialConfigs(String username) {
MaterialConfigs materialConfigs = new MaterialConfigs();
Set<String> materialFingerprints = new HashSet<>();
for (PipelineConfigs pipelineGroup : goConfigService.groups()) {
if (securityService.hasViewPermissionForGroup(username, pipelineGroup.getGroup())) {
for (PipelineConfig pipelineConfig : pipelineGroup) {
for (MaterialConfig currentMaterialConfig : pipelineConfig.materialConfigs()) {
if (!materialFingerprints.contains(currentMaterialConfig.getFingerprint())) {
materialConfigs.add(currentMaterialConfig);
materialFingerprints.add(currentMaterialConfig.getFingerprint());
}
}
}
}
}
return materialConfigs;
}
use of com.thoughtworks.go.config.PipelineConfigs in project gocd by gocd.
the class MingleConfigServiceIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
dbHelper.onSetUp();
configHelper = new GoConfigFileHelper(goConfigDao);
configHelper.onSetUp();
configHelper.addPipeline("bar", "stage", MaterialConfigsMother.defaultMaterialConfigs(), "build");
pipelineConfig = configHelper.addPipeline("foo", "stage", MaterialConfigsMother.defaultMaterialConfigs(), "build");
configHelper.addMingleConfigToPipeline("foo", new MingleConfig("https://some-tracking-tool:8443", "project-super-secret", "hello=world"));
CruiseConfig cruiseConfig = configHelper.load();
PipelineConfigs group = cruiseConfig.findGroup("defaultGroup");
group.setAuthorization(new Authorization(new ViewConfig(new AdminUser(new CaseInsensitiveString("authorized_user")))));
configHelper.writeConfigFile(cruiseConfig);
SecurityConfig securityConfig = new SecurityConfig(new LdapConfig(new GoCipher()), new PasswordFileConfig("/tmp/foo.passwd"), true);
securityConfig.adminsConfig().add(new AdminUser(new CaseInsensitiveString("admin")));
configHelper.addSecurity(securityConfig);
}
use of com.thoughtworks.go.config.PipelineConfigs in project gocd by gocd.
the class MyGoControllerTest method shouldRenderPipelineStageCombinationJSONSortedByPipelineNameIgnoringCase.
@Test
public void shouldRenderPipelineStageCombinationJSONSortedByPipelineNameIgnoringCase() {
HttpServletRequest request = mock(HttpServletRequest.class);
User user = new User(USERNAME, "Srikanth Maga", new String[] { "rope", "srikanth" }, "sriki@tw.com", true);
user.addNotificationFilter(new NotificationFilter("p1", "s1", StageEvent.All, true));
user.addNotificationFilter(new NotificationFilter("p2", "s2", StageEvent.Fails, true));
when(userService.load(USERID)).thenReturn(user);
List<PipelineConfigs> groups = new ArrayList<>();
groups.add(PipelineConfigMother.createGroup("g3", PipelineConfigMother.createPipelineConfigWithStages("pipeline3-1", "stage3-1")));
groups.add(PipelineConfigMother.createGroup("g1", PipelineConfigMother.createPipelineConfigWithStages("PIPELINE2-1", "stage2-1")));
groups.add(PipelineConfigMother.createGroup("g1", PipelineConfigMother.createPipelineConfigWithStages("pipeline1-1", "stage1-1", "stage1-2")));
when(pipelineConfigService.viewableGroupsFor(new Username(new CaseInsensitiveString(user.getName())))).thenReturn(groups);
ModelAndView modelAndView = controller.handleRequest(null, request);
assertThat(modelAndView.getModel().get("matchers"), is(new Matcher("rope,srikanth")));
assertThat(modelAndView.getModel().get("email"), is("sriki@tw.com"));
assertThat(modelAndView.getModel().get("emailMe"), is(true));
assertThat(modelAndView.getModel().get("notificationFilters"), is(user.getNotificationFilters()));
assertThat(modelAndView.getModel().get("l"), is(localizer));
assertThat(modelAndView.getModel().get("pipelines"), is("[{\"name\":\"" + GoConstants.ANY_PIPELINE + "\",\"stages\":[{\"stageName\":\"" + GoConstants.ANY_STAGE + "\"}]}," + "{\"name\":\"pipeline1-1\",\"stages\":[{\"stageName\":\"" + GoConstants.ANY_STAGE + "\"},{\"stageName\":\"stage1-1\"},{\"stageName\":\"stage1-2\"}]}," + "{\"name\":\"PIPELINE2-1\",\"stages\":[{\"stageName\":\"" + GoConstants.ANY_STAGE + "\"},{\"stageName\":\"stage2-1\"}]}," + "{\"name\":\"pipeline3-1\",\"stages\":[{\"stageName\":\"" + GoConstants.ANY_STAGE + "\"},{\"stageName\":\"stage3-1\"}]}]"));
}
use of com.thoughtworks.go.config.PipelineConfigs in project gocd by gocd.
the class BasicPipelineConfigsTest method shouldSetOriginInPipelines.
@Test
public void shouldSetOriginInPipelines() {
PipelineConfig pipe = PipelineConfigMother.pipelineConfig("pipeline1");
PipelineConfigs group = new BasicPipelineConfigs(pipe);
group.setOrigins(new FileConfigOrigin());
assertThat(pipe.getOrigin(), Is.<ConfigOrigin>is(new FileConfigOrigin()));
}
Aggregations