From b2ab54202fc82fdc3c820b34ba550b9e6dc941ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Hofman?= Date: Thu, 5 Sep 2024 20:21:06 +0200 Subject: [PATCH] SNOW-1651983 authenticated proxy on azure --- parent-pom.xml | 2 +- src/main/java/net/snowflake/client/core/HttpUtil.java | 10 ++++++---- .../client/core/CoreUtilsMiscellaneousTest.java | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/parent-pom.xml b/parent-pom.xml index 28412d161..9fecf4ea3 100644 --- a/parent-pom.xml +++ b/parent-pom.xml @@ -24,7 +24,7 @@ 1.8.1 4.2.0 1.12.655 - 5.0.0 + 8.6.6 1.74 1.0.2.4 1.0.5 diff --git a/src/main/java/net/snowflake/client/core/HttpUtil.java b/src/main/java/net/snowflake/client/core/HttpUtil.java index 166bd7e0a..b55755b9a 100644 --- a/src/main/java/net/snowflake/client/core/HttpUtil.java +++ b/src/main/java/net/snowflake/client/core/HttpUtil.java @@ -225,11 +225,13 @@ public static void setSessionlessProxyForAzure( */ public static void setProxyForAzure(HttpClientSettingsKey key, OperationContext opContext) { if (key != null && key.usesProxy()) { - Proxy azProxy = - new Proxy(Proxy.Type.HTTP, new InetSocketAddress(key.getProxyHost(), key.getProxyPort())); - logger.debug( - "Setting Azure proxy. Host: {}, port: {}", key.getProxyHost(), key.getProxyPort()); + Proxy azProxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(key.getProxyHost(), key.getProxyPort())); opContext.setProxy(azProxy); + if (!Strings.isNullOrEmpty(key.getProxyUser()) && !Strings.isNullOrEmpty(key.getProxyPassword())) { + logger.debug("Setting Azure proxy with user. Host: {}, port: {}", key.getProxyHost(), key.getProxyPort()); + opContext.setProxyUsername(key.getProxyUser()); + opContext.setProxyPassword(key.getProxyPassword()); + } } else { logger.debug("Omitting Azure proxy setup"); } diff --git a/src/test/java/net/snowflake/client/core/CoreUtilsMiscellaneousTest.java b/src/test/java/net/snowflake/client/core/CoreUtilsMiscellaneousTest.java index f11614c8b..87df6c659 100644 --- a/src/test/java/net/snowflake/client/core/CoreUtilsMiscellaneousTest.java +++ b/src/test/java/net/snowflake/client/core/CoreUtilsMiscellaneousTest.java @@ -162,6 +162,8 @@ public void testSetProxyForAzure() { false); HttpUtil.setProxyForAzure(testKey, op); Proxy proxy = op.getProxy(); + assertEquals("testuser", op.getProxyUsername()); + assertEquals("pw", op.getProxyPassword()); assertEquals(Proxy.Type.HTTP, proxy.type()); assertEquals(new InetSocketAddress("snowflakecomputing.com", 443), proxy.address()); }