Skip to content

Commit f928bb6

Browse files
committed
moved hardcoded variables to config
1 parent d374e4c commit f928bb6

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

SAMPLE-config.py

+6
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,9 @@
7070

7171
# Tells software test what browser to use (chrome/firefox), default = chrome
7272
SOFTWARE_BROWSER = "chrome"
73+
74+
# Tells email test if it should do a operation email test (most consumer ISP don't allow this)
75+
EMAIL_NETWORK_SUPPORT_PORT25_TRAFFIC = False
76+
77+
# Tells email test if it should do a operation test (GitHub Actions doesn't support it)
78+
EMAIL_NETWORK_SUPPORT_IPV6_TRAFFIC = False

tests/email_validator.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
REVIEW_SHOW_IMPROVEMENTS_ONLY = get_config_or_default('review_show_improvements_only')
2121
REQUEST_TIMEOUT = get_config_or_default('http_request_timeout')
2222
USERAGENT = get_config_or_default('useragent')
23+
EMAIL_NETWORK_SUPPORT_PORT25_TRAFFIC = get_config_or_default('EMAIL_NETWORK_SUPPORT_PORT25_TRAFFIC')
24+
EMAIL_NETWORK_SUPPORT_IPV6_TRAFFIC = get_config_or_default('EMAIL_NETWORK_SUPPORT_IPV6_TRAFFIC')
2325

2426
checked_urls = {}
2527

2628
# We are doing this to support IPv6
27-
class SmtpWebperf(smtplib.SMTP):
28-
def __init__(self, host='', port=0, local_hostname=None,
29+
class SmtpWebperf(smtplib.SMTP): # pylint: disable=too-many-instance-attributes
30+
def __init__(self, host='', port=0, local_hostname=None, # pylint: disable=too-many-arguments
2931
timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
3032
source_address=None):
3133
"""Initialize a new instance.
@@ -357,13 +359,6 @@ def validate_email_domain(hostname, result_dict, global_translation, local_trans
357359
if hostname.startswith('www.'):
358360
hostname = hostname[4:]
359361

360-
# 0.0 - Preflight (Will probably resolve 98% of questions from people trying this test themself)
361-
# 0.1 - Check for allowed connection over port 25 (most consumer ISP don't allow this)
362-
support_port25 = False
363-
# 0.2 - Check for allowed IPv6 support
364-
# (GitHub Actions doesn't support it on network lever on the time of writing this)
365-
support_ipv6 = False
366-
367362
# 1 - Get Email servers
368363
# dns_lookup
369364
rating, ipv4_servers, ipv6_servers = validate_mx_records(
@@ -372,12 +367,14 @@ def validate_email_domain(hostname, result_dict, global_translation, local_trans
372367
# If we have -1.0 in rating, we have no MX records, ignore test.
373368
if rating.get_overall() != -1.0:
374369
# 1.2 - Check operational
375-
if support_port25 and len(ipv4_servers) > 0:
370+
if EMAIL_NETWORK_SUPPORT_PORT25_TRAFFIC and len(ipv4_servers) > 0:
376371
rating = validate_ip4_operation_status(
377372
global_translation, rating, local_translation, ipv4_servers)
378373

379374
# 1.2 - Check operational
380-
if support_port25 and support_ipv6 and len(ipv6_servers) > 0:
375+
if EMAIL_NETWORK_SUPPORT_PORT25_TRAFFIC and\
376+
EMAIL_NETWORK_SUPPORT_IPV6_TRAFFIC and\
377+
len(ipv6_servers) > 0:
381378
rating = validate_ip6_operation_status(
382379
global_translation, rating, local_translation, ipv6_servers)
383380

0 commit comments

Comments
 (0)