mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 12:28:06 +00:00
merge accidental test files
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
import imaplib
|
import imaplib
|
||||||
|
import smtplib
|
||||||
|
|
||||||
|
|
||||||
class TestDovecot:
|
class TestDovecot:
|
||||||
@@ -7,6 +8,9 @@ class TestDovecot:
|
|||||||
user, password = gencreds()
|
user, password = gencreds()
|
||||||
imap.connect()
|
imap.connect()
|
||||||
imap.login(user, password)
|
imap.login(user, password)
|
||||||
|
# verify it works on another connection
|
||||||
|
imap.connect()
|
||||||
|
imap.login(user, password)
|
||||||
|
|
||||||
def test_login_fail(self, imap, gencreds):
|
def test_login_fail(self, imap, gencreds):
|
||||||
user, password = gencreds()
|
user, password = gencreds()
|
||||||
@@ -16,3 +20,37 @@ class TestDovecot:
|
|||||||
with pytest.raises(imaplib.IMAP4.error) as excinfo:
|
with pytest.raises(imaplib.IMAP4.error) as excinfo:
|
||||||
imap.login(user, password + "wrong")
|
imap.login(user, password + "wrong")
|
||||||
assert "AUTHENTICATIONFAILED" in str(excinfo)
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
class TestMailSending:
|
||||||
|
def test_one_on_one(self, smtp, imap, gencreds):
|
||||||
|
user1, pass1 = gencreds()
|
||||||
|
user2, pass2 = gencreds()
|
||||||
|
smtp.connect()
|
||||||
|
smtp.login(user1, pass1)
|
||||||
|
imap.connect()
|
||||||
|
imap.login(user2, pass2)
|
||||||
|
import pdb ; pdb.set_trace()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
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)
|
|
||||||
Reference in New Issue
Block a user