mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 04:18:09 +00:00
let mail connection setting come from CHATMAIL_DOMAIN env
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import imaplib
|
import imaplib
|
||||||
import smtplib
|
import smtplib
|
||||||
import itertools
|
import itertools
|
||||||
@@ -5,8 +6,13 @@ import pytest
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def imap():
|
def maildomain():
|
||||||
return ImapConn("c1.testrun.org")
|
return os.environ.get("CHATMAIL_DOMAIN", "c1.testrun.org")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def imap(maildomain):
|
||||||
|
return ImapConn(maildomain)
|
||||||
|
|
||||||
|
|
||||||
class ImapConn:
|
class ImapConn:
|
||||||
@@ -23,8 +29,8 @@ class ImapConn:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def smtp():
|
def smtp(maildomain):
|
||||||
return SmtpConn("c1.testrun.org")
|
return SmtpConn(maildomain)
|
||||||
|
|
||||||
|
|
||||||
class SmtpConn:
|
class SmtpConn:
|
||||||
@@ -41,12 +47,12 @@ class SmtpConn:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def gencreds():
|
def gencreds(maildomain):
|
||||||
count = itertools.count()
|
count = itertools.count()
|
||||||
|
|
||||||
def gen():
|
def gen():
|
||||||
while 1:
|
while 1:
|
||||||
num = next(count)
|
num = next(count)
|
||||||
yield f"user{num}", f"password{num}"
|
yield f"user{num}@{maildomain}", f"password{num}"
|
||||||
|
|
||||||
return lambda: next(gen())
|
return lambda: next(gen())
|
||||||
|
|||||||
@@ -40,5 +40,3 @@ class TestPostfix:
|
|||||||
smtp.login(user, password + "wrong")
|
smtp.login(user, password + "wrong")
|
||||||
assert excinfo.value.smtp_code == 535
|
assert excinfo.value.smtp_code == 535
|
||||||
assert "authentication failed" in str(excinfo)
|
assert "authentication failed" in str(excinfo)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user