Search in sources :

Example 1 with ConfigForEdit

use of com.thoughtworks.go.presentation.ConfigForEdit in project gocd by gocd.

the class GoConfigServiceIntegrationTest method shouldOnlyAllowAdminsToGetPipelineConfig.

@Test
public void shouldOnlyAllowAdminsToGetPipelineConfig() throws IOException {
    setupSecurity();
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    ConfigForEdit configForEdit = goConfigService.loadForEdit("my-pipeline", new Username(new CaseInsensitiveString("loser")), result);
    assertThat(configForEdit, is(nullValue()));
    assertThat(result.httpCode(), is(401));
    assertThat(result.message(localizer), is("Unauthorized to edit my-pipeline pipeline."));
    result = new HttpLocalizedOperationResult();
    configForEdit = goConfigService.loadForEdit("my-pipeline", new Username(new CaseInsensitiveString("pipeline_admin")), result);
    assertThat(configForEdit, not(nullValue()));
    assertThat(result.isSuccessful(), is(true));
    result = new HttpLocalizedOperationResult();
    configForEdit = goConfigService.loadForEdit("my-pipeline", new Username(new CaseInsensitiveString("root")), result);
    assertThat(configForEdit, not(nullValue()));
    assertThat(result.isSuccessful(), is(true));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) ConfigForEdit(com.thoughtworks.go.presentation.ConfigForEdit) Test(org.junit.Test)

Example 2 with ConfigForEdit

use of com.thoughtworks.go.presentation.ConfigForEdit in project gocd by gocd.

the class GoConfigServiceIntegrationTest method shouldReturn404WhenUserIsNotAnAdminAndTriesToLoadANonExistentPipeline.

@Test
public void shouldReturn404WhenUserIsNotAnAdminAndTriesToLoadANonExistentPipeline() throws IOException {
    setupSecurity();
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    ConfigForEdit configForEdit = goConfigService.loadForEdit("non-existent-pipeline", new Username(new CaseInsensitiveString("loser")), result);
    assertThat(configForEdit, is(nullValue()));
    assertThat(result.httpCode(), is(404));
    assertThat(result.message(localizer), is("pipeline 'non-existent-pipeline' not found."));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) ConfigForEdit(com.thoughtworks.go.presentation.ConfigForEdit) Test(org.junit.Test)

Aggregations

ConfigForEdit (com.thoughtworks.go.presentation.ConfigForEdit)2 Username (com.thoughtworks.go.server.domain.Username)2 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)2 Test (org.junit.Test)2