From a6879eabbeb10d0abc023b67067018c23df02d3e Mon Sep 17 00:00:00 2001 From: Alon Adam Date: Sun, 22 Dec 2024 17:08:00 +0200 Subject: [PATCH 1/3] Auth metadata endpoint is always rooted. --- .../com/microsoft/azure/kusto/data/auth/CloudInfo.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/data/src/main/java/com/microsoft/azure/kusto/data/auth/CloudInfo.java b/data/src/main/java/com/microsoft/azure/kusto/data/auth/CloudInfo.java index fd69babd..64d08d17 100644 --- a/data/src/main/java/com/microsoft/azure/kusto/data/auth/CloudInfo.java +++ b/data/src/main/java/com/microsoft/azure/kusto/data/auth/CloudInfo.java @@ -17,6 +17,7 @@ import com.microsoft.azure.kusto.data.instrumentation.MonitoredActivity; import com.microsoft.azure.kusto.data.req.RequestUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.http.client.utils.URIBuilder; import org.jetbrains.annotations.Nullable; import reactor.core.publisher.Mono; @@ -127,7 +128,11 @@ private static CloudInfo fetchImpl(String clusterUrl, @Nullable HttpClient given CloudInfo result; HttpClient localHttpClient = givenHttpClient == null ? HttpClientFactory.create(null) : givenHttpClient; try { - HttpRequest request = new HttpRequest(HttpMethod.GET, UriUtils.appendPathToUri(clusterUrl, METADATA_ENDPOINT)); + // Metadata endpoint is always on the root of the cluster + URIBuilder metadataEndpointUriBuilder = new URIBuilder(clusterUrl); + metadataEndpointUriBuilder.setPath(METADATA_ENDPOINT); + + HttpRequest request = new HttpRequest(HttpMethod.GET, metadataEndpointUriBuilder.build().toString()); request.setHeader(HttpHeaderName.ACCEPT_ENCODING, "gzip,deflate"); request.setHeader(HttpHeaderName.ACCEPT, "application/json"); From 61996863fa093123e14bf36d78271c60391aae4e Mon Sep 17 00:00:00 2001 From: Alon Adam Date: Sun, 22 Dec 2024 17:24:22 +0200 Subject: [PATCH 2/3] Ignore failing test. --- .../src/test/java/com/microsoft/azure/kusto/ingest/E2ETest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/ingest/src/test/java/com/microsoft/azure/kusto/ingest/E2ETest.java b/ingest/src/test/java/com/microsoft/azure/kusto/ingest/E2ETest.java index 06c01528..63b6d347 100644 --- a/ingest/src/test/java/com/microsoft/azure/kusto/ingest/E2ETest.java +++ b/ingest/src/test/java/com/microsoft/azure/kusto/ingest/E2ETest.java @@ -677,6 +677,7 @@ void testSameHttpClientInstance() throws DataClientException, DataServiceExcepti } + @Disabled("This test is disabled because it relies on the path part of the cluster Uri which we now ignore") @Test void testNoRedirectsCloudFail() { KustoTrustedEndpoints.addTrustedHosts(Collections.singletonList(new MatchRule("statusreturner.azurewebsites.net", false)), false); From befc50e76f5f9f496a2f946fcacf63eaee93e005 Mon Sep 17 00:00:00 2001 From: Alon Adam Date: Mon, 23 Dec 2024 11:31:11 +0200 Subject: [PATCH 3/3] Use UriUtils instead of UriBuilder. --- .../java/com/microsoft/azure/kusto/data/auth/CloudInfo.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/data/src/main/java/com/microsoft/azure/kusto/data/auth/CloudInfo.java b/data/src/main/java/com/microsoft/azure/kusto/data/auth/CloudInfo.java index 64d08d17..ea1a3aa2 100644 --- a/data/src/main/java/com/microsoft/azure/kusto/data/auth/CloudInfo.java +++ b/data/src/main/java/com/microsoft/azure/kusto/data/auth/CloudInfo.java @@ -17,7 +17,6 @@ import com.microsoft.azure.kusto.data.instrumentation.MonitoredActivity; import com.microsoft.azure.kusto.data.req.RequestUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.http.client.utils.URIBuilder; import org.jetbrains.annotations.Nullable; import reactor.core.publisher.Mono; @@ -129,10 +128,7 @@ private static CloudInfo fetchImpl(String clusterUrl, @Nullable HttpClient given HttpClient localHttpClient = givenHttpClient == null ? HttpClientFactory.create(null) : givenHttpClient; try { // Metadata endpoint is always on the root of the cluster - URIBuilder metadataEndpointUriBuilder = new URIBuilder(clusterUrl); - metadataEndpointUriBuilder.setPath(METADATA_ENDPOINT); - - HttpRequest request = new HttpRequest(HttpMethod.GET, metadataEndpointUriBuilder.build().toString()); + HttpRequest request = new HttpRequest(HttpMethod.GET, UriUtils.setPathForUri(clusterUrl, METADATA_ENDPOINT)); request.setHeader(HttpHeaderName.ACCEPT_ENCODING, "gzip,deflate"); request.setHeader(HttpHeaderName.ACCEPT, "application/json");