key server: fix tests by exporting jwk_with_kid

This commit is contained in:
Jimmy Zelinskie 2016-10-25 15:57:55 -04:00
parent ea5039877c
commit 30821569a4
2 changed files with 8 additions and 7 deletions

View file

@ -58,15 +58,15 @@ def _lookup_service_key(service, signer_kid, approved_only=True):
abort(403)
def jwk_with_kid(key):
jwk = key.jwk.copy()
jwk.update({'kid': key.kid})
return jwk
@key_server.route('/services/<service>/keys', methods=['GET'])
def list_service_keys(service):
keys = model.list_service_keys(service)
def jwk_with_kid(key):
jwk = key.jwk
jwk.update({'kid': key.kid})
return jwk
return jsonify({'keys': [jwk_with_kid(key) for key in keys]})

View file

@ -21,6 +21,7 @@ from data.database import ServiceKeyApprovalType
from endpoints import keyserver
from endpoints.api import api, api_bp
from endpoints.api.user import Signin
from endpoints.keyserver import jwk_with_kid
from endpoints.web import web as web_bp
from initdb import setup_database_for_testing, finished_database_for_testing
from test.helpers import assert_action_logged
@ -364,7 +365,7 @@ class KeyServerTestCase(EndpointTestCase):
def test_list_service_keys(self):
# Retrieve all the keys.
all_keys = model.service_keys.list_all_keys()
visible_jwks = [key.jwk for key in model.service_keys.list_service_keys('sample_service')]
visible_jwks = [jwk_with_kid(key) for key in model.service_keys.list_service_keys('sample_service')]
invisible_jwks = []
for key in all_keys: