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) abort(403)
@key_server.route('/services/<service>/keys', methods=['GET']) def jwk_with_kid(key):
def list_service_keys(service): jwk = key.jwk.copy()
keys = model.list_service_keys(service)
def jwk_with_kid(key):
jwk = key.jwk
jwk.update({'kid': key.kid}) jwk.update({'kid': key.kid})
return jwk return jwk
@key_server.route('/services/<service>/keys', methods=['GET'])
def list_service_keys(service):
keys = model.list_service_keys(service)
return jsonify({'keys': [jwk_with_kid(key) for key in keys]}) 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 import keyserver
from endpoints.api import api, api_bp from endpoints.api import api, api_bp
from endpoints.api.user import Signin from endpoints.api.user import Signin
from endpoints.keyserver import jwk_with_kid
from endpoints.web import web as web_bp from endpoints.web import web as web_bp
from initdb import setup_database_for_testing, finished_database_for_testing from initdb import setup_database_for_testing, finished_database_for_testing
from test.helpers import assert_action_logged from test.helpers import assert_action_logged
@ -364,7 +365,7 @@ class KeyServerTestCase(EndpointTestCase):
def test_list_service_keys(self): def test_list_service_keys(self):
# Retrieve all the keys. # Retrieve all the keys.
all_keys = model.service_keys.list_all_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 = [] invisible_jwks = []
for key in all_keys: for key in all_keys: