Skip to content

Commit

Permalink
Added unit test based on user forum issue
Browse files Browse the repository at this point in the history
  • Loading branch information
davsclaus committed Oct 28, 2024
1 parent 96d790e commit 1b068df
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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;
Expand Down Expand Up @@ -74,6 +75,29 @@ public void authorizationHeaderIsPresent() {

}

@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));
}
Expand Down

0 comments on commit 1b068df

Please sign in to comment.