@@ -664,7 +664,7 @@ def mock_validate(cert, _):
664664 return CRLValidationResult .REVOKED
665665 return CRLValidationResult .UNREVOKED
666666
667- validator ._validate_certificate = mock_validate
667+ validator ._validate_certificate_is_not_revoked = mock_validate
668668
669669 assert (
670670 validator ._validate_single_chain ([chain .leafA , chain .BsignA , chain .rootA ])
@@ -684,7 +684,7 @@ def test_validate_single_chain(cert_gen, session_manager):
684684
685685 # case 1: at least one valid path
686686 def mock_validate_with_special_cert (revoked_cert , error_result ):
687- validator ._validate_certificate_with_cache = lambda cert , _ : (
687+ validator ._validate_certificate_is_not_revoked_with_cache = lambda cert , _ : (
688688 error_result if cert == revoked_cert else CRLValidationResult .UNREVOKED
689689 )
690690
@@ -702,7 +702,7 @@ def mock_validate(cert, _):
702702 return CRLValidationResult .REVOKED
703703 return CRLValidationResult .UNREVOKED
704704
705- validator ._validate_certificate_with_cache = mock_validate
705+ validator ._validate_certificate_is_not_revoked_with_cache = mock_validate
706706 assert validator ._validate_single_chain (input_chain ) == CRLValidationResult .REVOKED
707707
708708 # case 3: revoked + error should result in revoked\
@@ -711,14 +711,14 @@ def mock_validate(cert, _):
711711 return CRLValidationResult .REVOKED
712712 return CRLValidationResult .ERROR
713713
714- validator ._validate_certificate_with_cache = mock_validate
714+ validator ._validate_certificate_is_not_revoked_with_cache = mock_validate
715715 assert validator ._validate_single_chain (input_chain ) == CRLValidationResult .REVOKED
716716
717717 # case 4: no path to trusted certificate
718718 def mock_validate (cert , _ ):
719719 return CRLValidationResult .UNREVOKED
720720
721- validator ._validate_certificate_with_cache = mock_validate
721+ validator ._validate_certificate_is_not_revoked_with_cache = mock_validate
722722 assert (
723723 validator ._validate_single_chain (
724724 [chain .leafA , chain .leafB , chain .AsignB , chain .BsignA ]
@@ -734,7 +734,7 @@ def mock_validate(cert, _):
734734 return CRLValidationResult .ERROR
735735 return CRLValidationResult .UNREVOKED
736736
737- validator ._validate_certificate_with_cache = mock_validate
737+ validator ._validate_certificate_is_not_revoked_with_cache = mock_validate
738738 assert (
739739 validator ._validate_single_chain (
740740 [chain .leafA , chain .rootA , chain .leafB , chain .rootB , chain .BsignA ]
@@ -1546,7 +1546,7 @@ def test_crl_validator_validate_certificate_with_cache_hit(
15461546 ) as mock_check , mock_patch .object (
15471547 validator , "_verify_crl_signature" , return_value = True
15481548 ) as mock_verify :
1549- result = validator ._validate_certificate (cert , ca_cert )
1549+ result = validator ._validate_certificate_is_not_revoked (cert , ca_cert )
15501550
15511551 # Should use cached CRL
15521552 assert result == CRLValidationResult .UNREVOKED
@@ -1591,7 +1591,7 @@ def test_crl_validator_validate_certificate_with_cache_miss(
15911591 mock_crl .next_update_utc = datetime .now (timezone .utc ) + timedelta (days = 7 )
15921592 mock_crl .issuer = ca_cert .subject # Set the CRL issuer to match CA subject
15931593 mock_load_crl .return_value = mock_crl
1594- result = validator ._validate_certificate (cert , ca_cert )
1594+ result = validator ._validate_certificate_is_not_revoked (cert , ca_cert )
15951595
15961596 # Should download CRL and cache it
15971597 assert result == CRLValidationResult .UNREVOKED
@@ -1780,7 +1780,9 @@ def test_crl_signature_verification_integration_with_validation_flow(
17801780 with mock_patch .object (
17811781 validator_enabled , "_fetch_crl_from_url" , return_value = invalid_crl_bytes
17821782 ):
1783- result = validator_enabled ._validate_certificate (cert , cert_gen .ca_certificate )
1783+ result = validator_enabled ._validate_certificate_is_not_revoked (
1784+ cert , cert_gen .ca_certificate
1785+ )
17841786 assert result == CRLValidationResult .ERROR
17851787
17861788 # Test in ADVISORY mode - should also fail due to signature verification failure
@@ -1794,7 +1796,9 @@ def test_crl_signature_verification_integration_with_validation_flow(
17941796 with mock_patch .object (
17951797 validator_advisory , "_fetch_crl_from_url" , return_value = invalid_crl_bytes
17961798 ):
1797- result = validator_advisory ._validate_certificate (cert , cert_gen .ca_certificate )
1799+ result = validator_advisory ._validate_certificate_is_not_revoked (
1800+ cert , cert_gen .ca_certificate
1801+ )
17981802 # Even in ADVISORY mode, signature verification failure should return ERROR
17991803 # We cannot trust a CRL whose signature cannot be verified
18001804 assert result == CRLValidationResult .ERROR
@@ -2066,16 +2070,15 @@ def test_validate_certificate_signatures_in_chain(cert_gen, session_manager):
20662070 )
20672071
20682072
2069- def test_is_certificate_trusted_by_os (cert_gen ):
2070- """Test OS certificate trust validation."""
2071- # Create a test certificate chain
2073+ def test_trusted_certificates_helpers (cert_gen ):
20722074 chain = cert_gen .create_simple_chain ()
20732075
2074- # Create a CRLValidator instance with SSL context
20752076 validator = CRLValidator (
20762077 session_manager = Mock (), trusted_certificates = [chain .root_cert ]
20772078 )
20782079
2079- # Test with a certificate that's in the CA certificates list
20802080 assert validator ._is_certificate_trusted_by_os (chain .root_cert ) is True
20812081 assert validator ._is_certificate_trusted_by_os (chain .intermediate_cert ) is False
2082+
2083+ assert validator ._get_trusted_ca_issuer (chain .intermediate_cert ) is chain .root_cert
2084+ assert validator ._get_trusted_ca_issuer (chain .leaf_cert ) is None
0 commit comments