@@ -348,18 +348,6 @@ async def test_bogus(db_parameters):
348
348
Notes:
349
349
This takes a long time.
350
350
"""
351
- with pytest .raises (DatabaseError ):
352
- async with snowflake .connector .aio .SnowflakeConnection (
353
- protocol = "http" ,
354
- user = "bogus" ,
355
- password = "bogus" ,
356
- host = db_parameters ["host" ],
357
- port = db_parameters ["port" ],
358
- account = db_parameters ["account" ],
359
- login_timeout = 5 ,
360
- ):
361
- pass
362
-
363
351
with pytest .raises (DatabaseError ):
364
352
async with snowflake .connector .aio .SnowflakeConnection (
365
353
protocol = "http" ,
@@ -369,7 +357,7 @@ async def test_bogus(db_parameters):
369
357
host = db_parameters ["host" ],
370
358
port = db_parameters ["port" ],
371
359
login_timeout = 5 ,
372
- insecure_mode = True ,
360
+ disable_ocsp_checks = True ,
373
361
):
374
362
pass
375
363
@@ -1450,19 +1438,111 @@ async def test_server_session_keep_alive(conn_cnx):
1450
1438
1451
1439
1452
1440
@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" )
1441
+ @pytest .mark .parametrize ("disable_ocsp_checks" , [True , False , None ])
1442
+ async def test_ocsp_mode_disable_ocsp_checks (
1443
+ conn_cnx , is_public_test , is_local_dev_setup , caplog , disable_ocsp_checks
1444
+ ):
1445
+ caplog .set_level (logging .DEBUG , "snowflake.connector.aio._ocsp_snowflake" )
1446
+ kwargs = (
1447
+ {"disable_ocsp_checks" : disable_ocsp_checks }
1448
+ if disable_ocsp_checks is not None
1449
+ else {}
1450
+ )
1451
+ async with conn_cnx (** kwargs ) as conn , conn .cursor () as cur :
1452
+ assert await (await cur .execute ("select 1" )).fetchall () == [(1 ,)]
1453
+ if disable_ocsp_checks is True :
1454
+ assert "snowflake.connector.aio._ocsp_snowflake" not in caplog .text
1455
+ else :
1456
+ if is_public_test or is_local_dev_setup :
1457
+ assert "snowflake.connector.aio._ocsp_snowflake" in caplog .text
1458
+ assert (
1459
+ "This connection does not perform OCSP checks." not in caplog .text
1460
+ )
1461
+ else :
1462
+ assert "snowflake.connector.aio._ocsp_snowflake" not in caplog .text
1463
+
1464
+
1465
+ @pytest .mark .skipolddriver
1466
+ async def test_ocsp_mode_insecure_mode (
1467
+ conn_cnx , is_public_test , is_local_dev_setup , caplog
1468
+ ):
1469
+ caplog .set_level (logging .DEBUG , "snowflake.connector.aio._ocsp_snowflake" )
1455
1470
async with conn_cnx (insecure_mode = True ) as conn , conn .cursor () as cur :
1456
1471
assert await (await cur .execute ("select 1" )).fetchall () == [(1 ,)]
1457
- assert "snowflake.connector.ocsp_snowflake" not in caplog .text
1458
- caplog .clear ()
1472
+ assert "snowflake.connector.aio._ocsp_snowflake" not in caplog .text
1473
+ if is_public_test or is_local_dev_setup :
1474
+ assert "This connection does not perform OCSP checks." in caplog .text
1475
+
1459
1476
1460
- async with conn_cnx () as conn , conn .cursor () as cur :
1477
+ @pytest .mark .skipolddriver
1478
+ async def test_ocsp_mode_insecure_mode_and_disable_ocsp_checks_match (
1479
+ conn_cnx , is_public_test , is_local_dev_setup , caplog
1480
+ ):
1481
+ caplog .set_level (logging .DEBUG , "snowflake.connector.aio._ocsp_snowflake" )
1482
+ async with conn_cnx (
1483
+ insecure_mode = True , disable_ocsp_checks = True
1484
+ ) as conn , conn .cursor () as cur :
1485
+ assert await (await cur .execute ("select 1" )).fetchall () == [(1 ,)]
1486
+ assert "snowflake.connector.aio._ocsp_snowflake" not in caplog .text
1487
+ if is_public_test or is_local_dev_setup :
1488
+ assert (
1489
+ "The values for 'disable_ocsp_checks' and 'insecure_mode' differ. "
1490
+ "Using the value of 'disable_ocsp_checks."
1491
+ ) not in caplog .text
1492
+ assert "This connection does not perform OCSP checks." in caplog .text
1493
+
1494
+
1495
+ @pytest .mark .skipolddriver
1496
+ async def test_ocsp_mode_insecure_mode_and_disable_ocsp_checks_mismatch_ocsp_disabled (
1497
+ conn_cnx , is_public_test , is_local_dev_setup , caplog
1498
+ ):
1499
+ caplog .set_level (logging .DEBUG , "snowflake.connector.aio._ocsp_snowflake" )
1500
+ async with conn_cnx (
1501
+ insecure_mode = False , disable_ocsp_checks = True
1502
+ ) as conn , conn .cursor () as cur :
1503
+ assert await (await cur .execute ("select 1" )).fetchall () == [(1 ,)]
1504
+ assert "snowflake.connector.aio._ocsp_snowflake" not in caplog .text
1505
+ if is_public_test or is_local_dev_setup :
1506
+ assert (
1507
+ "The values for 'disable_ocsp_checks' and 'insecure_mode' differ. "
1508
+ "Using the value of 'disable_ocsp_checks."
1509
+ ) in caplog .text
1510
+ assert "This connection does not perform OCSP checks." in caplog .text
1511
+
1512
+
1513
+ @pytest .mark .skipolddriver
1514
+ async def test_ocsp_mode_insecure_mode_and_disable_ocsp_checks_mismatch_ocsp_enabled (
1515
+ conn_cnx , is_public_test , is_local_dev_setup , caplog
1516
+ ):
1517
+ caplog .set_level (logging .DEBUG , "snowflake.connector.aio._ocsp_snowflake" )
1518
+ async with conn_cnx (
1519
+ insecure_mode = True , disable_ocsp_checks = False
1520
+ ) as conn , conn .cursor () as cur :
1461
1521
assert await (await cur .execute ("select 1" )).fetchall () == [(1 ,)]
1462
- if is_public_test :
1463
- assert "snowflake.connector.ocsp_snowflake" in caplog .text
1522
+ if is_public_test or is_local_dev_setup :
1523
+ assert "snowflake.connector.aio._ocsp_snowflake" in caplog .text
1524
+ assert (
1525
+ "The values for 'disable_ocsp_checks' and 'insecure_mode' differ. "
1526
+ "Using the value of 'disable_ocsp_checks."
1527
+ ) in caplog .text
1528
+ assert "This connection does not perform OCSP checks." not in caplog .text
1464
1529
else :
1465
- assert "snowflake.connector.ocsp_snowflake" not in caplog .text
1530
+ assert "snowflake.connector.aio._ocsp_snowflake" not in caplog .text
1531
+
1532
+
1533
+ @pytest .mark .skipolddriver
1534
+ async def test_ocsp_mode_insecure_mode_deprecation_warning (conn_cnx ):
1535
+ with warnings .catch_warnings (record = True ) as w :
1536
+ warnings .simplefilter ("ignore" )
1537
+ warnings .filterwarnings (
1538
+ "always" , category = DeprecationWarning , message = ".*insecure_mode"
1539
+ )
1540
+ async with conn_cnx (insecure_mode = True ):
1541
+ assert len (w ) == 1
1542
+ assert issubclass (w [0 ].category , DeprecationWarning )
1543
+ assert "The 'insecure_mode' connection property is deprecated." in str (
1544
+ w [0 ].message
1545
+ )
1466
1546
1467
1547
1468
1548
@pytest .mark .skipolddriver
0 commit comments