Skip to content

Commit 042c5ab

Browse files
fix sync tests
1 parent 8606d9b commit 042c5ab

File tree

1 file changed

+31
-47
lines changed

1 file changed

+31
-47
lines changed

test/integ/test_connection.py

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,92 +1370,76 @@ def test_server_session_keep_alive(conn_cnx):
13701370

13711371

13721372
@pytest.mark.skipolddriver
1373-
def test_ocsp_mode_disable_ocsp_checks(conn_cnx, is_public_test, caplog):
1373+
def test_ocsp_mode_disable_ocsp_checks(conn_cnx, caplog):
13741374
caplog.set_level(logging.DEBUG, "snowflake.connector.ocsp_snowflake")
13751375
with conn_cnx(disable_ocsp_checks=True) as conn, conn.cursor() as cur:
13761376
assert cur.execute("select 1").fetchall() == [(1,)]
1377-
assert "snowflake.connector.ocsp_snowflake" not in caplog.text
1378-
caplog.clear()
1379-
1380-
with conn_cnx() as conn, conn.cursor() as cur:
1381-
assert cur.execute("select 1").fetchall() == [(1,)]
1382-
if is_public_test:
1383-
assert "snowflake.connector.ocsp_snowflake" in caplog.text
1384-
assert "This connection does not perform OCSP checks." not in caplog.text
1385-
else:
1386-
assert "snowflake.connector.ocsp_snowflake" not in caplog.text
1377+
assert "snowflake.connector.ocsp_snowflake:" not in caplog.text
13871378

13881379

13891380
@pytest.mark.skipolddriver
1390-
def test_ocsp_mode_insecure_mode(conn_cnx, is_public_test, caplog):
1381+
def test_ocsp_mode_insecure_mode(conn_cnx, caplog):
13911382
caplog.set_level(logging.DEBUG, "snowflake.connector.ocsp_snowflake")
13921383
with conn_cnx(insecure_mode=True) as conn, conn.cursor() as cur:
13931384
assert cur.execute("select 1").fetchall() == [(1,)]
1394-
if is_public_test:
1395-
assert "snowflake.connector.ocsp_snowflake" not in caplog.text
1396-
assert "This connection does not perform OCSP checks." in caplog.text
1397-
else:
1398-
assert "snowflake.connector.ocsp_snowflake" not in caplog.text
1385+
# insecure_mode=True means OCSP is disabled
1386+
assert "snowflake.connector.ocsp_snowflake:" not in caplog.text
1387+
assert "This connection does not perform OCSP checks." in caplog.text
13991388

14001389

14011390
@pytest.mark.skipolddriver
1402-
def test_ocsp_mode_insecure_mode_and_disable_ocsp_checks_match(
1403-
conn_cnx, is_public_test, caplog
1404-
):
1391+
def test_ocsp_mode_insecure_mode_and_disable_ocsp_checks_match(conn_cnx, caplog):
14051392
caplog.set_level(logging.DEBUG, "snowflake.connector.ocsp_snowflake")
14061393
with conn_cnx(
14071394
insecure_mode=True, disable_ocsp_checks=True
14081395
) as conn, conn.cursor() as cur:
14091396
assert cur.execute("select 1").fetchall() == [(1,)]
1410-
if is_public_test:
1411-
assert "snowflake.connector.ocsp_snowflake" not in caplog.text
1412-
assert (
1413-
"The values for 'disable_ocsp_checks' and 'insecure_mode' differ. "
1414-
"Using the value of 'disable_ocsp_checks."
1415-
) not in caplog.text
1416-
assert "This connection does not perform OCSP checks." in caplog.text
1417-
else:
1418-
assert "snowflake.connector.ocsp_snowflake" not in caplog.text
1397+
assert "snowflake.connector.ocsp_snowflake" not in caplog.text
1398+
assert (
1399+
"The values for 'disable_ocsp_checks' and 'insecure_mode' differ. "
1400+
"Using the value of 'disable_ocsp_checks."
1401+
) not in caplog.text
1402+
assert "This connection does not perform OCSP checks." in caplog.text
14191403

14201404

14211405
@pytest.mark.skipolddriver
14221406
def test_ocsp_mode_insecure_mode_and_disable_ocsp_checks_mismatch_ocsp_disabled(
1423-
conn_cnx, is_public_test, caplog
1407+
conn_cnx, caplog
14241408
):
14251409
caplog.set_level(logging.DEBUG, "snowflake.connector.ocsp_snowflake")
14261410
with conn_cnx(
14271411
insecure_mode=False, disable_ocsp_checks=True
14281412
) as conn, conn.cursor() as cur:
14291413
assert cur.execute("select 1").fetchall() == [(1,)]
1430-
if is_public_test:
1431-
assert "snowflake.connector.ocsp_snowflake" not in caplog.text
1432-
assert (
1433-
"The values for 'disable_ocsp_checks' and 'insecure_mode' differ. "
1434-
"Using the value of 'disable_ocsp_checks."
1435-
) in caplog.text
1436-
assert "This connection does not perform OCSP checks." in caplog.text
1437-
else:
1438-
assert "snowflake.connector.ocsp_snowflake" not in caplog.text
1414+
# disable_ocsp_checks=True takes precedence, so OCSP should be disabled
1415+
assert "snowflake.connector.ocsp_snowflake:" not in caplog.text
1416+
assert (
1417+
"The values for 'disable_ocsp_checks' and 'insecure_mode' differ. "
1418+
"Using the value of 'disable_ocsp_checks."
1419+
) in caplog.text
14391420

14401421

14411422
@pytest.mark.skipolddriver
14421423
def test_ocsp_mode_insecure_mode_and_disable_ocsp_checks_mismatch_ocsp_enabled(
1443-
conn_cnx, is_public_test, caplog
1424+
conn_cnx, caplog
14441425
):
14451426
caplog.set_level(logging.DEBUG, "snowflake.connector.ocsp_snowflake")
14461427
with conn_cnx(
14471428
insecure_mode=True, disable_ocsp_checks=False
14481429
) as conn, conn.cursor() as cur:
14491430
assert cur.execute("select 1").fetchall() == [(1,)]
1450-
if is_public_test:
1451-
assert "snowflake.connector.ocsp_snowflake" in caplog.text
1452-
assert (
1453-
"The values for 'disable_ocsp_checks' and 'insecure_mode' differ. "
1454-
"Using the value of 'disable_ocsp_checks."
1455-
) in caplog.text
1431+
# disable_ocsp_checks=False takes precedence, so OCSP should be enabled
1432+
assert (
1433+
"The values for 'disable_ocsp_checks' and 'insecure_mode' differ. "
1434+
"Using the value of 'disable_ocsp_checks."
1435+
) in caplog.text
1436+
if "This connection is in OCSP Fail Open Mode" in caplog.text:
1437+
# OCSP is enabled, should see OCSP activity
1438+
assert "snowflake.connector.ocsp_snowflake:" in caplog.text
14561439
assert "This connection does not perform OCSP checks." not in caplog.text
14571440
else:
1458-
assert "snowflake.connector.ocsp_snowflake" not in caplog.text
1441+
# OCSP is disabled, should not see OCSP activity
1442+
assert "snowflake.connector.ocsp_snowflake:" not in caplog.text
14591443

14601444

14611445
@pytest.mark.skipolddriver

0 commit comments

Comments
 (0)