🐛(dimail) improve handling of dimail errors on failed mailbox creation

dimail is called twice when creating a mailbox (once for the token,
and once for the post on mailbox endpoint). we want to clarify
the status_codes and messages of each error to inform user and ease debug
This commit is contained in:
Marie PUPO JEAMMET
2024-09-03 18:29:28 +02:00
committed by Marie
parent ce15e8a3ed
commit ba631fafb9
4 changed files with 152 additions and 24 deletions

View File

@@ -168,17 +168,10 @@ def test_models_mailboxes__wrong_secret():
status=status.HTTP_403_FORBIDDEN,
content_type="application/json",
)
rsps.add(
rsps.POST,
re.compile(rf".*/domains/{domain.name}/mailboxes/"),
body='{"detail": "Permission denied"}',
status=status.HTTP_403_FORBIDDEN,
content_type="application/json",
)
with pytest.raises(
exceptions.PermissionDenied,
match=f"Please check secret of the mail domain {domain.name}",
match=f"Token denied - Wrong secret on mail domain {domain.name}",
):
mailbox = factories.MailboxFactory(use_mock=False, domain=domain)
# Payload sent to mailbox provider