99import random
1010import subprocess
1111import sys
12+ import urllib .parse
1213from typing import AsyncGenerator , Optional
1314
1415import pytest
@@ -282,8 +283,15 @@ def factory(core_version):
282283 channel = gw .remote_exec (remote_bob_loop )
283284 cm = os .environ .get ("CHATMAIL_DOMAIN" )
284285
286+ # old cores need "ic=3" to accept
287+ # the self-signed cert of an underscore domain
288+ addr , password = acfactory .get_credentials ()
289+ dclogin_qr = f"dclogin://{ urllib .parse .quote (addr , safe = '@' )} ?p={ urllib .parse .quote (password )} &v=1"
290+ if cm and cm .startswith ("_" ):
291+ dclogin_qr += "&ic=3"
292+
285293 # trigger getting an online account on bob's side
286- channel .send ((accounts_dir , str (rpc_server_path ), cm ))
294+ channel .send ((accounts_dir , str (rpc_server_path ), dclogin_qr ))
287295
288296 # meanwhile get a local alice account
289297 alice = acfactory .get_online_account ()
@@ -315,10 +323,8 @@ def remote_bob_loop(channel):
315323 import os
316324
317325 from deltachat_rpc_client import DeltaChat , Rpc
318- from deltachat_rpc_client .pytestplugin import ACFactory
319326
320- accounts_dir , rpc_server_path , chatmail_domain = channel .receive ()
321- os .environ ["CHATMAIL_DOMAIN" ] = chatmail_domain
327+ accounts_dir , rpc_server_path , dclogin_qr = channel .receive ()
322328
323329 # older core versions don't support specifying rpc_server_path
324330 # so we can't just pass `rpc_server_path` argument to Rpc constructor
@@ -329,8 +335,13 @@ def remote_bob_loop(channel):
329335 with rpc :
330336 dc = DeltaChat (rpc )
331337 channel .send (dc .rpc .get_system_info ()["deltachat_core_version" ])
332- acfactory = ACFactory (dc )
333- bob = acfactory .get_online_account ()
338+
339+ # ACFactory would configure from a "dcaccount" QR,
340+ # which old cores cannot use on underscore domains
341+ bob = dc .add_account ()
342+ bob .set_config_from_qr (dclogin_qr )
343+ bob .bring_online ()
344+
334345 alice_vcard = channel .receive ()
335346 [alice_contact ] = bob .import_vcard (alice_vcard )
336347 ns = {"bob" : bob , "bob_contact_alice" : alice_contact }
0 commit comments