diff --git a/.github/workflows/tests-all.yml b/.github/workflows/tests-all.yml index 2b08a32..8ee76c5 100644 --- a/.github/workflows/tests-all.yml +++ b/.github/workflows/tests-all.yml @@ -6,7 +6,5 @@ jobs: steps: - uses: actions/checkout@v4 - run: sudo apt update - - run: sudo apt install pycodestyle pyflakes3 - - run: ./run_tests checks - - run: sudo apt install python3-mock - - run: ./run_tests unittests + - run: sudo apt install cmdtest figlet python3-flask-restful python3-pexpect python3-aiosmtpd + - run: ./run_tests stubs smtpd diff --git a/stubs/cmdtests/smtpd.script b/stubs/cmdtests/smtpd.script index 7eda1e5..2384dcf 100755 --- a/stubs/cmdtests/smtpd.script +++ b/stubs/cmdtests/smtpd.script @@ -33,7 +33,6 @@ import os import os.path -import sys import subprocess import time @@ -43,6 +42,9 @@ def main(): stubdir = os.path.join(srcdir, 'stubs') smtpddir = os.path.join(datadir, 'smtpddir') + port = 4433 + delay = 5 + os.chdir(datadir) os.mkdir(smtpddir) @@ -50,15 +52,25 @@ def main(): env = os.environ.copy() env['STUB_SMTPD_DATADIR'] = smtpddir - smtpd = subprocess.Popen([os.path.join(stubdir, 'smtpd'), '--port=4321'], + print('Starting smtpd on port %d' % (port)) + smtpd = subprocess.Popen([os.path.join(stubdir, 'smtpd'), '--port=%d' % (port)], env=env) - time.sleep(1) + (stdout, stderr) = smtpd.communicate() + print('smtpd.returncode:' % (smtpd.returncode)) + print(stdout) + print(stderr) + + print('Sleeping %ds' % (delay)) + time.sleep(delay) - subprocess.call([os.path.join(stubdir, 'smtpclient'), '--port=4321']) + print('Starting smtpclient on port %d' % (port)) + subprocess.call([os.path.join(stubdir, 'smtpclient'), '--port=%d' % (port)]) - time.sleep(1) + print('Sleeping %ds' % (delay)) + time.sleep(delay) + print('Killing smtpd') smtpd.kill() # print all the files to make sure there are no extra mails diff --git a/stubs/cmdtests/smtpd.stdout b/stubs/cmdtests/smtpd.stdout index d9cc387..25df4b0 100644 --- a/stubs/cmdtests/smtpd.stdout +++ b/stubs/cmdtests/smtpd.stdout @@ -1,3 +1,8 @@ +Starting smtpd on port 4433 +Sleeping 5s +Starting smtpclient on port 4433 +Sleeping 5s +Killing smtpd files: ['0'] test@example.com -> foo@example.com, bar@example.com Content-Type: text/plain; charset="us-ascii" diff --git a/stubs/smtpclient b/stubs/smtpclient index e1da9dc..b4dd833 100755 --- a/stubs/smtpclient +++ b/stubs/smtpclient @@ -47,7 +47,7 @@ def run(args): msg['From'] = from_address try: - server = smtplib.SMTP('localhost', args.port) + server = smtplib.SMTP('127.0.0.1', args.port) server.sendmail(from_address, to, msg.as_string()) server.quit() except Exception as e: