@@ -369,7 +369,7 @@ async def test_bogus(db_parameters):
369
369
host = db_parameters ["host" ],
370
370
port = db_parameters ["port" ],
371
371
login_timeout = 5 ,
372
- insecure_mode = True ,
372
+ disable_ocsp_checks = True ,
373
373
):
374
374
pass
375
375
@@ -1450,19 +1450,96 @@ async def test_server_session_keep_alive(conn_cnx):
1450
1450
1451
1451
1452
1452
@pytest .mark .skipolddriver
1453
- async def test_ocsp_mode_insecure (conn_cnx , is_public_test , caplog ):
1454
- caplog .set_level (logging .DEBUG , "snowflake.connector.ocsp_snowflake" )
1453
+ async def test_ocsp_mode_disable_ocsp_checks (conn_cnx , caplog ):
1454
+ caplog .set_level (logging .DEBUG , "snowflake.connector.aio._ocsp_snowflake" )
1455
+ async with conn_cnx (disable_ocsp_checks = True ) as conn , conn .cursor () as cur :
1456
+ assert await (await cur .execute ("select 1" )).fetchall () == [(1 ,)]
1457
+ assert "snowflake.connector.aio._ocsp_snowflake:" not in caplog .text
1458
+
1459
+
1460
+ @pytest .mark .skipolddriver
1461
+ async def test_ocsp_mode_insecure_mode (conn_cnx , is_public_test , caplog ):
1462
+ caplog .set_level (logging .DEBUG , "snowflake.connector.aio._ocsp_snowflake" )
1455
1463
async with conn_cnx (insecure_mode = True ) as conn , conn .cursor () as cur :
1456
1464
assert await (await cur .execute ("select 1" )).fetchall () == [(1 ,)]
1457
- assert "snowflake.connector.ocsp_snowflake" not in caplog .text
1458
- caplog .clear ()
1465
+ if is_public_test :
1466
+ assert "snowflake.connector.aio._ocsp_snowflake:" not in caplog .text
1467
+ assert "This connection does not perform OCSP checks." in caplog .text
1468
+ else :
1469
+ assert "snowflake.connector.aio._ocsp_snowflake:" not in caplog .text
1470
+
1471
+
1472
+ @pytest .mark .skipolddriver
1473
+ async def test_ocsp_mode_insecure_mode_and_disable_ocsp_checks_match (
1474
+ conn_cnx , is_public_test , caplog
1475
+ ):
1476
+ caplog .set_level (logging .DEBUG , "snowflake.connector.aio._ocsp_snowflake" )
1477
+ async with conn_cnx (
1478
+ insecure_mode = True , disable_ocsp_checks = True
1479
+ ) as conn , conn .cursor () as cur :
1480
+ assert await (await cur .execute ("select 1" )).fetchall () == [(1 ,)]
1481
+ if is_public_test :
1482
+ assert "snowflake.connector.aio._ocsp_snowflake:" not in caplog .text
1483
+ assert (
1484
+ "The values for 'disable_ocsp_checks' and 'insecure_mode' differ. "
1485
+ "Using the value of 'disable_ocsp_checks."
1486
+ ) not in caplog .text
1487
+ assert "This connection does not perform OCSP checks." in caplog .text
1488
+ else :
1489
+ assert "snowflake.connector.aio._ocsp_snowflake:" not in caplog .text
1459
1490
1460
- async with conn_cnx () as conn , conn .cursor () as cur :
1491
+
1492
+ @pytest .mark .skipolddriver
1493
+ async def test_ocsp_mode_insecure_mode_and_disable_ocsp_checks_mismatch_ocsp_disabled (
1494
+ conn_cnx , is_public_test , caplog
1495
+ ):
1496
+ caplog .set_level (logging .DEBUG , "snowflake.connector.aio._ocsp_snowflake" )
1497
+ async with conn_cnx (
1498
+ insecure_mode = False , disable_ocsp_checks = True
1499
+ ) as conn , conn .cursor () as cur :
1461
1500
assert await (await cur .execute ("select 1" )).fetchall () == [(1 ,)]
1462
1501
if is_public_test :
1463
- assert "snowflake.connector.ocsp_snowflake" in caplog .text
1502
+ assert "snowflake.connector.aio._ocsp_snowflake:" not in caplog .text
1503
+ assert (
1504
+ "The values for 'disable_ocsp_checks' and 'insecure_mode' differ. "
1505
+ "Using the value of 'disable_ocsp_checks."
1506
+ ) in caplog .text
1507
+ assert "This connection does not perform OCSP checks." in caplog .text
1464
1508
else :
1465
- assert "snowflake.connector.ocsp_snowflake" not in caplog .text
1509
+ assert "snowflake.connector.aio._ocsp_snowflake:" not in caplog .text
1510
+
1511
+
1512
+ @pytest .mark .skipolddriver
1513
+ async def test_ocsp_mode_insecure_mode_and_disable_ocsp_checks_mismatch_ocsp_enabled (
1514
+ conn_cnx , caplog
1515
+ ):
1516
+ caplog .set_level (logging .DEBUG , "snowflake.connector.aio._ocsp_snowflake" )
1517
+ async with conn_cnx (
1518
+ insecure_mode = True , disable_ocsp_checks = False
1519
+ ) as conn , conn .cursor () as cur :
1520
+ assert await (await cur .execute ("select 1" )).fetchall () == [(1 ,)]
1521
+ assert (
1522
+ "The values for 'disable_ocsp_checks' and 'insecure_mode' differ. "
1523
+ "Using the value of 'disable_ocsp_checks."
1524
+ ) in caplog .text
1525
+ assert "snowflake.connector.aio._ocsp_snowflake:" in caplog .text
1526
+
1527
+
1528
+ @pytest .mark .skipolddriver
1529
+ async def test_ocsp_mode_insecure_mode_deprecation_warning (conn_cnx ):
1530
+ import warnings
1531
+
1532
+ with warnings .catch_warnings (record = True ) as w :
1533
+ warnings .simplefilter ("ignore" )
1534
+ warnings .filterwarnings (
1535
+ "always" , category = DeprecationWarning , message = ".*insecure_mode"
1536
+ )
1537
+ async with conn_cnx (insecure_mode = True ):
1538
+ assert len (w ) == 1
1539
+ assert issubclass (w [0 ].category , DeprecationWarning )
1540
+ assert "The 'insecure_mode' connection property is deprecated." in str (
1541
+ w [0 ].message
1542
+ )
1466
1543
1467
1544
1468
1545
@pytest .mark .skipolddriver
0 commit comments