use of io.servicetalk.http.api.StreamingHttpRequest in project servicetalk by apple.
the class RedirectingHttpRequesterFilterTest method newClient.
private StreamingHttpClient newClient(RedirectConfig config, StreamingHttpClientFilterFactory... other) {
StreamingHttpClientFilterFactory result = new RedirectingHttpRequesterFilter(config);
for (StreamingHttpClientFilterFactory next : other) {
result = appendClientFilterFactory(result, next);
}
StreamingHttpClientFilterFactory mockResponse = client -> new StreamingHttpClientFilter(client) {
@Override
protected Single<StreamingHttpResponse> request(final StreamingHttpRequester delegate, final StreamingHttpRequest request) {
return httpClient.request(request);
}
};
return from(reqRespFactory, mock(HttpExecutionContext.class), appendClientFilterFactory(result, mockResponse));
}
use of io.servicetalk.http.api.StreamingHttpRequest in project servicetalk by apple.
the class RedirectingHttpRequesterFilterTest method changePostToGet.
@ParameterizedTest(name = "{displayName} [{index}] allowNonRelativeRedirects={0}")
@ValueSource(ints = { 301, 302 })
void changePostToGet(int statusCode) throws Exception {
when(httpClient.request(any())).thenReturn(redirectResponse(HttpResponseStatus.of(statusCode, "")), okResponse());
StreamingHttpClient client = newClient(new RedirectConfigBuilder().allowedMethods(POST).changePostToGet(true).build());
StreamingHttpRequest request = newRequest(client, POST);
StreamingHttpRequest redirectedRequest = verifyResponse(client, request, OK, -1, 2, GET);
assertThat("Request didn't change", request, not(sameInstance(redirectedRequest)));
verifyHeadersAndMessageBodyRedirected(redirectedRequest);
verifyRedirectResponsePayloadsDrained(true);
}
use of io.servicetalk.http.api.StreamingHttpRequest in project servicetalk by apple.
the class BasicAuthHttpServiceFilterTest method authenticatedBasicTokenInBetween.
@Test
void authenticatedBasicTokenInBetween() throws Exception {
StreamingHttpRequest request = reqRespFactory.get("/path");
request.headers().set(AUTHORIZATION, "Other token1, Basic " + base64("userId:password") + ", Some token2");
testAuthenticated(request);
}
use of io.servicetalk.http.api.StreamingHttpRequest in project servicetalk by apple.
the class BasicAuthHttpServiceFilterTest method emptyBasicTokenInAuthorizationHeader.
@Test
void emptyBasicTokenInAuthorizationHeader() throws Exception {
StreamingHttpRequest request = reqRespFactory.get("/path");
request.headers().set(AUTHORIZATION, "OtherScheme qwe, Basic ");
testUnauthorized(request);
}
use of io.servicetalk.http.api.StreamingHttpRequest in project servicetalk by apple.
the class BasicAuthHttpServiceFilterTest method noUserIdInToken.
@Test
void noUserIdInToken() throws Exception {
StreamingHttpRequest request = reqRespFactory.get("/path");
request.headers().set(AUTHORIZATION, "Basic " + base64("no-colon"));
testUnauthorized(request);
}
Aggregations