-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SNOW-1526507: Pick top level domain for Snowflake hosts (#1820)
- Loading branch information
1 parent
579cb8f
commit b9dcc47
Showing
11 changed files
with
278 additions
and
19 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/main/java/net/snowflake/client/core/PrivateLinkDetector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package net.snowflake.client.core; | ||
|
||
@SnowflakeJdbcInternalApi | ||
public class PrivateLinkDetector { | ||
/** | ||
* We can only tell if private link is enabled for certain hosts when the hostname contains the | ||
* word 'privatelink' but we don't have a good way of telling if a private link connection is | ||
* expected for internal stages for example. | ||
*/ | ||
public static boolean isPrivateLink(String host) { | ||
return host.toLowerCase().contains(".privatelink.snowflakecomputing."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
src/test/java/net/snowflake/client/core/OCSPCacheServerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package net.snowflake.client.core; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
@RunWith(Parameterized.class) | ||
public class OCSPCacheServerTest { | ||
|
||
@Parameterized.Parameters( | ||
name = "For host {0} cache server fetch url should be {1} and retry url {2}") | ||
public static Object[][] data() { | ||
return new Object[][] { | ||
{ | ||
"bla-12345.global.snowflakecomputing.com", | ||
"https://ocspssd-12345.global.snowflakecomputing.com/ocsp/fetch", | ||
"https://ocspssd-12345.global.snowflakecomputing.com/ocsp/retry" | ||
}, | ||
{ | ||
"bla-12345.global.snowflakecomputing.cn", | ||
"https://ocspssd-12345.global.snowflakecomputing.cn/ocsp/fetch", | ||
"https://ocspssd-12345.global.snowflakecomputing.cn/ocsp/retry" | ||
}, | ||
{ | ||
"bla-12345.global.snowflakecomputing.xyz", | ||
"https://ocspssd-12345.global.snowflakecomputing.xyz/ocsp/fetch", | ||
"https://ocspssd-12345.global.snowflakecomputing.xyz/ocsp/retry" | ||
}, | ||
{ | ||
"bla-12345.GLOBAL.snowflakecomputing.xyz", | ||
"https://ocspssd-12345.GLOBAL.snowflakecomputing.xyz/ocsp/fetch", | ||
"https://ocspssd-12345.GLOBAL.snowflakecomputing.xyz/ocsp/retry" | ||
}, | ||
{ | ||
"bla-12345.snowflakecomputing.com", | ||
"https://ocspssd.snowflakecomputing.com/ocsp/fetch", | ||
"https://ocspssd.snowflakecomputing.com/ocsp/retry" | ||
}, | ||
{ | ||
"bla-12345.snowflakecomputing.cn", | ||
"https://ocspssd.snowflakecomputing.cn/ocsp/fetch", | ||
"https://ocspssd.snowflakecomputing.cn/ocsp/retry" | ||
}, | ||
{ | ||
"bla-12345.snowflakecomputing.xyz", | ||
"https://ocspssd.snowflakecomputing.xyz/ocsp/fetch", | ||
"https://ocspssd.snowflakecomputing.xyz/ocsp/retry" | ||
}, | ||
{ | ||
"bla-12345.SNOWFLAKEcomputing.xyz", | ||
"https://ocspssd.SNOWFLAKEcomputing.xyz/ocsp/fetch", | ||
"https://ocspssd.SNOWFLAKEcomputing.xyz/ocsp/retry" | ||
}, | ||
{ | ||
"s3.amazoncomaws.com", | ||
"https://ocspssd.snowflakecomputing.com/ocsp/fetch", | ||
"https://ocspssd.snowflakecomputing.com/ocsp/retry" | ||
}, | ||
{ | ||
"s3.amazoncomaws.COM", | ||
"https://ocspssd.snowflakecomputing.COM/ocsp/fetch", | ||
"https://ocspssd.snowflakecomputing.COM/ocsp/retry" | ||
}, | ||
{ | ||
"s3.amazoncomaws.com.cn", | ||
"https://ocspssd.snowflakecomputing.cn/ocsp/fetch", | ||
"https://ocspssd.snowflakecomputing.cn/ocsp/retry" | ||
}, | ||
{ | ||
"S3.AMAZONCOMAWS.COM.CN", | ||
"https://ocspssd.snowflakecomputing.CN/ocsp/fetch", | ||
"https://ocspssd.snowflakecomputing.CN/ocsp/retry" | ||
}, | ||
}; | ||
} | ||
|
||
private final String host; | ||
private final String expectedFetchUrl; | ||
private final String expectedRetryUrl; | ||
|
||
public OCSPCacheServerTest(String host, String expectedFetchUrl, String expectedRetryUrl) { | ||
this.host = host; | ||
this.expectedFetchUrl = expectedFetchUrl; | ||
this.expectedRetryUrl = expectedRetryUrl; | ||
} | ||
|
||
@Test | ||
public void shouldChooseOcspCacheServerUrls() { | ||
SFTrustManager.OCSPCacheServer ocspCacheServer = new SFTrustManager.OCSPCacheServer(); | ||
ocspCacheServer.resetOCSPResponseCacheServer(host); | ||
|
||
assertEquals(expectedFetchUrl, ocspCacheServer.SF_OCSP_RESPONSE_CACHE_SERVER); | ||
assertEquals(expectedRetryUrl, ocspCacheServer.SF_OCSP_RESPONSE_RETRY_URL); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/test/java/net/snowflake/client/core/PrivateLinkDetectorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package net.snowflake.client.core; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
@RunWith(Parameterized.class) | ||
public class PrivateLinkDetectorTest { | ||
|
||
@Parameterized.Parameters(name = "Host {0} is private link: {1}") | ||
public static Object[][] data() { | ||
return new Object[][] { | ||
{"snowhouse.snowflakecomputing.com", false}, | ||
{"snowhouse.privatelink.snowflakecomputing.com", true}, | ||
{"snowhouse.PRIVATELINK.snowflakecomputing.com", true}, | ||
{"snowhouse.snowflakecomputing.cn", false}, | ||
{"snowhouse.privatelink.snowflakecomputing.cn", true}, | ||
{"snowhouse.PRIVATELINK.snowflakecomputing.cn", true}, | ||
{"snowhouse.snowflakecomputing.xyz", false}, | ||
{"snowhouse.privatelink.snowflakecomputing.xyz", true}, | ||
{"snowhouse.PRIVATELINK.snowflakecomputing.xyz", true}, | ||
}; | ||
} | ||
|
||
private final String host; | ||
private final boolean expectedToBePrivateLink; | ||
|
||
public PrivateLinkDetectorTest(String host, boolean expectedToBePrivateLink) { | ||
this.host = host; | ||
this.expectedToBePrivateLink = expectedToBePrivateLink; | ||
} | ||
|
||
@Test | ||
public void shouldDetectPrivateLinkHost() { | ||
assertEquals( | ||
String.format("Expecting %s to be private link: %s", host, expectedToBePrivateLink), | ||
expectedToBePrivateLink, | ||
PrivateLinkDetector.isPrivateLink(host)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.