Skip to content
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

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c4fdb4c
FAIL_OPEN log changed (message + log level)
sfc-gh-ext-simba-vb Dec 10, 2024
e5d2224
Merge branch 'master' of https://github.com/snowflakedb/snowflake-jdb…
sfc-gh-ext-simba-vb Dec 10, 2024
c9607ee
Merge branch 'master' of https://github.com/snowflakedb/snowflake-jdb…
sfc-gh-ext-simba-vb Dec 13, 2024
4d66099
disableOCSPChecks property added.
sfc-gh-ext-simba-vb Dec 17, 2024
1967502
Testcase changes.
sfc-gh-ext-simba-vb Dec 17, 2024
f26374e
Correcting the checklist.
sfc-gh-ext-simba-vb Dec 17, 2024
47ab1dc
Merge branch 'master' into SNOW-1821504-jdbc-initialal-ocsp-deprecati…
sfc-gh-ext-simba-vb Dec 17, 2024
b244875
Merge branch 'master' of https://github.com/snowflakedb/snowflake-jdb…
sfc-gh-ext-simba-vb Dec 19, 2024
a5237da
Review comments incorporated.
sfc-gh-ext-simba-vb Dec 19, 2024
e0055ca
Merge branch 'SNOW-1821504-jdbc-initialal-ocsp-deprecation-plan-steps…
sfc-gh-ext-simba-vb Dec 19, 2024
20a9483
Check Style correction.
sfc-gh-ext-simba-vb Dec 19, 2024
b76683b
Review comments implemented.
sfc-gh-ext-simba-vb Dec 19, 2024
c8e578e
Merge branch 'master' into SNOW-1821504-jdbc-initialal-ocsp-deprecati…
sfc-gh-ext-simba-vb Dec 19, 2024
28bbf9d
Fixed tests failure on old driver.
sfc-gh-ext-simba-vb Dec 20, 2024
1dff792
Merge branch 'SNOW-1821504-jdbc-initialal-ocsp-deprecation-plan-steps…
sfc-gh-ext-simba-vb Dec 20, 2024
829b5c6
Merge branch 'master' into SNOW-1821504-jdbc-initialal-ocsp-deprecati…
sfc-gh-ext-simba-vb Dec 23, 2024
bb2a27e
Merge branch 'master' of https://github.com/snowflakedb/snowflake-jdb…
sfc-gh-ext-simba-vb Jan 3, 2025
89b69f4
Merge branch 'SNOW-1821504-jdbc-initialal-ocsp-deprecation-plan-steps…
sfc-gh-ext-simba-vb Jan 3, 2025
840b6a0
Review comment changes implemented.
sfc-gh-ext-simba-vb Jan 3, 2025
e835e00
Merge branch 'master' of https://github.com/snowflakedb/snowflake-jdb…
sfc-gh-ext-simba-vb Jan 7, 2025
aa499a9
Merge branch 'master' into SNOW-1821504-jdbc-initialal-ocsp-deprecati…
sfc-gh-ext-simba-vb Jan 8, 2025
f52c52b
Merge branch 'SNOW-1821504-jdbc-initialal-ocsp-deprecation-plan-steps…
sfc-gh-ext-simba-vb Jan 8, 2025
e5fd8e5
Review comments implementation.
sfc-gh-ext-simba-vb Jan 8, 2025
11b7746
corrected typo.
sfc-gh-ext-simba-vb Jan 9, 2025
ab37d95
Merge branch 'master' into SNOW-1821504-jdbc-initialal-ocsp-deprecati…
sfc-gh-ext-simba-vb Jan 9, 2025
d154832
Comments related to driver version is added.
sfc-gh-ext-simba-vb Jan 9, 2025
abcfa29
Merge branch 'master' into SNOW-1821504-jdbc-initialal-ocsp-deprecati…
sfc-gh-ext-simba-vb Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ public OCSPMode getOCSPMode() throws SnowflakeSQLException {
&& (disableOCSPChecks != insecureMode)) {
logger.error(
"The values for 'disableOCSPChecks' and 'insecureMode' must be identical. "
+ "Please ensure both properties are set to the same value.");
+ "Please ensure both properties are set to the same value or unset insecureMode.");
sfc-gh-pbulawa marked this conversation as resolved.
Show resolved Hide resolved
throw new SnowflakeSQLException(
ErrorCode.DISABLEOCSP_INSECUREMODE_VALUE_MISMATCH,
"The values for 'disableOCSPChecks' and 'insecureMode' " + "must be identical.");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* Copyright (c) 2024 Snowflake Computing Inc. All right reserved.
sfc-gh-dprzybysz marked this conversation as resolved.
Show resolved Hide resolved
*/
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. */
sfc-gh-ext-simba-vb marked this conversation as resolved.
Show resolved Hide resolved
@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)));
sfc-gh-ext-simba-vb marked this conversation as resolved.
Show resolved Hide resolved
}

/** 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 =
sfc-gh-dprzybysz marked this conversation as resolved.
Show resolved Hide resolved
"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(
sfc-gh-dprzybysz marked this conversation as resolved.
Show resolved Hide resolved
e.getErrorCode(), anyOf(is(INVALID_CONNECTION_INFO_CODE), is(BAD_REQUEST_GS_CODE)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.fail;

import java.net.SocketTimeoutException;
Expand Down Expand Up @@ -45,7 +43,6 @@ public class ConnectionWithOCSPModeIT extends BaseJDBCTest {
private final String testPassword = "testpassword";
private final String testRevokedCertConnectString = "jdbc:snowflake://revoked.badssl.com/";
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;

private static int nameCounter = 0;
Expand Down Expand Up @@ -445,49 +442,6 @@ public void testWrongHost() throws InterruptedException {
fail("All retries failed");
}

/** 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)));
}

private static Matcher<String> httpStatus403Or404Or513() {
return anyOf(
containsString("HTTP status=403"),
Expand Down
Loading