|
7 | 7 | ECDSAECKey = CryptographyECKey = None
|
8 | 8 | from jose.constants import ALGORITHMS
|
9 | 9 |
|
10 |
| -from .test_EC import private_key |
| 10 | +from .test_EC import get_pem_for_key, normalize_pem, private_key |
11 | 11 |
|
12 | 12 |
|
13 | 13 | @pytest.mark.backend_compatibility
|
@@ -37,35 +37,35 @@ def test_public_key_to_pem(self, BackendFrom, BackendTo):
|
37 | 37 | key = BackendFrom(private_key, ALGORITHMS.ES256)
|
38 | 38 | key2 = BackendTo(private_key, ALGORITHMS.ES256)
|
39 | 39 |
|
40 |
| - assert key.public_key().to_pem().strip() == key2.public_key().to_pem().strip() |
| 40 | + assert normalize_pem(get_pem_for_key(key.public_key())) == normalize_pem(get_pem_for_key(key2.public_key())) |
41 | 41 |
|
42 | 42 | @pytest.mark.parametrize("BackendFrom", [ECDSAECKey, CryptographyECKey])
|
43 | 43 | @pytest.mark.parametrize("BackendTo", [ECDSAECKey, CryptographyECKey])
|
44 | 44 | def test_private_key_to_pem(self, BackendFrom, BackendTo):
|
45 | 45 | key = BackendFrom(private_key, ALGORITHMS.ES256)
|
46 | 46 | key2 = BackendTo(private_key, ALGORITHMS.ES256)
|
47 | 47 |
|
48 |
| - assert key.to_pem().strip() == key2.to_pem().strip() |
| 48 | + assert normalize_pem(get_pem_for_key(key)) == normalize_pem(get_pem_for_key(key2)) |
49 | 49 |
|
50 | 50 | @pytest.mark.parametrize("BackendFrom", [ECDSAECKey, CryptographyECKey])
|
51 | 51 | @pytest.mark.parametrize("BackendTo", [ECDSAECKey, CryptographyECKey])
|
52 | 52 | def test_public_key_load_cycle(self, BackendFrom, BackendTo):
|
53 | 53 | key = BackendFrom(private_key, ALGORITHMS.ES256)
|
54 | 54 | pubkey = key.public_key()
|
55 | 55 |
|
56 |
| - pub_pem_source = pubkey.to_pem().strip() |
| 56 | + pub_pem_source = normalize_pem(get_pem_for_key(pubkey)) |
57 | 57 |
|
58 | 58 | pub_target = BackendTo(pub_pem_source, ALGORITHMS.ES256)
|
59 | 59 |
|
60 |
| - assert pub_pem_source == pub_target.to_pem().strip() |
| 60 | + assert pub_pem_source == normalize_pem(get_pem_for_key(pub_target)) |
61 | 61 |
|
62 | 62 | @pytest.mark.parametrize("BackendFrom", [ECDSAECKey, CryptographyECKey])
|
63 | 63 | @pytest.mark.parametrize("BackendTo", [ECDSAECKey, CryptographyECKey])
|
64 | 64 | def test_private_key_load_cycle(self, BackendFrom, BackendTo):
|
65 | 65 | key = BackendFrom(private_key, ALGORITHMS.ES256)
|
66 | 66 |
|
67 |
| - pem_source = key.to_pem().strip() |
| 67 | + pem_source = normalize_pem(get_pem_for_key(key)) |
68 | 68 |
|
69 | 69 | target = BackendTo(pem_source, ALGORITHMS.ES256)
|
70 | 70 |
|
71 |
| - assert pem_source == target.to_pem().strip() |
| 71 | + assert pem_source == normalize_pem(get_pem_for_key(target)) |
0 commit comments