mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
Split generating authorization headers by type
In response to [1]. [1]: https://github.com/alphagov/notifications-api/pull/3300#discussion_r681653248
This commit is contained in:
@@ -2,7 +2,7 @@ import json
|
||||
import uuid
|
||||
|
||||
from app.models import ServiceDataRetention
|
||||
from tests import create_authorization_header
|
||||
from tests import create_admin_authorization_header
|
||||
from tests.app.db import create_service_data_retention
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ def test_get_service_data_retention(client, sample_service):
|
||||
|
||||
response = client.get(
|
||||
'/service/{}/data-retention'.format(str(sample_service.id)),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()],
|
||||
headers=[('Content-Type', 'application/json'), create_admin_authorization_header()],
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
@@ -29,7 +29,7 @@ def test_get_service_data_retention(client, sample_service):
|
||||
def test_get_service_data_retention_returns_empty_list(client, sample_service):
|
||||
response = client.get(
|
||||
'/service/{}/data-retention'.format(str(sample_service.id)),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()],
|
||||
headers=[('Content-Type', 'application/json'), create_admin_authorization_header()],
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert len(json.loads(response.get_data(as_text=True))) == 0
|
||||
@@ -38,7 +38,7 @@ def test_get_service_data_retention_returns_empty_list(client, sample_service):
|
||||
def test_get_data_retention_for_service_notification_type(client, sample_service):
|
||||
data_retention = create_service_data_retention(service=sample_service)
|
||||
response = client.get('/service/{}/data-retention/notification-type/{}'.format(sample_service.id, 'sms'),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()],
|
||||
headers=[('Content-Type', 'application/json'), create_admin_authorization_header()],
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert json.loads(response.get_data(as_text=True)) == data_retention.serialize()
|
||||
@@ -52,7 +52,7 @@ def test_get_service_data_retention_by_id(client, sample_service):
|
||||
days_of_retention=30)
|
||||
response = client.get(
|
||||
'/service/{}/data-retention/{}'.format(str(sample_service.id), sms_data_retention.id),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()],
|
||||
headers=[('Content-Type', 'application/json'), create_admin_authorization_header()],
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert json.loads(response.get_data(as_text=True)) == sms_data_retention.serialize()
|
||||
@@ -61,7 +61,7 @@ def test_get_service_data_retention_by_id(client, sample_service):
|
||||
def test_get_service_data_retention_by_id_returns_none_when_no_data_retention_exists(client, sample_service):
|
||||
response = client.get(
|
||||
'/service/{}/data-retention/{}'.format(str(sample_service.id), uuid.uuid4()),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()],
|
||||
headers=[('Content-Type', 'application/json'), create_admin_authorization_header()],
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert json.loads(response.get_data(as_text=True)) == {}
|
||||
@@ -74,7 +74,7 @@ def test_create_service_data_retention(client, sample_service):
|
||||
}
|
||||
response = client.post(
|
||||
'/service/{}/data-retention'.format(str(sample_service.id)),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()],
|
||||
headers=[('Content-Type', 'application/json'), create_admin_authorization_header()],
|
||||
data=json.dumps(data)
|
||||
)
|
||||
|
||||
@@ -93,7 +93,7 @@ def test_create_service_data_retention_returns_400_when_notification_type_is_inv
|
||||
}
|
||||
response = client.post(
|
||||
'/service/{}/data-retention'.format(str(uuid.uuid4())),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()],
|
||||
headers=[('Content-Type', 'application/json'), create_admin_authorization_header()],
|
||||
data=json.dumps(data)
|
||||
)
|
||||
json_resp = json.loads(response.get_data(as_text=True))
|
||||
@@ -112,7 +112,7 @@ def test_create_service_data_retention_returns_400_when_data_retention_for_notif
|
||||
}
|
||||
response = client.post(
|
||||
'/service/{}/data-retention'.format(str(uuid.uuid4())),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()],
|
||||
headers=[('Content-Type', 'application/json'), create_admin_authorization_header()],
|
||||
data=json.dumps(data)
|
||||
)
|
||||
|
||||
@@ -129,7 +129,7 @@ def test_modify_service_data_retention(client, sample_service):
|
||||
}
|
||||
response = client.post(
|
||||
'/service/{}/data-retention/{}'.format(sample_service.id, data_retention.id),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()],
|
||||
headers=[('Content-Type', 'application/json'), create_admin_authorization_header()],
|
||||
data=json.dumps(data)
|
||||
)
|
||||
assert response.status_code == 204
|
||||
@@ -142,7 +142,7 @@ def test_modify_service_data_retention_returns_400_when_data_retention_does_not_
|
||||
}
|
||||
response = client.post(
|
||||
'/service/{}/data-retention/{}'.format(sample_service.id, uuid.uuid4()),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()],
|
||||
headers=[('Content-Type', 'application/json'), create_admin_authorization_header()],
|
||||
data=json.dumps(data)
|
||||
)
|
||||
|
||||
@@ -155,7 +155,7 @@ def test_modify_service_data_retention_returns_400_when_data_is_invalid(client):
|
||||
}
|
||||
response = client.post(
|
||||
'/service/{}/data-retention/{}'.format(uuid.uuid4(), uuid.uuid4()),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()],
|
||||
headers=[('Content-Type', 'application/json'), create_admin_authorization_header()],
|
||||
data=json.dumps(data)
|
||||
)
|
||||
assert response.status_code == 400
|
||||
|
||||
Reference in New Issue
Block a user