-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNOW-1821504: [JDBC] Initialal OCSP deprecation plan steps #2008
Open
sfc-gh-ext-simba-vb
wants to merge
16
commits into
master
Choose a base branch
from
SNOW-1821504-jdbc-initialal-ocsp-deprecation-plan-steps
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+188
−16
Open
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c4fdb4c
FAIL_OPEN log changed (message + log level)
sfc-gh-ext-simba-vb e5d2224
Merge branch 'master' of https://github.com/snowflakedb/snowflake-jdb…
sfc-gh-ext-simba-vb c9607ee
Merge branch 'master' of https://github.com/snowflakedb/snowflake-jdb…
sfc-gh-ext-simba-vb 4d66099
disableOCSPChecks property added.
sfc-gh-ext-simba-vb 1967502
Testcase changes.
sfc-gh-ext-simba-vb f26374e
Correcting the checklist.
sfc-gh-ext-simba-vb 47ab1dc
Merge branch 'master' into SNOW-1821504-jdbc-initialal-ocsp-deprecati…
sfc-gh-ext-simba-vb b244875
Merge branch 'master' of https://github.com/snowflakedb/snowflake-jdb…
sfc-gh-ext-simba-vb a5237da
Review comments incorporated.
sfc-gh-ext-simba-vb e0055ca
Merge branch 'SNOW-1821504-jdbc-initialal-ocsp-deprecation-plan-steps…
sfc-gh-ext-simba-vb 20a9483
Check Style correction.
sfc-gh-ext-simba-vb b76683b
Review comments implemented.
sfc-gh-ext-simba-vb c8e578e
Merge branch 'master' into SNOW-1821504-jdbc-initialal-ocsp-deprecati…
sfc-gh-ext-simba-vb 28bbf9d
Fixed tests failure on old driver.
sfc-gh-ext-simba-vb 1dff792
Merge branch 'SNOW-1821504-jdbc-initialal-ocsp-deprecation-plan-steps…
sfc-gh-ext-simba-vb 829b5c6
Merge branch 'master' into SNOW-1821504-jdbc-initialal-ocsp-deprecati…
sfc-gh-ext-simba-vb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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) 2024 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 static org.junit.jupiter.api.Assertions.fail; | ||
|
||
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. */ | ||
@Test | ||
public void testDisableOCSPChecksModeAndInsecureMode() throws SQLException { | ||
|
||
String deploymentUrl = | ||
"jdbc:snowflake://sfcsupport.snowflakecomputing.com?disableOCSPChecks=true&insecureMode=true"; | ||
Properties properties = new Properties(); | ||
|
||
properties.put("user", "fakeuser"); | ||
properties.put("password", "fakepwd"); | ||
properties.put("account", "fakeaccount"); | ||
SQLException thrown = | ||
assertThrows( | ||
SQLException.class, | ||
() -> { | ||
DriverManager.getConnection(deploymentUrl, properties); | ||
}); | ||
|
||
assertThat( | ||
thrown.getErrorCode(), anyOf(is(INVALID_CONNECTION_INFO_CODE), is(BAD_REQUEST_GS_CODE))); | ||
} | ||
|
||
/** Test connectivity with disableOCSPChecksMode enabled and insecure mode disabled. */ | ||
@Test | ||
public void testDisableOCSPChecksModeAndInsecureModeMismatched() throws SQLException { | ||
|
||
String deploymentUrl = | ||
"jdbc:snowflake://sfcsupport.snowflakecomputing.com?disableOCSPChecks=true&insecureMode=false"; | ||
Properties properties = new Properties(); | ||
|
||
properties.put("user", "fakeuser"); | ||
properties.put("password", "fakepwd"); | ||
properties.put("account", "fakeaccount"); | ||
SQLException thrown = | ||
assertThrows( | ||
SQLException.class, | ||
() -> { | ||
DriverManager.getConnection(deploymentUrl, properties); | ||
}); | ||
|
||
assertThat(thrown.getErrorCode(), anyOf(is(DISABLE_OCSP_INSECURE_MODE_MISMATCH))); | ||
} | ||
|
||
/** Test production connectivity with only disableOCSPChecksMode enabled. */ | ||
@Test | ||
public void testDisableOCSPChecksModeSet() throws SQLException { | ||
|
||
String deploymentUrl = | ||
"jdbc:snowflake://sfcsupport.snowflakecomputing.com?disableOCSPChecks=true"; | ||
Properties properties = new Properties(); | ||
|
||
properties.put("user", "fakeuser"); | ||
properties.put("password", "fakepwd"); | ||
properties.put("account", "fakeaccount"); | ||
SQLException thrown = | ||
assertThrows( | ||
SQLException.class, | ||
() -> { | ||
DriverManager.getConnection(deploymentUrl, properties); | ||
}); | ||
|
||
assertThat( | ||
thrown.getErrorCode(), anyOf(is(INVALID_CONNECTION_INFO_CODE), is(BAD_REQUEST_GS_CODE))); | ||
} | ||
|
||
/** Test production connectivity with insecure mode enabled. */ | ||
@Test | ||
public void testEnableInsecureMode() throws SQLException { | ||
String deploymentUrl = "jdbc:snowflake://sfcsupport.snowflakecomputing.com?insecureMode=true"; | ||
Properties properties = new Properties(); | ||
|
||
properties.put("user", "fakeuser"); | ||
properties.put("password", "fakepwd"); | ||
properties.put("account", "fakeaccount"); | ||
try { | ||
DriverManager.getConnection(deploymentUrl, properties); | ||
fail(); | ||
} catch (SQLException e) { | ||
assertThat( | ||
e.getErrorCode(), anyOf(is(INVALID_CONNECTION_INFO_CODE), is(BAD_REQUEST_GS_CODE))); | ||
} | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this assertion? It only tests options mismatch, not the effect. We could make a typo in config and it wouldn't end up in the same exception, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test name for option mismatch is testDisableOCSPChecksModeAndInsecureModeMismatched.
This above test testDisableOCSPChecksModeAndInsecureMode is a good case where both options are enabled. It will skip the OCSP check and try to connect to db, but it ends up with an exception as the user and account are fake.
For testDisableOCSPChecksModeAndInsecureModeMismatched test, it will get the new error code 200064.