From 8ae289ad3124eec82ee5ad5687ed7df14141acf6 Mon Sep 17 00:00:00 2001 From: Spitap Date: Mon, 5 Sep 2022 13:52:36 +0200 Subject: [PATCH] fixed mistake, updated test with real response possibility --- modoboa/admin/management/commands/subcommands/_mx.py | 2 +- modoboa/admin/tests/test_mx.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modoboa/admin/management/commands/subcommands/_mx.py b/modoboa/admin/management/commands/subcommands/_mx.py index 853ac2558..d1ea6abee 100644 --- a/modoboa/admin/management/commands/subcommands/_mx.py +++ b/modoboa/admin/management/commands/subcommands/_mx.py @@ -81,7 +81,7 @@ class CheckMXRecords(BaseCommand): result = socket.gethostbyname(pattern) #result from dnsbl is in ipv4 format splited_result = result.split(".") - if int(splited_result[-1]) <= 15: + if int(splited_result[-1]) > 15: #Typical dnsbl result : 127.0.0.[1-15] (depends on services) result = False except socket.gaierror: diff --git a/modoboa/admin/tests/test_mx.py b/modoboa/admin/tests/test_mx.py index 9d0a80164..a8d7bdf88 100644 --- a/modoboa/admin/tests/test_mx.py +++ b/modoboa/admin/tests/test_mx.py @@ -217,7 +217,7 @@ class DNSBLTestCase(ModoTestCase): """Check notifications.""" mock_query.side_effect = utils.mock_dns_query_result mock_getaddrinfo.side_effect = utils.mock_ip_query_result - mock_g_gethostbyname.return_value = "1.2.3.4" + mock_g_gethostbyname.return_value = "127.0.0.4" management.call_command( "modo", "check_mx", "--email", "user@example.test") self.assertEqual(len(mail.outbox), 2)