From 470e8c02caf4a311ee92b8e3a28dc01eb25aaa0b Mon Sep 17 00:00:00 2001 From: Joyce Ling <115662568+sfc-gh-ext-simba-jl@users.noreply.github.com> Date: Thu, 19 Oct 2023 00:56:22 -0700 Subject: [PATCH] Add more tests to cover some partial hits --- .../core/CoreUtilsMiscellaneousTest.java | 23 +++++++++++++++++++ .../client/jdbc/SnowflakeDriverLatestIT.java | 11 +++++++++ 2 files changed, 34 insertions(+) diff --git a/src/test/java/net/snowflake/client/core/CoreUtilsMiscellaneousTest.java b/src/test/java/net/snowflake/client/core/CoreUtilsMiscellaneousTest.java index 9f86db711..d1eaa390d 100644 --- a/src/test/java/net/snowflake/client/core/CoreUtilsMiscellaneousTest.java +++ b/src/test/java/net/snowflake/client/core/CoreUtilsMiscellaneousTest.java @@ -273,4 +273,27 @@ public void testSizeOfHttpClientMapWithGzipAndUserAgentSuffix() { // Assert there are 3 entries because userAgentSuffix has changed assertEquals(3, HttpUtil.httpClient.size()); } + + @Test + public void testNullAndEmptyProxySettingsForS3() { + HttpClientSettingsKey testKey = + new HttpClientSettingsKey( + OCSPMode.FAIL_OPEN, + null, + 443, + null, + null, + null, + "", + "", + false); + ClientConfiguration clientConfig = new ClientConfiguration(); + HttpUtil.setProxyForS3(testKey, clientConfig); + assertEquals(Protocol.HTTP, clientConfig.getProxyProtocol()); + assertEquals("", clientConfig.getProxyHost()); + assertEquals(443, clientConfig.getProxyPort()); + assertEquals("", clientConfig.getNonProxyHosts()); + assertNull(clientConfig.getProxyUsername()); + assertNull(clientConfig.getProxyPassword()); + } } diff --git a/src/test/java/net/snowflake/client/jdbc/SnowflakeDriverLatestIT.java b/src/test/java/net/snowflake/client/jdbc/SnowflakeDriverLatestIT.java index 2cea0e5fb..da29b287e 100644 --- a/src/test/java/net/snowflake/client/jdbc/SnowflakeDriverLatestIT.java +++ b/src/test/java/net/snowflake/client/jdbc/SnowflakeDriverLatestIT.java @@ -416,6 +416,17 @@ public void testGetPropertyInfo() throws SQLException { "server URL in form of ://:/", info[0].description); + // Test with null URL and no properties. ServerURL is needed. + url = null; + props = new Properties(); + driver = DriverManager.getDriver("jdbc:snowflake://snowflake.reg.local:8082"); + info = driver.getPropertyInfo(url, props); + assertEquals(1, info.length); + assertEquals("serverURL", info[0].name); + assertEquals( + "server URL in form of ://:/", + info[0].description); + // Test with URL that requires username and password. url = "jdbc:snowflake://snowflake.reg.local:8082"; info = driver.getPropertyInfo(url, props);