diff --git a/src/backend/plugins/organizations.py b/src/backend/plugins/organizations.py index 634b5b5..c8ca8a2 100644 --- a/src/backend/plugins/organizations.py +++ b/src/backend/plugins/organizations.py @@ -139,14 +139,21 @@ class CommuneCreation(BaseOrganizationPlugin): create_domain.params = { "name": inputs["name"], "delivery": "virtual", - "features": ["webmail"], + "features": ["webmail","mailbox"], "context_name": inputs["name"], } create_domain.headers = { "Authorization": f"Basic: {settings.MAIL_PROVISIONING_API_CREDENTIALS}" } - return [create_zone, create_domain] + spec_domain = ApiCall() + spec_domain.base = settings.MAIL_PROVISIONING_API_URL + spec_domain.url = f"/domains/{inputs["name"]}.collectivite.fr/spec" + spec_domain.headers = { + "Authorization": f"Basic: {settings.MAIL_PROVISIONING_API_CREDENTIALS}" + } + + return [create_zone, create_domain, spec_domain] def run_after_create(self, organization): """After creating an organization, update the organization name.""" diff --git a/src/backend/plugins/tests/organizations/test_commune_creation.py b/src/backend/plugins/tests/organizations/test_commune_creation.py index e0fd65f..8662043 100644 --- a/src/backend/plugins/tests/organizations/test_commune_creation.py +++ b/src/backend/plugins/tests/organizations/test_commune_creation.py @@ -90,10 +90,25 @@ def test_tasks_on_commune_creation_include_dimail_domain_creation(): assert tasks[1].params == { "name": "merlaut", "delivery": "virtual", - "features": ["webmail"], + "features": ["webmail", "mailbox"], "context_name": "merlaut", } assert ( tasks[1].headers["Authorization"] == f"Basic: {settings.MAIL_PROVISIONING_API_CREDENTIALS}" ) + +def test_tasks_on_commune_creation_include_fetching_spec(): + """Test the third task in commune creation: asking Dimail for the spec""" + plugin = CommuneCreation() + name = "Loc-Eguiner" + + tasks = plugin.complete_commune_creation(name) + + assert tasks[2].base == settings.MAIL_PROVISIONING_API_URL + assert tasks[2].url == "/domains/loc-eguiner.collectivite.fr/spec" + assert tasks[2].method == "GET" + assert ( + tasks[2].headers["Authorization"] + == f"Basic: {settings.MAIL_PROVISIONING_API_CREDENTIALS}" + )