Skip to content

Commit

Permalink
Update invalid EC key test for compatibility with upcoming OpenSSL ch…
Browse files Browse the repository at this point in the history
…anges (pyca#7833)

One of the tests checking behavior with invalid EC keys hardcoded the
error reason.

This commit replaces the string matching with a regex to match both the
current string and a new reason, introduced by upcoming OpenSSL
changes [0], which would otherwise trigger a false positive failure.

[0]: openssl/openssl#19681
  • Loading branch information
romen authored and reaperhulk committed Nov 27, 2022
1 parent 7d9c6c3 commit 597605c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/hazmat/primitives/test_ec.py
Expand Up @@ -479,7 +479,9 @@ def test_load_invalid_ec_key_from_pem(self, backend):
# BoringSSL rejects infinity points before it ever gets to us, so it
# uses a more generic error message.
match = (
"infinity" if not backend._lib.CRYPTOGRAPHY_IS_BORINGSSL else None
r"infinity|invalid form"
if not backend._lib.CRYPTOGRAPHY_IS_BORINGSSL
else None
)
with pytest.raises(ValueError, match=match):
serialization.load_pem_public_key(
Expand Down

0 comments on commit 597605c

Please sign in to comment.