From d222736d18a334bc248291a03a1aafdefb33ac2d Mon Sep 17 00:00:00 2001 From: Nicola Tuveri Date: Mon, 21 Nov 2022 17:57:35 +0200 Subject: [PATCH] Update invalid EC key test for compatibility with upcoming OpenSSL changes 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]: https://github.com/openssl/openssl/pull/19681 --- tests/hazmat/primitives/test_ec.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/hazmat/primitives/test_ec.py b/tests/hazmat/primitives/test_ec.py index 6022b95022f7..3d488be1720c 100644 --- a/tests/hazmat/primitives/test_ec.py +++ b/tests/hazmat/primitives/test_ec.py @@ -411,7 +411,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(