use of com.thoughtworks.go.http.mocks.MockHttpServletResponse in project gocd by gocd.
the class RequestRejectedExceptionHandlerTest method shouldHandleUrlsAsApiRequest.
@ParameterizedTest
@ValueSource(strings = { "/remoting/foo", "/add-on/bar/api/foo", "/api/foo", "/cctray.xml" })
void shouldHandleUrlsAsApiRequest(String url) throws IOException {
final MockHttpServletRequest request = HttpRequestBuilder.GET(url).withHeader("Accept", "application/json").build();
final MockHttpServletResponse response = new MockHttpServletResponse();
new RequestRejectedExceptionHandler().handle(request, response, "Something went wrong", HttpStatus.BAD_REQUEST);
assertThat(response).isBadRequest().hasBody("{\n" + " \"message\": \"Something went wrong\"\n" + "}");
}
use of com.thoughtworks.go.http.mocks.MockHttpServletResponse in project gocd by gocd.
the class DenyGoCDAccessForArtifactsFilterChainTest method setUp.
@BeforeEach
void setUp() {
response = new MockHttpServletResponse();
filter = new DenyGoCDAccessForArtifactsFilterChain();
filterChain = mock(FilterChain.class);
}
use of com.thoughtworks.go.http.mocks.MockHttpServletResponse in project gocd by gocd.
the class AbstractBasicAuthenticationFilterTest method setUp.
@BeforeEach
void setUp() {
clock = new TestingClock();
securityService = mock(SecurityService.class);
authenticationProvider = mock(PasswordBasedPluginAuthenticationProvider.class);
response = new MockHttpServletResponse();
filterChain = mock(FilterChain.class);
filter = spy(new AbstractBasicAuthenticationFilter(securityService, authenticationProvider) {
@Override
protected void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, String errorMessage) throws IOException {
}
});
}
use of com.thoughtworks.go.http.mocks.MockHttpServletResponse in project gocd by gocd.
the class AbstractUserEnabledCheckFilterTest method setUp.
@BeforeEach
void setUp() throws Exception {
userService = mock(UserService.class);
securityService = mock(SecurityService.class);
filter = spy(new AbstractUserEnabledCheckFilter(userService, securityService) {
@Override
void handleFailure(HttpServletRequest request, HttpServletResponse response, String errorMessage) throws IOException {
}
});
request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
filterChain = mock(FilterChain.class);
}
use of com.thoughtworks.go.http.mocks.MockHttpServletResponse in project gocd by gocd.
the class AssumeAnonymousUserFilterTest method setUp.
@BeforeEach
void setUp() {
clock = new TestingClock();
securityService = mock(SecurityService.class);
anonymousAuthenticationProvider = new AnonymousAuthenticationProvider(clock, new AuthorityGranter(securityService));
filterChain = mock(FilterChain.class);
response = new MockHttpServletResponse();
request = new MockHttpServletRequest();
}
Aggregations