|
4 | 4 | import pytest |
5 | 5 | from mock import MagicMock, sentinel |
6 | 6 | from pytest_mock import mocker # noqa pylint: disable=unused-import |
| 7 | +from cryptography.hazmat.primitives.asymmetric import ec |
7 | 8 |
|
8 | 9 | import aws_encryption_sdk.internal.crypto.authentication |
9 | 10 | from aws_encryption_sdk.exceptions import NotSupportedError |
@@ -56,12 +57,19 @@ def test_init(patch_set_signature_type, patch_build_hasher): |
56 | 57 | def test_set_signature_type_elliptic_curve( |
57 | 58 | patch_build_hasher, patch_cryptography_ec |
58 | 59 | ): |
59 | | - mock_algorithm_info = MagicMock(return_value=sentinel.algorithm_info, spec=patch_cryptography_ec.EllipticCurve) |
60 | | - mock_algorithm = MagicMock(signing_algorithm_info=mock_algorithm_info) |
| 60 | + patch_cryptography_ec.EllipticCurve = ec.EllipticCurve |
| 61 | + mock_algorithm = MagicMock(signing_algorithm_info=ec.SECP256R1) |
61 | 62 | test = _PrehashingAuthenticator(algorithm=mock_algorithm, key=sentinel.key) |
62 | 63 |
|
63 | 64 | assert test._signature_type is patch_cryptography_ec.EllipticCurve |
64 | 65 |
|
| 66 | +def test_set_signature_type_elliptic_curve_known_value(patch_build_hasher): |
| 67 | + from cryptography.hazmat.primitives.asymmetric import ec as real_ec |
| 68 | + |
| 69 | + mock_algorithm = MagicMock(signing_algorithm_info=real_ec.SECP384R1) |
| 70 | + test = _PrehashingAuthenticator(algorithm=mock_algorithm, key=sentinel.key) |
| 71 | + |
| 72 | + assert test._signature_type is real_ec.EllipticCurve |
65 | 73 |
|
66 | 74 | def test_set_signature_type_unknown( |
67 | 75 | patch_build_hasher, patch_cryptography_ec |
|
0 commit comments