@Test public void getStageAsXmlPartial_shouldEnforcePipelineGroupAdminPermissions() throws Exception { String md5 = setUpPipelineGroupsWithAdminPermissions(); controller.getStageAsXmlPartial("go", 0, md5, response); assertThat(response.getStatus(), is(SC_UNAUTHORIZED)); assertThat( response.getContentAsString(), is("User 'ram' does not have permissions to administer pipeline group 'studios'")); controller.getStageAsXmlPartial("bcg", 0, md5, response); assertThat(response.getStatus(), is(SC_OK)); }
@Test public void shouldGetStageAsPartialXml() throws Exception { configHelper.addPipeline("pipeline", "dev", "linux", "windows"); controller.getStageAsXmlPartial("pipeline", 0, null, response); assertValidContentAndStatus( SC_OK, "text/xml", "<stage name=\"dev\">\n" + " <jobs>\n" + " <job name=\"linux\" />\n" + " <job name=\"windows\" />\n" + " </jobs>\n" + "</stage>"); }
@Test public void shouldGetErrorMessageWhenPipelineDoesNotExistAndGettingStage() throws Exception { configHelper.addPipeline("pipeline", "stage", "build1"); controller.getStageAsXmlPartial("unknown", 0, null, response); assertValidContentAndStatus(SC_NOT_FOUND, RESPONSE_CHARSET, "Pipeline 'unknown' not found."); }
@Test public void shouldGetErrorMessageWhenStageDoesNotExist() throws Exception { configHelper.addPipeline("pipeline", "stage", "build1"); controller.getStageAsXmlPartial("pipeline", 1, null, response); assertValidContentAndStatus(SC_NOT_FOUND, RESPONSE_CHARSET, "Stage does not exist."); }