You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2023/03/22 13:58:08 UTC

[camel] branch CAMEL-19184/use-http-context-with-httpcomponents-v5 updated (6048147601e -> 3042a688927)

This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a change to branch CAMEL-19184/use-http-context-with-httpcomponents-v5
in repository https://gitbox.apache.org/repos/asf/camel.git


 discard 6048147601e CAMEL-19184: camel-http - Add test to validate authentication with httpContext
     new 3042a688927 CAMEL-19184: camel-http - Add test for authentication with httpContext

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (6048147601e)
            \
             N -- N -- N   refs/heads/CAMEL-19184/use-http-context-with-httpcomponents-v5 (3042a688927)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:


[camel] 01/01: CAMEL-19184: camel-http - Add test for authentication with httpContext

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-19184/use-http-context-with-httpcomponents-v5
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 3042a688927bfe9577245fa67a79d5f2c810549d
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Wed Mar 22 14:56:55 2023 +0100

    CAMEL-19184: camel-http - Add test for authentication with httpContext
---
 .../component/http/HttpsAuthenticationTest.java    | 41 ++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsAuthenticationTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsAuthenticationTest.java
index 2ce323579d8..4dc5ba73df3 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsAuthenticationTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpsAuthenticationTest.java
@@ -25,12 +25,20 @@ import org.apache.camel.component.http.handler.AuthenticationValidationHandler;
 import org.apache.camel.component.http.interceptor.RequestBasicAuth;
 import org.apache.camel.component.http.interceptor.ResponseBasicUnauthorized;
 import org.apache.camel.support.jsse.SSLContextParameters;
+import org.apache.hc.client5.http.auth.AuthScope;
+import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
+import org.apache.hc.client5.http.impl.auth.BasicAuthCache;
+import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
+import org.apache.hc.client5.http.impl.auth.BasicScheme;
+import org.apache.hc.client5.http.protocol.HttpClientContext;
 import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
+import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.HttpRequestInterceptor;
 import org.apache.hc.core5.http.HttpResponseInterceptor;
 import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
 import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
+import org.apache.hc.core5.http.protocol.HttpContext;
 import org.apache.hc.core5.http.protocol.HttpProcessor;
 import org.apache.hc.core5.http.protocol.ResponseContent;
 import org.junit.jupiter.api.AfterEach;
@@ -50,6 +58,8 @@ public class HttpsAuthenticationTest extends BaseHttpsTest {
 
     @BindToRegistry("sslContextParameters")
     private SSLContextParameters sslContextParameters = new SSLContextParameters();
+    @BindToRegistry("basicAuthContext")
+    private HttpContext basicAuthContexts = basicAuthContext();
 
     @BeforeEach
     @Override
@@ -75,6 +85,26 @@ public class HttpsAuthenticationTest extends BaseHttpsTest {
         }
     }
 
+    HttpContext basicAuthContext() {
+
+        char[] chars = new char[7];
+        password.getChars(1, 7, chars, 0);
+
+        UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(user, password.toCharArray());
+        BasicCredentialsProvider provider = new BasicCredentialsProvider();
+        provider.setCredentials(new AuthScope(null, -1), credentials);
+
+        BasicAuthCache authCache = new BasicAuthCache();
+        BasicScheme basicAuth = new BasicScheme();
+        authCache.put(new HttpHost("localhost", 8083), basicAuth);
+
+        HttpClientContext context = HttpClientContext.create();
+        context.setAuthCache(authCache);
+        context.setCredentialsProvider(provider);
+
+        return context;
+    }
+
     @Test
     public void httpsGetWithAuthentication() throws Exception {
 
@@ -86,6 +116,17 @@ public class HttpsAuthenticationTest extends BaseHttpsTest {
         assertExchange(exchange);
     }
 
+    @Test
+    public void httpsGetWithHttpCache() throws Exception {
+
+        Exchange exchange = template.request("https://localhost:" + localServer.getLocalPort()
+                                             + "?throwExceptionOnFailure=false&httpContext=#basicAuthContext",
+                exchange1 -> {
+                });
+
+        assertExchange(exchange);
+    }
+
     @Override
     protected HttpProcessor getBasicHttpProcessor() {
         List<HttpRequestInterceptor> requestInterceptors = new ArrayList<>();