This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 1b068df4c5c Added unit test based on user forum issue 1b068df4c5c is described below commit 1b068df4c5cf312d314955a820473e3f8efd2dda Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Mon Oct 28 12:59:38 2024 +0100 Added unit test based on user forum issue --- .../http/HttpOAuth2AuthenticationTest.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpOAuth2AuthenticationTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpOAuth2AuthenticationTest.java index b8607b6c212..223b53457b1 100644 --- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpOAuth2AuthenticationTest.java +++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpOAuth2AuthenticationTest.java @@ -20,6 +20,7 @@ import java.util.HashMap; import java.util.Map; import org.apache.camel.Exchange; +import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.http.handler.HeaderValidationHandler; import org.apache.camel.component.http.handler.OAuth2TokenRequestHandler; import org.apache.hc.core5.http.HttpStatus; @@ -74,6 +75,29 @@ public class HttpOAuth2AuthenticationTest extends BaseHttpTest { } + @Test + public void toDauthorizationHeaderIsPresent() throws Exception { + String tokenEndpoint = "http://localhost:" + localServer.getLocalPort() + "/token"; + + context.addRoutes(new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start") + .setVariable("cid", constant(clientId)) + .setVariable("cs", constant(clientSecret)) + .toD("http://localhost:" + localServer.getLocalPort() + + "/post?httpMethod=POST&oauth2ClientId=${variable.cid}" + + "&oauth2ClientSecret=${variable:cs}&oauth2TokenEndpoint=" + tokenEndpoint); + } + }); + + Exchange exchange = template.send("direct:start", e -> { + }); + + assertExchange(exchange); + + } + protected void assertHeaders(Map<String, Object> headers) { assertEquals(HttpStatus.SC_OK, headers.get(Exchange.HTTP_RESPONSE_CODE)); }