use of com.thoughtworks.go.server.web.ResponseCodeView in project gocd by gocd.
the class ArtifactsControllerIntegrationTest method shouldReturn404WhenFileNotFound.
@Test
public void shouldReturn404WhenFileNotFound() throws Exception {
ModelAndView mav = getFileAsHtml("/foo.xml");
assertThat(mav.getView().getContentType(), is(RESPONSE_CHARSET));
assertThat(mav.getView(), is(instanceOf((ResponseCodeView.class))));
assertThat(((ResponseCodeView) mav.getView()).getContent(), containsString("Artifact '/foo.xml' is unavailable as it may have been purged by Go or deleted externally."));
}
use of com.thoughtworks.go.server.web.ResponseCodeView in project gocd by gocd.
the class ArtifactsControllerTest method shouldReturnBadRequestIfRequiredHeadersAreMissingOnACreateArtifactRequest.
@Test
public void shouldReturnBadRequestIfRequiredHeadersAreMissingOnACreateArtifactRequest() throws Exception {
MultipartHttpServletRequest multipartHttpServletRequest = new MockMultipartHttpServletRequest();
when(systemEnvironment.isApiSafeModeEnabled()).thenReturn(true);
ModelAndView modelAndView = artifactsController.postArtifact("pipeline", "invalid-label", "stage", "stage-counter", "job-name", 3L, "file-path", 3, multipartHttpServletRequest);
ResponseCodeView codeView = (ResponseCodeView) modelAndView.getView();
assertThat(codeView.getStatusCode(), is(HttpServletResponse.SC_BAD_REQUEST));
assertThat(codeView.getContent(), is("Missing required header 'Confirm'"));
}
use of com.thoughtworks.go.server.web.ResponseCodeView in project gocd by gocd.
the class StageControllerIntegrationTest method shouldReturnBadRequestIfRequiredHeadersAreMissing.
@Test
public void shouldReturnBadRequestIfRequiredHeadersAreMissing() {
MockHttpServletRequest mockHttpServletRequest = new MockHttpServletRequest();
mockHttpServletRequest.addHeader("Confirm", "false");
ModelAndView modelAndView = controller.rerunStage("pipeline", "invalid-label", "stage", response, mockHttpServletRequest);
ResponseCodeView codeView = (ResponseCodeView) modelAndView.getView();
assertThat(codeView.getStatusCode(), is(HttpServletResponse.SC_BAD_REQUEST));
assertThat(codeView.getContent(), is("Missing required header 'Confirm'"));
}
use of com.thoughtworks.go.server.web.ResponseCodeView in project gocd by gocd.
the class StageControllerIntegrationTest method shouldReturn404WhenReRunningNonExistantStage.
@Test
public void shouldReturn404WhenReRunningNonExistantStage() throws Exception {
Pipeline pipeline = fixture.createPipelineWithFirstStagePassedAndSecondStageHasNotStarted();
ModelAndView mav = controller.rerunStage(fixture.pipelineName, pipeline.getLabel(), "doesNotExist", response, request);
ResponseCodeView codeView = (ResponseCodeView) mav.getView();
assertThat(codeView.getStatusCode(), is(HttpServletResponse.SC_NOT_FOUND));
assertThat(codeView.getContent(), is("Stage 'doesNotExist' not found in pipeline '" + fixture.pipelineName + "'"));
}
use of com.thoughtworks.go.server.web.ResponseCodeView in project gocd by gocd.
the class ArtifactsControllerIntegrationTest method testConsoleOutShouldReturn404WhenJobIsNotFound.
@Test
public void testConsoleOutShouldReturn404WhenJobIsNotFound() throws Exception {
prepareConsoleOut("");
Stage firstStage = pipeline.getFirstStage();
int startLineNumber = 0;
ModelAndView view = artifactsController.consoleout("snafu", "snafu", "snafu", "build", String.valueOf(firstStage.getCounter()), startLineNumber);
assertThat(view.getView().getContentType(), is(RESPONSE_CHARSET));
assertThat(view.getView(), is(instanceOf((ResponseCodeView.class))));
assertThat(((ResponseCodeView) view.getView()).getContent(), containsString("Job snafu/snafu/snafu/1/build not found."));
}
Aggregations