Skip to content

Commit

Permalink
Add unit tests for exposed key email rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
gjcthinkst committed Dec 11, 2024
1 parent f8ce003 commit 6869f8a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/units/test_channel_output_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
DNSTokenHit,
Memo,
TokenAlertDetails,
TokenExposedDetails,
TokenTypes,
)
from canarytokens.settings import FrontendSettings, SwitchboardSettings
Expand Down Expand Up @@ -134,6 +135,33 @@ def test_aws_keys_safetynet_rendered_html(settings: SwitchboardSettings):
assert "https://some.link/history/here" in email_template


def test_aws_key_exposed_rendered_html(settings: SwitchboardSettings):
memo = "This is a test Memo"
manage_url = "https://some.link/manage/here"
public_location = "http://example.com/exposed/key"
key_id = "ABCDEFG"

details = TokenExposedDetails(
token_type=TokenTypes.AWS_KEYS,
token=Canarytoken().value(),
memo=memo,
manage_url=manage_url,
key_id=key_id,
public_location=public_location,
exposed_time=datetime.datetime(2030, 12, 21, 12, 0, 0),
)
email_template = EmailOutputChannel.format_token_exposed_html(
details,
Path(settings.TEMPLATES_PATH, f"{EmailTemplates.NOTIFICATION_TOKEN_EXPOSED}"),
)
assert memo in email_template
assert manage_url in email_template
assert public_location in email_template
assert key_id in email_template
assert "2030/12/21" in email_template
assert "12:00" in email_template


def _get_send_token_details() -> TokenAlertDetails:
return TokenAlertDetails(
channel="DNS",
Expand Down

0 comments on commit 6869f8a

Please sign in to comment.