-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SNOW-1821504: [JDBC] Initialal OCSP deprecation plan steps (#2008)
- Loading branch information
1 parent
dcac111
commit 895b098
Showing
8 changed files
with
192 additions
and
15 deletions.
There are no files selected for viewing
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
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
121 changes: 121 additions & 0 deletions
121
src/test/java/net/snowflake/client/jdbc/ConnectionWithDisableOCSPModeLatestIT.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,121 @@ | ||
/* | ||
* Copyright (c) 2025 Snowflake Computing Inc. All right reserved. | ||
*/ | ||
package net.snowflake.client.jdbc; | ||
|
||
import static org.hamcrest.CoreMatchers.anyOf; | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import java.sql.DriverManager; | ||
import java.sql.SQLException; | ||
import java.util.Properties; | ||
import net.snowflake.client.category.TestTags; | ||
import net.snowflake.client.core.SFTrustManager; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** Tests for connection with DisableOCSPchecks and insecuremode settings. */ | ||
@Tag(TestTags.CONNECTION) | ||
public class ConnectionWithDisableOCSPModeLatestIT extends BaseJDBCTest { | ||
public static final int INVALID_CONNECTION_INFO_CODE = 390100; | ||
private static final int DISABLE_OCSP_INSECURE_MODE_MISMATCH = 200064; | ||
public static final int BAD_REQUEST_GS_CODE = 390400; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
SFTrustManager.deleteCache(); | ||
} | ||
|
||
@AfterEach | ||
public void tearDown() { | ||
SFTrustManager.cleanTestSystemParameters(); | ||
} | ||
|
||
/** | ||
* Test connectivity with disableOCSPChecksMode and insecure mode enabled. This test applies to | ||
* driver versions after 3.21.0 | ||
*/ | ||
@Test | ||
public void testDisableOCSPChecksModeAndInsecureModeSet() throws SQLException { | ||
|
||
boolean disableOCSPChecks = true; | ||
boolean insecureMode = true; | ||
assertThat( | ||
returnErrorCodeFromConnection(disableOCSPChecks, insecureMode), | ||
anyOf(is(INVALID_CONNECTION_INFO_CODE), is(BAD_REQUEST_GS_CODE))); | ||
} | ||
|
||
/** | ||
* Test production connectivity with only disableOCSPChecksMode enabled. This test applies to | ||
* driver versions after 3.21.0 | ||
*/ | ||
@Test | ||
public void testDisableOCSPChecksModeSet() throws SQLException { | ||
boolean disableOCSPChecks = true; | ||
assertThat( | ||
returnErrorCodeFromConnection(disableOCSPChecks, null), | ||
anyOf(is(INVALID_CONNECTION_INFO_CODE), is(BAD_REQUEST_GS_CODE))); | ||
} | ||
|
||
/** | ||
* Test production connectivity with only insecureMode enabled. This test applies to driver | ||
* versions after 3.21.0 | ||
*/ | ||
@Test | ||
public void testInsecureModeSet() throws SQLException { | ||
boolean insecureMode = true; | ||
assertThat( | ||
returnErrorCodeFromConnection(null, insecureMode), | ||
anyOf(is(INVALID_CONNECTION_INFO_CODE), is(BAD_REQUEST_GS_CODE))); | ||
} | ||
|
||
/** | ||
* Test production connectivity with disableOCSPChecksMode enabled AND insecureMode disabled. This | ||
* test applies to driver versions after 3.21.0 | ||
*/ | ||
@Test | ||
public void testDisableOCSPChecksModeAndInsecureModeMismatched() throws SQLException { | ||
boolean disableOCSPChecks = true; | ||
boolean insecureMode = false; | ||
assertThat( | ||
returnErrorCodeFromConnection(disableOCSPChecks, insecureMode), | ||
anyOf(is(DISABLE_OCSP_INSECURE_MODE_MISMATCH))); | ||
} | ||
|
||
/** | ||
* Helper method to return error code from connection. | ||
* | ||
* @param disableOSCPChecks | ||
* @param isInsecureMode | ||
* @return SF Error code | ||
* @throws SQLException | ||
*/ | ||
public int returnErrorCodeFromConnection(Boolean disableOSCPChecks, Boolean isInsecureMode) | ||
throws SQLException { | ||
String deploymentUrl = "jdbc:snowflake://sfcsupport.snowflakecomputing.com"; | ||
Properties properties = new Properties(); | ||
|
||
properties.put("user", "fakeuser"); | ||
properties.put("password", "fakepwd"); | ||
properties.put("account", "fakeaccount"); | ||
if (disableOSCPChecks != null) { | ||
properties.put("disableOCSPChecks", disableOSCPChecks); | ||
} | ||
if (isInsecureMode != null) { | ||
properties.put("insecureMode", isInsecureMode); | ||
} | ||
|
||
SQLException thrown = | ||
assertThrows( | ||
SQLException.class, | ||
() -> { | ||
DriverManager.getConnection(deploymentUrl, properties); | ||
}); | ||
|
||
return (thrown.getErrorCode()); | ||
} | ||
} |