From 9ad7cea5159abda579fb351da7348d09b39dce0c Mon Sep 17 00:00:00 2001 From: Dimitri Huisman Date: Wed, 31 May 2023 09:17:59 +0000 Subject: [PATCH] Update 05_connectivity test to use UTF8 password. --- tests/compose/core/00_create_users.sh | 1 + tests/compose/core/05_connectivity.py | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/compose/core/00_create_users.sh b/tests/compose/core/00_create_users.sh index 26461966..142c3cb3 100755 --- a/tests/compose/core/00_create_users.sh +++ b/tests/compose/core/00_create_users.sh @@ -8,4 +8,5 @@ docker compose -f tests/compose/core/docker-compose.yml exec -T admin flask mail docker compose -f tests/compose/core/docker-compose.yml exec -T admin flask mailu admin admin mailu.io 'password' --mode=update || exit 1 docker compose -f tests/compose/core/docker-compose.yml exec -T admin flask mailu user user mailu.io 'password' || exit 1 docker compose -f tests/compose/core/docker-compose.yml exec -T admin flask mailu user 'user/with/slash' mailu.io 'password' || exit 1 +docker compose -f tests/compose/core/docker-compose.yml exec -T admin flask mailu user 'user_UTF8' mailu.io 'password€' || exit 1 echo "User testing successful!" diff --git a/tests/compose/core/05_connectivity.py b/tests/compose/core/05_connectivity.py index cee02cf6..5cc12069 100755 --- a/tests/compose/core/05_connectivity.py +++ b/tests/compose/core/05_connectivity.py @@ -7,25 +7,31 @@ import sys import managesieve SERVER='localhost' -USERNAME='user@mailu.io' -PASSWORD='password' +USERNAME='user_UTF8@mailu.io' +PASSWORD='password€' +#https://github.com/python/cpython/issues/73936 +#SMTPlib does not support UTF8 passwords. +USERNAME_ASCII='user@mailu.io' +PASSWORD_ASCII='password' + def test_imap(server, username, password): + auth = lambda data : f'\x00{username}\x00{password}' print(f'Authenticating to imaps://{username}:{password}@{server}:993/') with imaplib.IMAP4_SSL(server) as conn: - conn.login(username, password) + conn.authenticate('PLAIN', auth) conn.noop() print('OK') print(f'Authenticating to imaps://{username}:{password}@{server}:143/') with imaplib.IMAP4(server) as conn: conn.starttls() - conn.login(username, password) + conn.authenticate('PLAIN', auth) conn.noop() print('OK') print(f'Authenticating to imap://{username}:{password}@{server}:143/') try: with imaplib.IMAP4(server) as conn: - conn.login(username, password) + conn.authenticate('PLAIN', auth) print(f'Authenticating to imap://{username}:{password}@{server}:143/ worked without STARTTLS!') sys.exit(102) except imaplib.IMAP4.error: @@ -121,7 +127,7 @@ def test_managesieve(server, username, password): if m.login('', username, password) != 'OK': print(f'Authenticating to sieve://{username}:{password}@{server}:4190/ has failed!') sys.exit(109) - + if m.listscripts()[0] != 'OK': print(f'Listing scripts failed!') sys.exit(110) @@ -130,5 +136,7 @@ def test_managesieve(server, username, password): if __name__ == '__main__': test_imap(SERVER, USERNAME, PASSWORD) test_pop3(SERVER, USERNAME, PASSWORD) - test_SMTP(SERVER, USERNAME, PASSWORD) + test_SMTP(SERVER, USERNAME_ASCII, PASSWORD_ASCII) test_managesieve(SERVER, USERNAME, PASSWORD) +#https://github.com/python/cpython/issues/73936 +#SMTPlib does not support UTF8 passwords. \ No newline at end of file