|
9 | 9 | import io.strimzi.kafka.bridge.config.BridgeConfig;
|
10 | 10 | import io.strimzi.kafka.bridge.http.model.HttpBridgeError;
|
11 | 11 | import io.strimzi.kafka.bridge.utils.Urls;
|
| 12 | +import io.vertx.core.MultiMap; |
| 13 | +import io.vertx.core.http.CaseInsensitiveHeaders; |
12 | 14 | import io.vertx.core.json.JsonArray;
|
13 | 15 | import io.vertx.core.json.JsonObject;
|
14 | 16 | import io.vertx.ext.web.client.HttpResponse;
|
@@ -235,6 +237,38 @@ void createConsumerWithForwardedHeader(VertxTestContext context) throws Interrup
|
235 | 237 | assertTrue(context.awaitCompletion(TEST_TIMEOUT, TimeUnit.SECONDS));
|
236 | 238 | }
|
237 | 239 |
|
| 240 | + @Test |
| 241 | + void createConsumerWithMultipleForwardedHeaders(VertxTestContext context) throws InterruptedException { |
| 242 | + String forwarded = "host=my-api-gateway-host:443;proto=https"; |
| 243 | + String forwarded2 = "host=my-api-another-gateway-host:886;proto=http"; |
| 244 | + |
| 245 | + String baseUri = "https://my-api-gateway-host:443/consumers/" + groupId + "/instances/" + name; |
| 246 | + |
| 247 | + // we have to use MultiMap because of https://github.com/vert-x3/vertx-web/issues/1383 |
| 248 | + MultiMap headers = new CaseInsensitiveHeaders(); |
| 249 | + headers.add(FORWARDED, forwarded); |
| 250 | + headers.add(FORWARDED, forwarded2); |
| 251 | + |
| 252 | + consumerService().createConsumerRequest(groupId, consumerWithEarliestReset) |
| 253 | + .putHeaders(headers) |
| 254 | + .sendJsonObject(consumerWithEarliestReset, ar -> { |
| 255 | + context.verify(() -> { |
| 256 | + assertTrue(ar.succeeded()); |
| 257 | + HttpResponse<JsonObject> response = ar.result(); |
| 258 | + assertEquals(HttpResponseStatus.OK.code(), response.statusCode()); |
| 259 | + JsonObject bridgeResponse = response.body(); |
| 260 | + String consumerInstanceId = bridgeResponse.getString("instance_id"); |
| 261 | + String consumerBaseUri = bridgeResponse.getString("base_uri"); |
| 262 | + assertEquals(name, consumerInstanceId); |
| 263 | + assertEquals(baseUri, consumerBaseUri); |
| 264 | + }); |
| 265 | + context.completeNow(); |
| 266 | + }); |
| 267 | + |
| 268 | + assertTrue(context.awaitCompletion(TEST_TIMEOUT, TimeUnit.SECONDS)); |
| 269 | + } |
| 270 | + |
| 271 | + |
238 | 272 | @Test
|
239 | 273 | void createConsumerWithForwardedPathHeader(VertxTestContext context) throws InterruptedException {
|
240 | 274 | // this test emulates a create consumer request coming from an API gateway/proxy
|
|
0 commit comments