add tests

This commit is contained in:
holger krekel
2023-10-14 12:07:46 +02:00
parent 207d7c7060
commit 0f2cb90e09
2 changed files with 45 additions and 1 deletions

View File

@@ -0,0 +1,44 @@
import pytest
import imaplib
import smtplib
class TestDovecot:
def test_login_ok(self, imap, gencreds):
user, password = gencreds()
imap.connect()
imap.login(user, password)
# verify it works on another connection
imap.connect()
imap.login(user, password)
def test_login_fail(self, imap, gencreds):
user, password = gencreds()
imap.connect()
imap.login(user, password)
imap.connect()
with pytest.raises(imaplib.IMAP4.error) as excinfo:
imap.login(user, password + "wrong")
assert "AUTHENTICATIONFAILED" in str(excinfo)
class TestPostfix:
def test_login_ok(self, smtp, gencreds):
user, password = gencreds()
smtp.connect()
smtp.login(user, password)
# verify it works on another connection
smtp.connect()
smtp.login(user, password)
def test_login_fail(self, smtp, gencreds):
user, password = gencreds()
smtp.connect()
smtp.login(user, password)
smtp.connect()
with pytest.raises(smtplib.SMTPAuthenticationError) as excinfo:
smtp.login(user, password + "wrong")
assert excinfo.value.smtp_code == 535
assert "authentication failed" in str(excinfo)

View File

@@ -3,4 +3,4 @@ pushd doveauth/src/doveauth
../../venv/bin/pytest
popd
online-tests/venv/bin/pytest online-tests/ -vrx
online-tests/venv/bin/pytest online-tests/ -vrx --durations=5