This commit is contained in:
Kenneth Kehl
2025-09-10 10:34:56 -07:00
parent 861df96c8a
commit 4a3a1394b4

View File

@@ -16,14 +16,8 @@ from tests import create_service_authorization_header
from tests.app.db import create_api_key, create_notification from tests.app.db import create_api_key, create_notification
@given( @pytest.mark.usefixtures(
st.emails(), "client", "sample_service", "sample_template", "notify_db_session"
st.dictionaries(
keys=st.text(min_size=1, max_size=20),
values=st.text(min_size=0, max_size=100),
max_size=5,
),
st.one_of(st.none(), st.text(min_size=0, max_size=50)),
) )
def test_fuzz_send_email_notification( def test_fuzz_send_email_notification(
client, client,
@@ -34,21 +28,36 @@ def test_fuzz_send_email_notification(
personalisation, personalisation,
reference, reference,
): ):
template_id = str(sample_template.id) @given(
auth_header = { st.emails(),
"Authorization": "ApiKey-v1 {}".format(sample_service.api_keys[0].secret) st.dictionaries(
} keys=st.text(min_size=1, max_size=20),
payload = { values=st.text(min_size=0, max_size=100),
"template_id": template_id, max_size=5,
"email_address": email_address, ),
"personalisation": personalisation, st.one_of(st.none(), st.text(min_size=0, max_size=50)),
"reference": reference, )
} def inner(email_address, personalisation, reference):
response = client.post("/v2/notifications/email", json=payload, headers=auth_header)
assert response.status_code in ( template_id = str(sample_template.id)
201, auth_header = {
400, "Authorization": "ApiKey-v1 {}".format(sample_service.api_keys[0].secret)
), f"Unexpected status: {response.status_code}, body: {response.json}" }
payload = {
"template_id": template_id,
"email_address": email_address,
"personalisation": personalisation,
"reference": reference,
}
response = client.post(
"/v2/notifications/email", json=payload, headers=auth_header
)
assert response.status_code in (
201,
400,
), f"Unexpected status: {response.status_code}, body: {response.json}"
inner()
@pytest.mark.parametrize("type", (NotificationType.EMAIL, NotificationType.SMS)) @pytest.mark.parametrize("type", (NotificationType.EMAIL, NotificationType.SMS))