From 30def31ea739857e18a82cc8e7641a0f3262bd0b Mon Sep 17 00:00:00 2001 From: Bob Barrett Date: Thu, 24 Jun 2021 01:47:27 -0700 Subject: [PATCH] Fix tests to support ProxyConnectionFactory --- .../io/confluent/kafkarest/testing/KafkaRestFixture.java | 5 +++++ .../confluent/kafkarest/testing/SchemaRegistryFixture.java | 5 +++++ pom.xml | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/kafka-rest/src/test/java/io/confluent/kafkarest/testing/KafkaRestFixture.java b/kafka-rest/src/test/java/io/confluent/kafkarest/testing/KafkaRestFixture.java index 5a34aa5793..0df859fbf5 100644 --- a/kafka-rest/src/test/java/io/confluent/kafkarest/testing/KafkaRestFixture.java +++ b/kafka-rest/src/test/java/io/confluent/kafkarest/testing/KafkaRestFixture.java @@ -76,6 +76,11 @@ public void before() throws Exception { server = application.createServer(); server.start(); baseUri = server.getURI(); + if (certificates != null && baseUri.getScheme().equals("http")) { + // If PROXY protocol is enabled, the base URI will come back as http because the first connection + // factory is not the SSL factory. If we want SSL, explicitly set the scheme here + baseUri = new URI(baseUri.toString().replace("http", "https")); + } } private KafkaRestConfig createConfigs() { diff --git a/kafka-rest/src/test/java/io/confluent/kafkarest/testing/SchemaRegistryFixture.java b/kafka-rest/src/test/java/io/confluent/kafkarest/testing/SchemaRegistryFixture.java index b6cebdf840..58e77f8bf0 100644 --- a/kafka-rest/src/test/java/io/confluent/kafkarest/testing/SchemaRegistryFixture.java +++ b/kafka-rest/src/test/java/io/confluent/kafkarest/testing/SchemaRegistryFixture.java @@ -85,6 +85,11 @@ public void before() throws Exception { server = new SchemaRegistryRestApplication(createConfigs()).createServer(); server.start(); baseUri = server.getURI(); + if (certificates != null && baseUri.getScheme().equals("http")) { + // If PROXY protocol is enabled, the base URI will come back as http because the first connection + // factory is not the SSL factory. If we want SSL, explicitly set the scheme here + baseUri = new URI(baseUri.toString().replace("http", "https")); + } client = new CachedSchemaRegistryClient( singletonList(baseUri.toString()), diff --git a/pom.xml b/pom.xml index 45e346dd44..4c7ff1575c 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,8 @@ io.confluent rest-utils-parent - [7.0.0-0, 7.0.1-0) + 7.0.0-0 + kafka-rest-parent