|
2 | 2 | from urllib.parse import urlsplit |
3 | 3 |
|
4 | 4 | import pytest |
| 5 | +import responses |
5 | 6 | from cryptojwt.key_jar import build_keyjar |
6 | 7 |
|
7 | 8 | from oidcservice.service_context import ServiceContext |
@@ -239,20 +240,21 @@ def test_import_keys_file(self): |
239 | 240 | # Now there should be 2, the second a RSA key for signing |
240 | 241 | assert len(self.service_context.keyjar.get_issuer_keys('')) == 2 |
241 | 242 |
|
242 | | - def test_import_keys_url(self, httpserver): |
| 243 | + def test_import_keys_url(self): |
243 | 244 | assert len(self.service_context.keyjar.get_issuer_keys('')) == 1 |
244 | 245 |
|
245 | 246 | # One EC key for signing |
246 | 247 | key_def = [{"type": "EC", "crv": "P-256", "use": ["sig"]}] |
247 | 248 |
|
248 | 249 | keyjar = build_keyjar(key_def) |
249 | 250 |
|
250 | | - httpserver.serve_content(keyjar.export_jwks_as_json()) |
| 251 | + with responses.RequestsMock() as rsps: |
| 252 | + _jwks_url = 'https://foobar.com/jwks.json' |
| 253 | + rsps.add("GET", _jwks_url, body=keyjar.export_jwks_as_json(), status=200, |
| 254 | + adding_headers={"Content-Type": "application/json"}) |
| 255 | + keyspec = {'url': {'https://foobar.com': _jwks_url}} |
| 256 | + self.service_context.import_keys(keyspec) |
251 | 257 |
|
252 | | - keyspec = {'url': {'https://example.com': httpserver.url }} |
253 | | - |
254 | | - self.service_context.import_keys(keyspec) |
255 | | - |
256 | | - # Now there should be one belonging to https://example.com |
257 | | - assert len(self.service_context.keyjar.get_issuer_keys( |
258 | | - 'https://example.com')) == 1 |
| 258 | + # Now there should be one belonging to https://example.com |
| 259 | + assert len(self.service_context.keyjar.get_issuer_keys( |
| 260 | + 'https://foobar.com')) == 1 |
0 commit comments