mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 20:38:05 +00:00
more precise test, streamline wording (accounts -> address)
This commit is contained in:
@@ -124,7 +124,7 @@ def lookup_passdb(db, config: Config, user, cleartext_password, last_login=None)
|
|||||||
q = """INSERT INTO users (addr, password, last_login)
|
q = """INSERT INTO users (addr, password, last_login)
|
||||||
VALUES (?, ?, ?)"""
|
VALUES (?, ?, ?)"""
|
||||||
conn.execute(q, (user, encrypted_password, last_login))
|
conn.execute(q, (user, encrypted_password, last_login))
|
||||||
print(f"Created account {user}", file=sys.stderr)
|
print(f"Created e-mail address: {user}", file=sys.stderr)
|
||||||
return dict(
|
return dict(
|
||||||
home=f"/home/vmail/mail/{config.mail_domain}/{user}",
|
home=f"/home/vmail/mail/{config.mail_domain}/{user}",
|
||||||
uid="vmail",
|
uid="vmail",
|
||||||
|
|||||||
@@ -15,8 +15,13 @@ def test_remove_stale_users(db, example_config):
|
|||||||
md.joinpath("cur").mkdir()
|
md.joinpath("cur").mkdir()
|
||||||
md.joinpath("cur", "something").mkdir()
|
md.joinpath("cur", "something").mkdir()
|
||||||
|
|
||||||
|
to_remove = []
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
create_user(f"oldold{i:03}@chat.example.org", last_login=old)
|
addr = f"oldold{i:03}@chat.example.org"
|
||||||
|
create_user(addr, last_login=old)
|
||||||
|
with db.read_connection() as conn:
|
||||||
|
assert conn.get_user(addr)
|
||||||
|
to_remove.append(addr)
|
||||||
|
|
||||||
remain = []
|
remain = []
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
@@ -30,5 +35,11 @@ def test_remove_stale_users(db, example_config):
|
|||||||
for p in udir.parent.iterdir():
|
for p in udir.parent.iterdir():
|
||||||
assert not p.name.startswith("old")
|
assert not p.name.startswith("old")
|
||||||
|
|
||||||
|
for addr in to_remove:
|
||||||
|
with db.read_connection() as conn:
|
||||||
|
assert not conn.get_user(addr)
|
||||||
|
|
||||||
for addr in remain:
|
for addr in remain:
|
||||||
assert example_config.get_user_maildir(addr).exists()
|
assert example_config.get_user_maildir(addr).exists()
|
||||||
|
with db.read_connection() as conn:
|
||||||
|
assert conn.get_user(addr)
|
||||||
|
|||||||
Reference in New Issue
Block a user