(plugin) add CommuneCreation plugin

Add test for domain spec from Dimail
This commit is contained in:
Laurent Bossavit
2025-01-21 15:45:21 +01:00
committed by Laurent Bossavit
parent 34c9dc6cd7
commit 57fd15100e
2 changed files with 25 additions and 3 deletions

View File

@@ -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."""

View File

@@ -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}"
)