Search in sources :

Example 11 with PipelineConfigs

use of com.thoughtworks.go.config.PipelineConfigs in project gocd by gocd.

the class BasicPipelineConfigsTest method shouldUpdateName.

@Test
public void shouldUpdateName() {
    PipelineConfigs group = createWithPipeline(PipelineConfigMother.pipelineConfig("pipeline1"));
    group.setConfigAttributes(m(BasicPipelineConfigs.GROUP, "my-new-group"));
    assertThat(group.getGroup(), is("my-new-group"));
    group.setConfigAttributes(m());
    assertThat(group.getGroup(), is("my-new-group"));
    group.setConfigAttributes(null);
    assertThat(group.getGroup(), is("my-new-group"));
    group.setConfigAttributes(m(BasicPipelineConfigs.GROUP, null));
    assertThat(group.getGroup(), is(nullValue()));
}
Also used : PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) BasicPipelineConfigs(com.thoughtworks.go.config.BasicPipelineConfigs) Test(org.junit.Test)

Example 12 with PipelineConfigs

use of com.thoughtworks.go.config.PipelineConfigs in project gocd by gocd.

the class BasicPipelineConfigsTest method shouldSetOriginInAuthorization.

@Test
public void shouldSetOriginInAuthorization() {
    PipelineConfig pipe = PipelineConfigMother.pipelineConfig("pipeline1");
    PipelineConfigs group = new BasicPipelineConfigs(pipe);
    group.setOrigins(new FileConfigOrigin());
    assertThat(group.getAuthorization().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)

Example 13 with PipelineConfigs

use of com.thoughtworks.go.config.PipelineConfigs in project gocd by gocd.

the class MyGoController method render.

private ModelAndView render(HttpServletRequest request, Message message, HashMap<String, Object> data) {
    User user = userService.load(getUserId(request));
    user.populateModel(data);
    for (String key : data.keySet()) {
        if (StringUtils.isNotBlank(request.getParameter(key))) {
            data.put(key, request.getParameter(key));
        }
    }
    List<PipelineConfigs> groups = pipelineConfigService.viewableGroupsFor(getUserName());
    data.put("pipelines", new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().toJson(getPipelineModelsSortedByNameFor(groups)));
    data.put("l", localizer);
    message.populateModel(data);
    return new ModelAndView("mycruise/mycruise-tab", data);
}
Also used : User(com.thoughtworks.go.domain.User) GsonBuilder(com.google.gson.GsonBuilder) ModelAndView(org.springframework.web.servlet.ModelAndView) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs)

Example 14 with PipelineConfigs

use of com.thoughtworks.go.config.PipelineConfigs in project gocd by gocd.

the class MyGoController method getPipelineModelsSortedByNameFor.

private List<PipelineViewModel> getPipelineModelsSortedByNameFor(List<PipelineConfigs> groups) {
    List<PipelineViewModel> pipelineModels = new ArrayList<>();
    List<PipelineViewModel.StageViewModel> anyPipelineStageModels = new ArrayList<>();
    anyPipelineStageModels.add(new PipelineViewModel.StageViewModel(GoConstants.ANY_STAGE));
    pipelineModels.add(new PipelineViewModel(GoConstants.ANY_PIPELINE, anyPipelineStageModels));
    for (PipelineConfigs group : groups) {
        for (PipelineConfig pipelineConfig : group) {
            pipelineModels.add(new PipelineViewModel(CaseInsensitiveString.str(pipelineConfig.name()), getStagesModelsFor(pipelineConfig)));
        }
    }
    Collections.sort(pipelineModels);
    return pipelineModels;
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PipelineViewModel(com.thoughtworks.go.server.presentation.models.PipelineViewModel) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs)

Example 15 with PipelineConfigs

use of com.thoughtworks.go.config.PipelineConfigs in project gocd by gocd.

the class MaterialConfigService method getMaterialConfig.

public MaterialConfig getMaterialConfig(String username, String materialFingerprint, OperationResult result) {
    MaterialConfig materialConfig = null;
    boolean hasViewPermissionForMaterial = false;
    for (PipelineConfigs pipelineGroup : goConfigService.groups()) {
        boolean hasViewPermissionForGroup = securityService.hasViewPermissionForGroup(username, pipelineGroup.getGroup());
        for (PipelineConfig pipelineConfig : pipelineGroup) {
            for (MaterialConfig currentMaterialConfig : pipelineConfig.materialConfigs()) {
                if (currentMaterialConfig.getFingerprint().equals(materialFingerprint)) {
                    materialConfig = currentMaterialConfig;
                    if (hasViewPermissionForGroup) {
                        hasViewPermissionForMaterial = true;
                        break;
                    }
                }
            }
        }
    }
    if (materialConfig == null) {
        result.notFound("Not Found", "Material not found", HealthStateType.general(HealthStateScope.GLOBAL));
        return null;
    }
    if (!hasViewPermissionForMaterial) {
        result.unauthorized("Unauthorized", "Do not have view permission to this material", HealthStateType.general(HealthStateScope.GLOBAL));
        return null;
    }
    return materialConfig;
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs)

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