✅(tests) update tests to look for dimail secret in settings
Update back-end tests to match 'secret' field being moved to settings.
This commit is contained in:
committed by
Marie
parent
ba30b1d3ee
commit
29904ef7b6
@@ -31,7 +31,6 @@ class MailDomainFactory(factory.django.DjangoModelFactory):
|
|||||||
|
|
||||||
name = factory.Faker("domain_name")
|
name = factory.Faker("domain_name")
|
||||||
slug = factory.LazyAttribute(lambda o: slugify(o.name))
|
slug = factory.LazyAttribute(lambda o: slugify(o.name))
|
||||||
secret = factory.Faker("password")
|
|
||||||
|
|
||||||
@factory.post_generation
|
@factory.post_generation
|
||||||
def users(self, create, extracted, **kwargs):
|
def users(self, create, extracted, **kwargs):
|
||||||
|
|||||||
@@ -438,7 +438,7 @@ def test_api_mailboxes__secret_unrelated_to_domain():
|
|||||||
|
|
||||||
assert response.status_code == status.HTTP_403_FORBIDDEN
|
assert response.status_code == status.HTTP_403_FORBIDDEN
|
||||||
assert response.json() == {
|
assert response.json() == {
|
||||||
"detail": f"Secret not valid for this domain {access.domain.name}"
|
"detail": "Permission denied. Please check your MAIL_PROVISIONING_API_CREDENTIALS."
|
||||||
}
|
}
|
||||||
assert not models.Mailbox.objects.exists()
|
assert not models.Mailbox.objects.exists()
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from logging import Logger
|
|||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from django.core import exceptions
|
from django.core import exceptions
|
||||||
|
from django.test.utils import override_settings
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import responses
|
import responses
|
||||||
@@ -143,13 +144,17 @@ def test_models_mailboxes__cannot_be_created_for_pending_maildomain():
|
|||||||
### SYNC TO DIMAIL-API
|
### SYNC TO DIMAIL-API
|
||||||
|
|
||||||
|
|
||||||
|
@override_settings(MAIL_PROVISIONING_API_CREDENTIALS=None)
|
||||||
def test_models_mailboxes__no_secret():
|
def test_models_mailboxes__no_secret():
|
||||||
"""If no secret is declared on the domain, the function should raise an error."""
|
"""
|
||||||
domain = factories.MailDomainEnabledFactory(secret=None)
|
If MAIL_PROVISIONING_API_CREDENTIALS setting is not configured,
|
||||||
|
trying to create a mailbox should raise an error.
|
||||||
|
"""
|
||||||
|
domain = factories.MailDomainEnabledFactory()
|
||||||
|
|
||||||
with pytest.raises(
|
with pytest.raises(
|
||||||
exceptions.ValidationError,
|
exceptions.ValidationError,
|
||||||
match="Please configure your domain's secret before creating any mailbox.",
|
match="Please configure MAIL_PROVISIONING_API_CREDENTIALS before creating any mailbox.",
|
||||||
):
|
):
|
||||||
factories.MailboxFactory(domain=domain)
|
factories.MailboxFactory(domain=domain)
|
||||||
|
|
||||||
|
|||||||
@@ -581,7 +581,7 @@ class Test(Base):
|
|||||||
CELERY_TASK_ALWAYS_EAGER = values.BooleanValue(True)
|
CELERY_TASK_ALWAYS_EAGER = values.BooleanValue(True)
|
||||||
|
|
||||||
# this is a dev credentials for mail provisioning API
|
# this is a dev credentials for mail provisioning API
|
||||||
MAIL_PROVISIONING_API_CREDENTIALS = "bGFfcmVnaWU6cGFzc3dvcmQ"
|
MAIL_PROVISIONING_API_CREDENTIALS = "bGFfcmVnaWU6cGFzc3dvcmQ="
|
||||||
|
|
||||||
|
|
||||||
class ContinuousIntegration(Test):
|
class ContinuousIntegration(Test):
|
||||||
|
|||||||
Reference in New Issue
Block a user