|
27 | 27 |
|
28 | 28 | DATA_DIR = os.path.join(os.path.dirname(__file__), "..", "data") |
29 | 29 |
|
| 30 | + |
30 | 31 | @pytest.fixture |
31 | 32 | def private_key_bytes(): |
32 | 33 | with open(os.path.join(DATA_DIR, "privatekey.pem"), "rb") as fh: |
33 | 34 | return fh.read() |
34 | 35 |
|
| 36 | + |
35 | 37 | @pytest.fixture |
36 | 38 | def public_key_bytes(): |
37 | 39 | with open(os.path.join(DATA_DIR, "privatekey.pub"), "rb") as fh: |
38 | 40 | return fh.read() |
39 | 41 |
|
| 42 | + |
40 | 43 | @pytest.fixture |
41 | 44 | def cryptography_private_key(private_key_bytes): |
42 | 45 | return serialization.load_pem_private_key( |
43 | 46 | private_key_bytes, password=None, backend=backends.default_backend() |
44 | 47 | ) |
45 | 48 |
|
| 49 | + |
46 | 50 | @pytest.fixture |
47 | 51 | def rsa_private_key(private_key_bytes): |
48 | 52 | return rsa_lib.PrivateKey.load_pkcs1(private_key_bytes) |
49 | 53 |
|
| 54 | + |
50 | 55 | @pytest.fixture |
51 | 56 | def cryptography_public_key(public_key_bytes): |
52 | 57 | return serialization.load_pem_public_key( |
53 | 58 | public_key_bytes, backend=backends.default_backend() |
54 | 59 | ) |
55 | 60 |
|
| 61 | + |
56 | 62 | @pytest.fixture |
57 | 63 | def rsa_public_key(public_key_bytes): |
58 | 64 | return rsa_lib.PublicKey.load_pkcs1(public_key_bytes) |
@@ -135,7 +141,9 @@ def test_sign_delegates(self, rsa_private_key): |
135 | 141 | mock_sign.assert_called_once_with(b"message") |
136 | 142 |
|
137 | 143 | @mock.patch("google.auth.crypt.rsa._cryptography_rsa") |
138 | | - def test_from_string_delegates_to_cryptography(self, mock_crypto, private_key_bytes): |
| 144 | + def test_from_string_delegates_to_cryptography( |
| 145 | + self, mock_crypto, private_key_bytes |
| 146 | + ): |
139 | 147 | expected_signer = mock.Mock() |
140 | 148 | mock_crypto.RSASigner.from_string.return_value = expected_signer |
141 | 149 |
|
|
0 commit comments