Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 133A1200D0F for ; Fri, 29 Sep 2017 17:05:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 11E121609C5; Fri, 29 Sep 2017 15:05:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 58F3C1609ED for ; Fri, 29 Sep 2017 17:05:21 +0200 (CEST) Received: (qmail 66251 invoked by uid 500); 29 Sep 2017 15:05:20 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 66178 invoked by uid 99); 29 Sep 2017 15:05:20 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Sep 2017 15:05:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 54E47F5BD5; Fri, 29 Sep 2017 15:05:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: olegk@apache.org To: commits@hc.apache.org Date: Fri, 29 Sep 2017 15:05:21 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/2] httpcomponents-client git commit: Corrected configuration of the 'expect-continue' handshake in async client authentication tests archived-at: Fri, 29 Sep 2017 15:05:22 -0000 Corrected configuration of the 'expect-continue' handshake in async client authentication tests Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/repo Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/commit/5203c669 Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/tree/5203c669 Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/diff/5203c669 Branch: refs/heads/master Commit: 5203c669289e15fa8dd6ce2e257e94c36423bd2d Parents: 18e56cc Author: Oleg Kalnichevski Authored: Thu Sep 28 15:39:43 2017 +0200 Committer: Oleg Kalnichevski Committed: Fri Sep 29 17:02:41 2017 +0200 ---------------------------------------------------------------------- .../testing/async/TestClientAuthentication.java | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/5203c669/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestClientAuthentication.java ---------------------------------------------------------------------- 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 fa54a35..afde7f2 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 @@ -218,6 +218,34 @@ public class TestClientAuthentication extends IntegrationTestBase { } @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);