mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
Added authorization headers for all requests
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import json
|
||||
from app.models import Template
|
||||
from flask import url_for
|
||||
|
||||
from tests import create_authorization_header
|
||||
|
||||
|
||||
def test_get_template_list(notify_api, notify_db, notify_db_session, sample_template):
|
||||
"""
|
||||
@@ -9,7 +10,11 @@ def test_get_template_list(notify_api, notify_db, notify_db_session, sample_temp
|
||||
"""
|
||||
with notify_api.test_request_context():
|
||||
with notify_api.test_client() as client:
|
||||
response = client.get(url_for('template.get_template'))
|
||||
auth_header = create_authorization_header(service_id=sample_template.service_id,
|
||||
path=url_for('template.get_template'),
|
||||
method='GET')
|
||||
response = client.get(url_for('template.get_template'),
|
||||
headers=[auth_header])
|
||||
assert response.status_code == 200
|
||||
json_resp = json.loads(response.get_data(as_text=True))
|
||||
assert len(json_resp['data']) == 1
|
||||
@@ -23,8 +28,13 @@ def test_get_template(notify_api, notify_db, notify_db_session, sample_template)
|
||||
"""
|
||||
with notify_api.test_request_context():
|
||||
with notify_api.test_client() as client:
|
||||
auth_header = create_authorization_header(service_id=sample_template.service_id,
|
||||
path=url_for('template.get_template',
|
||||
template_id=sample_template.id),
|
||||
method='GET')
|
||||
resp = client.get(url_for(
|
||||
'template.get_template', template_id=sample_template.id))
|
||||
'template.get_template', template_id=sample_template.id),
|
||||
headers=[auth_header])
|
||||
assert resp.status_code == 200
|
||||
json_resp = json.loads(resp.get_data(as_text=True))
|
||||
assert json_resp['data']['name'] == sample_template.name
|
||||
|
||||
Reference in New Issue
Block a user