99from pathlib import Path
1010
1111import pytest
12- from chatmaild .config import read_config
12+ from chatmaild .config import read_config , format_deliverable_domain , is_valid_ipv4
13+
1314
1415conftestdir = Path (__file__ ).parent
1516
@@ -65,6 +66,11 @@ def maildomain(chatmail_config):
6566 return chatmail_config .mail_domain
6667
6768
69+ @pytest .fixture (scope = "session" )
70+ def maildomain_deliverable (maildomain ):
71+ return format_deliverable_domain (maildomain )
72+
73+
6874@pytest .fixture (scope = "session" )
6975def sshdomain (maildomain ):
7076 return os .environ .get ("CHATMAIL_SSH" , maildomain )
@@ -281,7 +287,7 @@ def gencreds(chatmail_config):
281287 next (count )
282288
283289 def gen (domain = None ):
284- domain = domain if domain else chatmail_config .mail_domain
290+ domain = domain if domain else chatmail_config .mail_domain_deliverable
285291 while 1 :
286292 num = next (count )
287293 alphanumeric = "abcdefghijklmnopqrstuvwxyz1234567890"
@@ -320,7 +326,8 @@ def __init__(self, rpc, maildomain, gencreds, chatmail_config):
320326
321327 def _make_transport (self , domain ):
322328 """Build a transport config dict for the given domain."""
323- addr , password = self .gencreds (domain )
329+ domain_deliverable = format_deliverable_domain (domain )
330+ addr , password = self .gencreds (domain_deliverable )
324331 transport = {
325332 "addr" : addr ,
326333 "password" : password ,
@@ -329,7 +336,7 @@ def _make_transport(self, domain):
329336 "imapServer" : domain ,
330337 "smtpServer" : domain ,
331338 }
332- if self . chatmail_config . tls_cert_mode == "self" :
339+ if domain . startswith ( "_" ) or is_valid_ipv4 ( domain ) :
333340 transport ["certificateChecks" ] = "acceptInvalidCertificates"
334341 return transport
335342
0 commit comments