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));
}
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."));
}
Aggregations