Skip to content

Commit

Permalink
Bugfix/msi 707 user id pool hook validation issue (#1571)
Browse files Browse the repository at this point in the history
* Initial add of VSCode Dev Container

* Potential fix for #1405 static site options issue

* Fixing spelling issue

* Adding unit test covering changed code
  • Loading branch information
jake-skipper committed Sep 1, 2022
1 parent 72eeb8b commit ee6bf91
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Retrieve the ID of the Cognito User Pool."""
import logging
from typing import Any, Dict
from typing import Any, Dict, Optional

from ...base import HookArgsBaseModel

Expand All @@ -10,10 +10,10 @@
class HookArgs(HookArgsBaseModel):
"""Hook arguments."""

created_user_pool_id: str
created_user_pool_id: Optional[str] = None
"""The ID of the created Cognito User Pool."""

user_pool_arn: str
user_pool_arn: Optional[str] = None
"""The ARN of the supplied User pool."""


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Empty init for python import traversal."""
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Test runway.cfngin.hooks.staticsite.auth_at_edge.user_pool_id_retriever."""
from __future__ import annotations

import pytest

from runway.cfngin.hooks.staticsite.auth_at_edge.user_pool_id_retriever import HookArgs

MODULE = "runway.cfngin.hooks.staticsite.auth_at_edge.user_pool_id_retriever"


@pytest.mark.parametrize(
"provided, expected",
[
({"user_pool_arn": "abc123"}, {"user_pool_arn": "abc123"}),
({"created_user_pool_id": "abc123"}, {"created_user_pool_id": "abc123"}),
(
{"created_user_pool_id": "abc123", "user_pool_arn": "abc123"},
{"created_user_pool_id": "abc123", "user_pool_arn": "abc123"},
),
],
)
def test_hook_args_parse_obj(
provided: dict[str, str], expected: dict[str, str]
) -> None:
"""Test HookArgs.parse_obj."""
kwargs = provided
args = HookArgs.parse_obj(kwargs)
if "user_pool_arn" in provided:
assert args.user_pool_arn == expected["user_pool_arn"]
if "created_user_pool_id" in provided:
assert args.created_user_pool_id == expected["created_user_pool_id"]

0 comments on commit ee6bf91

Please sign in to comment.