mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
@@ -53,6 +53,12 @@ class DomainAPITestCase(ModoAPITestCase):
|
||||
self.assertEqual(response.status_code, 400)
|
||||
self.assertIn("name", response.data)
|
||||
|
||||
response = self.client.post(
|
||||
url, {"name": "test5.com", "quota": 1, "default_mailbox_quota": 10}
|
||||
)
|
||||
self.assertEqual(response.status_code, 400)
|
||||
self.assertIn("default_mailbox_quota", response.data)
|
||||
|
||||
self.client.credentials(
|
||||
HTTP_AUTHORIZATION='Token ' + self.da_token.key)
|
||||
response = self.client.post(
|
||||
|
||||
@@ -126,6 +126,33 @@ class DomainTestCase(ModoTestCase):
|
||||
self.assertTrue(
|
||||
self.client.login(username="toto@pouet.com", password=password))
|
||||
|
||||
def test_quota_constraints(self):
|
||||
"""Check quota constraints."""
|
||||
values = {
|
||||
"name": "pouet.com", "quota": 10, "default_mailbox_quota": 100,
|
||||
"create_dom_admin": True, "dom_admin_username": "toto",
|
||||
"create_aliases": True, "type": "domain", "stepid": 'step3'
|
||||
}
|
||||
response = self.ajax_post(
|
||||
reverse("admin:domain_add"),
|
||||
values, status=400
|
||||
)
|
||||
self.assertEqual(
|
||||
response["form_errors"]["default_mailbox_quota"][0],
|
||||
"Cannot be greater than domain quota")
|
||||
|
||||
dom = Domain.objects.get(name="test.com")
|
||||
values["name"] = dom.name
|
||||
values["quota"] = 10
|
||||
values["default_mailbox_quota"] = 100
|
||||
response = self.ajax_post(
|
||||
reverse("admin:domain_change", args=[dom.pk]),
|
||||
values, status=400
|
||||
)
|
||||
self.assertEqual(
|
||||
response["form_errors"]["default_mailbox_quota"][0],
|
||||
"Cannot be greater than domain quota")
|
||||
|
||||
def test_create_using_default_quota(self):
|
||||
"""Check that default value is used for creation."""
|
||||
self.set_global_parameter("default_domain_quota", 500)
|
||||
@@ -157,8 +184,7 @@ class DomainTestCase(ModoTestCase):
|
||||
dom.alias_set.filter(address="postmaster@pouet.com").exists())
|
||||
|
||||
def test_delete(self):
|
||||
"""Test the removal of a domain
|
||||
"""
|
||||
"""Test the removal of a domain."""
|
||||
dom = Domain.objects.get(name="test.com")
|
||||
self.ajax_post(
|
||||
reverse("admin:domain_delete", args=[dom.id]),
|
||||
|
||||
@@ -64,6 +64,12 @@ domainalias; domalias1.com; domain1.com; True
|
||||
name="domains.csv")
|
||||
response = self.client.post(url, {"sourcefile": f})
|
||||
self.assertContains(response, "Invalid default mailbox quota")
|
||||
f = ContentFile("domain; domain1.com; 10; 100; True",
|
||||
name="domains.csv")
|
||||
response = self.client.post(url, {"sourcefile": f})
|
||||
self.assertContains(
|
||||
response,
|
||||
"Default mailbox quota cannot be greater than domain quota")
|
||||
|
||||
def test_import_domains_with_conflict(self):
|
||||
f = ContentFile(b"""domain;test.alias;100;10;True
|
||||
|
||||
Reference in New Issue
Block a user