mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-17 18:52:30 -05:00
Merge branch 'master' into change-v2-error-resp
This commit is contained in:
@@ -28,7 +28,7 @@ def get_auth_token(req):
|
|||||||
if not auth_header:
|
if not auth_header:
|
||||||
raise AuthError('Unauthorized, authentication token must be provided', 401)
|
raise AuthError('Unauthorized, authentication token must be provided', 401)
|
||||||
|
|
||||||
auth_scheme = auth_header[:7]
|
auth_scheme = auth_header[:7].title()
|
||||||
|
|
||||||
if auth_scheme != 'Bearer ':
|
if auth_scheme != 'Bearer ':
|
||||||
raise AuthError('Unauthorized, authentication bearer scheme must be used', 401)
|
raise AuthError('Unauthorized, authentication bearer scheme must be used', 401)
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ def send_sms(self,
|
|||||||
)
|
)
|
||||||
|
|
||||||
current_app.logger.info(
|
current_app.logger.info(
|
||||||
"SMS {} created at {}".format(notification_id, created_at)
|
"SMS {} created at {} for job {}".format(notification_id, created_at, notification.get('job', None))
|
||||||
)
|
)
|
||||||
|
|
||||||
except SQLAlchemyError as e:
|
except SQLAlchemyError as e:
|
||||||
|
|||||||
@@ -23,4 +23,4 @@ git+https://github.com/alphagov/notifications-python-client.git@1.3.0#egg=notifi
|
|||||||
|
|
||||||
git+https://github.com/alphagov/notifications-utils.git@9.1.1#egg=notifications-utils==9.1.1
|
git+https://github.com/alphagov/notifications-utils.git@9.1.1#egg=notifications-utils==9.1.1
|
||||||
|
|
||||||
git+https://github.com/alphagov/boto.git@2.42.0-patch2#egg=boto==2.42.0-patch2
|
git+https://github.com/alphagov/boto.git@2.43.0-patch3#egg=boto==2.43.0-patch3
|
||||||
|
|||||||
@@ -56,13 +56,14 @@ def test_should_not_allow_invalid_secret(notify_api, sample_api_key):
|
|||||||
assert data['message'] == {"token": ['Invalid token: signature, api token is not valid']}
|
assert data['message'] == {"token": ['Invalid token: signature, api token is not valid']}
|
||||||
|
|
||||||
|
|
||||||
def test_should_allow_valid_token(notify_api, sample_api_key):
|
@pytest.mark.parametrize('scheme', ['bearer', 'Bearer'])
|
||||||
|
def test_should_allow_valid_token(notify_api, sample_api_key, scheme):
|
||||||
with notify_api.test_request_context():
|
with notify_api.test_request_context():
|
||||||
with notify_api.test_client() as client:
|
with notify_api.test_client() as client:
|
||||||
token = __create_get_token(sample_api_key.service_id)
|
token = __create_get_token(sample_api_key.service_id)
|
||||||
response = client.get(
|
response = client.get(
|
||||||
'/service/{}'.format(str(sample_api_key.service_id)),
|
'/service/{}'.format(str(sample_api_key.service_id)),
|
||||||
headers={'Authorization': 'Bearer {}'.format(token)}
|
headers={'Authorization': '{} {}'.format(scheme, token)}
|
||||||
)
|
)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user