Add pretend authenticated API for govuk-alerts

We can define the API properly in future work. I've used a separate
blueprint from "broadcasts" since this API is purely internal, and
it's helpful to make it clear it's specific to govuk-alerts.
This commit is contained in:
Ben Thorner
2021-07-29 12:25:28 +01:00
parent 3e32fc99b8
commit 4b7ad89f6a
6 changed files with 45 additions and 2 deletions

View File

@@ -78,6 +78,15 @@ def test_requires_admin_auth_should_allow_valid_token_for_request(client):
assert response.status_code == 200
def test_requires_govuk_alerts_auth_should_allow_valid_token_for_request(client):
govuk_alerts_jwt_client_id = current_app.config['GOVUK_ALERTS_CLIENT_ID']
govuk_alerts_jwt_secret = current_app.config['INTERNAL_CLIENT_API_KEYS'][govuk_alerts_jwt_client_id][0]
govuk_alerts_jwt_token = create_jwt_token(govuk_alerts_jwt_secret, govuk_alerts_jwt_client_id)
response = client.get('/v2/govuk-alerts', headers={'Authorization': 'Bearer {}'.format(govuk_alerts_jwt_token)})
assert response.status_code == 200
def test_get_auth_token_should_not_allow_request_with_no_token(client):
request.headers = {}
with pytest.raises(AuthError) as exc: