Skip to content

Commit cebfba4

Browse files
committed
linters test ocsp
1 parent e5c6c2a commit cebfba4

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

test/unit/test_ocsp.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def overwrite_ocsp_cache(tmpdir):
8080
@pytest.fixture(autouse=True)
8181
def worker_specific_cache_dir(tmpdir, request):
8282
"""Create worker-specific cache directory to avoid file lock conflicts in parallel execution.
83-
83+
8484
Note: Tests that explicitly manage their own cache directories (like test_ocsp_cache_when_server_is_down)
8585
should work normally - this fixture only provides isolation for the validation cache.
8686
"""
@@ -461,36 +461,42 @@ def test_ocsp_cache_when_server_is_down(tmpdir):
461461
"""Test that OCSP validation handles server failures gracefully."""
462462
# Create a completely isolated cache for this test
463463
from snowflake.connector.cache import SFDictFileCache
464+
464465
isolated_cache = SFDictFileCache(
465466
entry_lifetime=3600,
466467
file_path=str(tmpdir.join("isolated_ocsp_cache.json")),
467468
)
468-
469+
469470
with mock.patch(
470471
"snowflake.connector.ocsp_snowflake.OCSP_RESPONSE_VALIDATION_CACHE",
471472
isolated_cache,
472473
):
473474
# Ensure cache starts empty
474475
isolated_cache.clear()
475-
476+
476477
# Simulate server being down when trying to validate certificates
477478
with mock.patch(
478479
"snowflake.connector.ocsp_snowflake.SnowflakeOCSP._fetch_ocsp_response",
479480
side_effect=BrokenPipeError("fake error"),
480481
), mock.patch(
481482
"snowflake.connector.ocsp_snowflake.SnowflakeOCSP.is_cert_id_in_cache",
482-
return_value=(False, None) # Force cache miss to trigger _fetch_ocsp_response
483+
return_value=(
484+
False,
485+
None,
486+
), # Force cache miss to trigger _fetch_ocsp_response
483487
):
484488
ocsp = SFOCSP(use_ocsp_cache_server=False, use_fail_open=True)
485489

486490
# The main test: validation should succeed with fail-open behavior
487491
# even when server is down (BrokenPipeError)
488492
connection = _openssl_connect("snowflake.okta.com")
489493
result = ocsp.validate("snowflake.okta.com", connection)
490-
494+
491495
# With fail-open enabled, validation should succeed despite server being down
492496
# The result should not be None (which would indicate complete failure)
493-
assert result is not None, "OCSP validation should succeed with fail-open when server is down"
497+
assert (
498+
result is not None
499+
), "OCSP validation should succeed with fail-open when server is down"
494500

495501

496502
def test_concurrent_ocsp_requests(tmpdir):

0 commit comments

Comments
 (0)