mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-21 07:51:13 -05:00
Added test that the token can be signed and retrieved
This commit is contained in:
@@ -113,7 +113,8 @@ def delete_token(service_id):
|
||||
return jsonify(result="error", message="Token not found"), 404
|
||||
|
||||
|
||||
def _generate_token():
|
||||
def _generate_token(token=None):
|
||||
if not token:
|
||||
token = uuid.uuid4()
|
||||
serializer = URLSafeSerializer(current_app.config.get('SECRET_KEY'))
|
||||
return serializer.dumps(str(token), current_app.config.get('DANGEROUS_SALT'))
|
||||
|
||||
@@ -318,6 +318,15 @@ def test_delete_token(notify_api, notify_db, notify_db_session, sample_service):
|
||||
assert len(Token.query.all()) == 0
|
||||
|
||||
|
||||
def test_token_generated_can_be_read_again(notify_api):
|
||||
from app.service.views.rest import (_generate_token, _get_token)
|
||||
import uuid
|
||||
with notify_api.test_request_context():
|
||||
token = str(uuid.uuid4())
|
||||
signed_token = _generate_token(token=token)
|
||||
assert token == _get_token(signed_token)
|
||||
|
||||
|
||||
def test_create_template(notify_api, notify_db, notify_db_session, sample_service):
|
||||
"""
|
||||
Tests POST endpoint '/<service_id>/template' a template can be created
|
||||
|
||||
Reference in New Issue
Block a user