Fix timeouts in the JWT endpoint tests
This commit is contained in:
parent
522cf68c5d
commit
bc08ac2749
3 changed files with 15 additions and 13 deletions
|
@ -190,13 +190,14 @@ class WebEndpointTestCase(EndpointTestCase):
|
|||
|
||||
|
||||
class KeyServerTestCase(EndpointTestCase):
|
||||
_test_jwt_payload = {
|
||||
'iss': 'sample_service',
|
||||
'aud': key_server.JWT_AUDIENCE,
|
||||
'exp': int(time.time()) + 60,
|
||||
'iat': int(time.time()),
|
||||
'nbf': int(time.time()),
|
||||
}
|
||||
def _get_test_jwt_payload(self):
|
||||
return {
|
||||
'iss': 'sample_service',
|
||||
'aud': key_server.JWT_AUDIENCE,
|
||||
'exp': int(time.time()) + 60,
|
||||
'iat': int(time.time()),
|
||||
'nbf': int(time.time()),
|
||||
}
|
||||
|
||||
def test_list_service_keys(self):
|
||||
unapproved_key = model.service_keys.get_service_key(kid='kid3')
|
||||
|
@ -227,7 +228,7 @@ class KeyServerTestCase(EndpointTestCase):
|
|||
# Mint a JWT with our test payload
|
||||
private_key = RSA.generate(2048)
|
||||
jwk = RSAKey(key=private_key.publickey()).serialize()
|
||||
payload = self._test_jwt_payload
|
||||
payload = self._get_test_jwt_payload()
|
||||
token = jwt.encode(payload, private_key.exportKey('PEM'), 'RS256')
|
||||
|
||||
# Publish a new key
|
||||
|
@ -266,7 +267,7 @@ class KeyServerTestCase(EndpointTestCase):
|
|||
model.service_keys.approve_service_key('kid123', 1, ServiceKeyApprovalType.SUPERUSER)
|
||||
|
||||
# Mint a JWT with our test payload
|
||||
token = jwt.encode(self._test_jwt_payload, private_key.exportKey('PEM'), 'RS256',
|
||||
token = jwt.encode(self._get_test_jwt_payload(), private_key.exportKey('PEM'), 'RS256',
|
||||
headers={'kid': 'kid123'})
|
||||
|
||||
# Using the credentials of our approved key, delete our unapproved key
|
||||
|
@ -275,7 +276,7 @@ class KeyServerTestCase(EndpointTestCase):
|
|||
expected_code=204, service='sample_service', kid='kid321')
|
||||
|
||||
# Attempt to delete a key signed by a key from a different service
|
||||
bad_token = jwt.encode(self._test_jwt_payload, private_key.exportKey('PEM'), 'RS256',
|
||||
bad_token = jwt.encode(self._get_test_jwt_payload(), private_key.exportKey('PEM'), 'RS256',
|
||||
headers={'kid': 'kid5'})
|
||||
self.deleteResponse('key_server.delete_service_key',
|
||||
headers={'Authorization': 'Bearer %s' % bad_token},
|
||||
|
|
Reference in a new issue