mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
No tests for reserved domains.
fix #995 Conflicts: modoboa/admin/models/domain.py
This commit is contained in:
@@ -80,3 +80,12 @@ DNSBL_PROVIDERS = [
|
||||
"zen.spamhaus.org",
|
||||
"zombie.dnsbl.sorbs.net",
|
||||
]
|
||||
|
||||
# Do not run tests for these domains.
|
||||
# https://en.wikipedia.org/wiki/Top-level_domain#Reserved_domains
|
||||
RESERVED_TLD = [
|
||||
"example",
|
||||
"invalid",
|
||||
"localhost",
|
||||
"test"
|
||||
]
|
||||
|
||||
@@ -257,4 +257,6 @@ class CheckMXRecords(BaseCommand):
|
||||
options.pop("domain")
|
||||
|
||||
for domain in domains:
|
||||
if domain.uses_a_reserved_tld:
|
||||
continue
|
||||
self.check_domain(domain, **options)
|
||||
|
||||
@@ -20,6 +20,7 @@ from modoboa.parameters import tools as param_tools
|
||||
|
||||
from .. import signals
|
||||
from .base import AdminObject
|
||||
from .. import constants
|
||||
|
||||
|
||||
class DomainManager(Manager):
|
||||
@@ -108,6 +109,12 @@ class Domain(AdminObject):
|
||||
def aliases(self):
|
||||
return self.domainalias_set
|
||||
|
||||
@property
|
||||
def uses_a_reserved_tld(self):
|
||||
"""Does this domain use a reserved TLD."""
|
||||
tld = self.name.split(".", 1)[-1]
|
||||
return tld in constants.RESERVED_TLD
|
||||
|
||||
@property
|
||||
def just_created(self):
|
||||
"""Return true if the domain was created in the latest 24h."""
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
{% if enable_mx_checks or enable_dnsbl_checks %}
|
||||
<td name="dns">
|
||||
<small>
|
||||
{% if domain.awaiting_checks %}
|
||||
{% if domain.uses_a_reserved_tld %}
|
||||
<span class="label label-mini label-info">{% trans "Disabled" context "checks" %}</span>
|
||||
{% elif domain.awaiting_checks %}
|
||||
<span class="label label-mini label-info">{% trans "Awaiting checks" %}</span>
|
||||
{% else %}
|
||||
{% if enable_mx_checks %}
|
||||
|
||||
@@ -72,6 +72,8 @@ class DNSBLTestCase(ModoTestCase):
|
||||
super(DNSBLTestCase, cls).setUpTestData()
|
||||
cls.domain = factories.DomainFactory(name="modoboa.org")
|
||||
factories.DomainFactory(name="pouet.com") # should not exist
|
||||
cls.domain2 = factories.DomainFactory(
|
||||
name="test.localhost") # Should not be checked
|
||||
models.DNSBLResult.objects.all().delete()
|
||||
|
||||
@override_settings(DNSBL_PROVIDERS=["zen.spamhaus.org"])
|
||||
@@ -84,6 +86,8 @@ class DNSBLTestCase(ModoTestCase):
|
||||
response = self.client.get(
|
||||
reverse("admin:dnsbl_domain_detail", args=[self.domain.pk]))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertFalse(self.domain.uses_a_reserved_tld)
|
||||
self.assertTrue(self.domain2.uses_a_reserved_tld)
|
||||
|
||||
@override_settings(DNSBL_PROVIDERS=["zen.spamhaus.org"])
|
||||
def test_management_command_no_dnsbl(self):
|
||||
|
||||
Reference in New Issue
Block a user