Skip to content

Commit

Permalink
PRMDR-168
Browse files Browse the repository at this point in the history
ensuring AUTH_DYNAMODB_NAME variable exists before processing
  • Loading branch information
AlexHerbertNHS committed Oct 20, 2023
1 parent 8ea45f6 commit cc6485c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lambdas/handlers/back_channel_logout_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


@ensure_environment_variables(
names=["OIDC_CALLBACK_URL"]
names=["OIDC_CALLBACK_URL", "AUTH_DYNAMODB_NAME"]
)
def lambda_handler(event, context):
logger.info(f"event = {event}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def test_returns_500_when_env_vars_not_set():
def test_back_channel_logout_handler_valid_jwt_returns_200_if_session_exists(mocker, mock_oidc_service, monkeypatch,
context):
monkeypatch.setenv("OIDC_CALLBACK_URL", "mock_url")
monkeypatch.setenv("AUTH_DYNAMODB_NAME", "mock_dynamo_name")
mock_token = "mock_token"
mock_session_id = "mock_session_id"
mock_decoded_token = {"sid": mock_session_id}
Expand All @@ -55,7 +56,7 @@ def test_back_channel_logout_handler_valid_jwt_returns_200_if_session_exists(moc
def test_back_channel_logout_handler_missing_jwt_returns_400(mocker, mock_oidc_service, monkeypatch,
context):
monkeypatch.setenv("OIDC_CALLBACK_URL", "mock_url")
mock_token = "mock_token"
monkeypatch.setenv("AUTH_DYNAMODB_NAME", "mock_dynamo_name")
event = {
"httpMethod": "POST",
"body": "{}"
Expand All @@ -70,6 +71,7 @@ def test_back_channel_logout_handler_missing_jwt_returns_400(mocker, mock_oidc_s

def test_back_channel_logout_handler_jwt_without_session_id_returns_400(mock_oidc_service, monkeypatch):
monkeypatch.setenv("OIDC_CALLBACK_URL", "mock_url")
monkeypatch.setenv("AUTH_DYNAMODB_NAME", "mock_dynamo_name")
mock_token = "mock_token"
mock_session_id = "mock_session_id"
mock_decoded_token = {"not_an_sid": mock_session_id}
Expand All @@ -87,6 +89,7 @@ def test_back_channel_logout_handler_jwt_without_session_id_returns_400(mock_oid

def test_back_channel_logout_handler_invalid_jwt_returns_400(mock_oidc_service, monkeypatch):
monkeypatch.setenv("OIDC_CALLBACK_URL", "mock_url")
monkeypatch.setenv("AUTH_DYNAMODB_NAME", "mock_dynamo_name")
mock_token = "mock_token"
mock_oidc_service.side_effect = AuthorisationException

Expand All @@ -102,6 +105,7 @@ def test_back_channel_logout_handler_invalid_jwt_returns_400(mock_oidc_service,

def test_back_channel_logout_handler_boto_error_returns_400(mocker, mock_oidc_service, monkeypatch):
monkeypatch.setenv("OIDC_CALLBACK_URL", "mock_url")
monkeypatch.setenv("AUTH_DYNAMODB_NAME", "mock_dynamo_name")
mock_token = "mock_token"
mock_session_id = "mock_session_id"
mock_decoded_token = {"sid": mock_session_id}
Expand Down

0 comments on commit cc6485c

Please sign in to comment.