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:
Ben Thorner
2021-08-04 15:12:09 +01:00
parent 5a1636e41f
commit 0312e2a528
33 changed files with 526 additions and 512 deletions

View File

@@ -2,7 +2,7 @@ import json
import uuid
from app.models import LetterBranding
from tests import create_authorization_header
from tests import create_admin_authorization_header
from tests.app.db import create_letter_branding
@@ -11,7 +11,7 @@ def test_get_all_letter_brands(client, notify_db_session):
test_branding = create_letter_branding(
name='test branding', filename='test-branding',
)
response = client.get('/letter-branding', headers=[create_authorization_header()])
response = client.get('/letter-branding', headers=[create_admin_authorization_header()])
assert response.status_code == 200
json_response = json.loads(response.get_data(as_text=True))
assert len(json_response) == 2
@@ -29,14 +29,14 @@ def test_get_letter_branding_by_id(client, notify_db_session):
create_letter_branding(
name='test domain', filename='test-domain'
)
response = client.get('/letter-branding/{}'.format(hm_gov.id), headers=[create_authorization_header()])
response = client.get('/letter-branding/{}'.format(hm_gov.id), headers=[create_admin_authorization_header()])
assert response.status_code == 200
assert json.loads(response.get_data(as_text=True)) == hm_gov.serialize()
def test_get_letter_branding_by_id_returns_404_if_does_not_exist(client, notify_db_session):
response = client.get('/letter-branding/{}'.format(uuid.uuid4()), headers=[create_authorization_header()])
response = client.get('/letter-branding/{}'.format(uuid.uuid4()), headers=[create_admin_authorization_header()])
assert response.status_code == 404
@@ -49,7 +49,7 @@ def test_create_letter_branding(client, notify_db_session):
response = client.post(
'/letter-branding',
data=json.dumps(form),
headers=[('Content-Type', 'application/json'), create_authorization_header()],
headers=[('Content-Type', 'application/json'), create_admin_authorization_header()],
)
assert response.status_code == 201
@@ -71,7 +71,7 @@ def test_update_letter_branding_returns_400_when_integrity_error_is_thrown(
response = client.post(
'/letter-branding/{}'.format(brand_to_update.id),
headers=[('Content-Type', 'application/json'), create_authorization_header()],
headers=[('Content-Type', 'application/json'), create_admin_authorization_header()],
data=json.dumps(form)
)