diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestClientAuthentication.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestClientAuthentication.java index fa54a3507..afde7f23a 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestClientAuthentication.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestClientAuthentication.java @@ -217,6 +217,34 @@ public class TestClientAuthentication extends IntegrationTestBase { Assert.assertEquals("test realm", authscope.getRealm()); } + @Test + public void testBasicAuthenticationWithEntitySuccess() throws Exception { + server.register("*", new Supplier() { + + @Override + public AsyncServerExchangeHandler get() { + return new AsyncEchoHandler(); + } + + }); + final HttpHost target = start(); + + final TestCredentialsProvider credsProvider = new TestCredentialsProvider( + new UsernamePasswordCredentials("test", "test".toCharArray())); + final HttpClientContext context = HttpClientContext.create(); + context.setCredentialsProvider(credsProvider); + + final Future future = httpclient.execute( + SimpleHttpRequest.put(target, "/", "Some important stuff", ContentType.TEXT_PLAIN), context, null); + final HttpResponse response = future.get(); + + Assert.assertNotNull(response); + Assert.assertEquals(HttpStatus.SC_OK, response.getCode()); + final AuthScope authscope = credsProvider.getAuthScope(); + Assert.assertNotNull(authscope); + Assert.assertEquals("test realm", authscope.getRealm()); + } + @Test public void testBasicAuthenticationSuccessNonPersistentConnection() throws Exception { server.register("*", new Supplier() { @@ -276,6 +304,7 @@ public class TestClientAuthentication extends IntegrationTestBase { new UsernamePasswordCredentials("test", "all-wrong".toCharArray())); final HttpClientContext context = HttpClientContext.create(); context.setCredentialsProvider(credsProvider); + context.setRequestConfig(RequestConfig.custom().setExpectContinueEnabled(true).build()); final Future future = httpclient.execute( SimpleHttpRequest.put(target, "/", "Some important stuff", ContentType.TEXT_PLAIN), context, null); @@ -301,6 +330,7 @@ public class TestClientAuthentication extends IntegrationTestBase { new UsernamePasswordCredentials("test", "test".toCharArray())); final HttpClientContext context = HttpClientContext.create(); context.setCredentialsProvider(credsProvider); + context.setRequestConfig(RequestConfig.custom().setExpectContinueEnabled(true).build()); final Future future = httpclient.execute( SimpleHttpRequest.put(target, "/", "Some important stuff", ContentType.TEXT_PLAIN), context, null);