Search in sources :

Example 6 with PipelineConfigs

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));
}
Also used : Authorization(com.thoughtworks.go.config.Authorization) AllowedViewers(com.thoughtworks.go.domain.cctray.viewers.AllowedViewers) Viewers(com.thoughtworks.go.domain.cctray.viewers.Viewers) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) Test(org.junit.Test)

Example 7 with PipelineConfigs

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;
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) HashSet(java.util.HashSet)

Example 8 with PipelineConfigs

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);
}
Also used : Authorization(com.thoughtworks.go.config.Authorization) LdapConfig(com.thoughtworks.go.config.LdapConfig) GoCipher(com.thoughtworks.go.security.GoCipher) SecurityConfig(com.thoughtworks.go.config.SecurityConfig) ViewConfig(com.thoughtworks.go.config.ViewConfig) AdminUser(com.thoughtworks.go.config.AdminUser) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) GoConfigFileHelper(com.thoughtworks.go.util.GoConfigFileHelper) MingleConfig(com.thoughtworks.go.config.MingleConfig) PasswordFileConfig(com.thoughtworks.go.config.PasswordFileConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Before(org.junit.Before)

Example 9 with PipelineConfigs

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\"}]}]"));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) User(com.thoughtworks.go.domain.User) Username(com.thoughtworks.go.server.domain.Username) Matcher(com.thoughtworks.go.domain.Matcher) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) NotificationFilter(com.thoughtworks.go.domain.NotificationFilter) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 10 with PipelineConfigs

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()));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) BasicPipelineConfigs(com.thoughtworks.go.config.BasicPipelineConfigs) BasicPipelineConfigs(com.thoughtworks.go.config.BasicPipelineConfigs) Test(org.junit.Test)

Aggregations

PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)16 Test (org.junit.Test)10 BasicPipelineConfigs (com.thoughtworks.go.config.BasicPipelineConfigs)7 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)6 Authorization (com.thoughtworks.go.config.Authorization)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 FileConfigOrigin (com.thoughtworks.go.config.remote.FileConfigOrigin)3 AllowedViewers (com.thoughtworks.go.domain.cctray.viewers.AllowedViewers)3 Viewers (com.thoughtworks.go.domain.cctray.viewers.Viewers)3 User (com.thoughtworks.go.domain.User)2 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)2 Before (org.junit.Before)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 GsonBuilder (com.google.gson.GsonBuilder)1 AdminUser (com.thoughtworks.go.config.AdminUser)1 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)1 LdapConfig (com.thoughtworks.go.config.LdapConfig)1 MingleConfig (com.thoughtworks.go.config.MingleConfig)1 PasswordFileConfig (com.thoughtworks.go.config.PasswordFileConfig)1 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)1