mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 12:28:06 +00:00
python tests work
This commit is contained in:
@@ -15,4 +15,4 @@ def main():
|
|||||||
deploy_chatmail(mail_domain, mail_server, dkim_selector)
|
deploy_chatmail(mail_domain, mail_server, dkim_selector)
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ end
|
|||||||
-- call out to python program to actually manage authentication for dovecot
|
-- call out to python program to actually manage authentication for dovecot
|
||||||
|
|
||||||
function chatctl_verify(user, password)
|
function chatctl_verify(user, password)
|
||||||
local handle = io.popen("python3 /home/vmail/chatctl hexauth "..escape(user).." "..escape(password))
|
local cmd = "python3 /home/vmail/chatctl hexauth "..escape(user).." "..escape(password)
|
||||||
|
print("executing: "..cmd)
|
||||||
|
local handle = io.popen(cmd)
|
||||||
local result = handle:read("*a")
|
local result = handle:read("*a")
|
||||||
handle:close()
|
handle:close()
|
||||||
return split_chatctl(result)
|
return split_chatctl(result)
|
||||||
|
|||||||
@@ -4,20 +4,17 @@ import sys
|
|||||||
|
|
||||||
|
|
||||||
def get_user_data(user):
|
def get_user_data(user):
|
||||||
if user == b"link2xt@c1.testrun.org":
|
if user == "link2xt@c1.testrun.org":
|
||||||
return dict(
|
return dict(
|
||||||
uid="vmail",
|
uid="vmail",
|
||||||
gid="vmail",
|
gid="vmail",
|
||||||
password=b"Ahyei6ie",
|
password="Ahyei6ie",
|
||||||
)
|
)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
def create_user(user, password):
|
def create_user(user, password):
|
||||||
assert isinstance(password, bytes)
|
return dict(home=f"/home/vmail/{user}", uid="vmail", gid="vmail", password=password)
|
||||||
return dict(
|
|
||||||
home=f"/home/vmail/{user}", uid="vmail", gid="vmail", password=password
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def verify_user(user, password):
|
def verify_user(user, password):
|
||||||
@@ -50,11 +47,11 @@ def dump_result(res):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if sys.argv[1] == "hexauth":
|
if sys.argv[1] == "hexauth":
|
||||||
login = base64.b16decode(sys.argv[2])
|
login = base64.b16decode(sys.argv[2]).decode()
|
||||||
password = base64.b16decode(sys.argv[3])
|
password = base64.b16decode(sys.argv[3]).decode()
|
||||||
res = verify_user(login, password)
|
res = verify_user(login, password)
|
||||||
dump_result(res)
|
dump_result(res)
|
||||||
elif sys.argv[1] == "hexlookup":
|
elif sys.argv[1] == "hexlookup":
|
||||||
login = base64.b16decode(sys.argv[2])
|
login = base64.b16decode(sys.argv[2]).decode()
|
||||||
res = lookup_user(login)
|
res = lookup_user(login)
|
||||||
dump_result(res)
|
dump_result(res)
|
||||||
|
|||||||
@@ -67,10 +67,12 @@ function test_split_chatctl()
|
|||||||
end
|
end
|
||||||
|
|
||||||
test_split_chatctl()
|
test_split_chatctl()
|
||||||
test_password_verify_ok("link2xt@instant2.testrun.org", "Ahyei6ie")
|
test_password_verify_ok("link2xt@c1.testrun.org", "Ahyei6ie")
|
||||||
test_password_verify_mismatch("link2xt@instant2.testrun.org", "Aqwlek")
|
test_password_verify_mismatch("link2xt@c1.testrun.org", "Aqwlek")
|
||||||
test_userdb_lookup_ok("link2xt@instant2.testrun.org")
|
test_userdb_lookup_ok("link2xt@c1.testrun.org")
|
||||||
test_userdb_lookup_mismatch("wlekqjlew@xyz.org")
|
test_userdb_lookup_mismatch("wlekqjlew@xyz.org")
|
||||||
test_passdb_lookup_ok("link2xt@instant2.testrun.org")
|
|
||||||
test_passdb_lookup_mismatch("llqkwjelqwe@xyz.org")
|
-- probably not needed by dovecot?
|
||||||
|
-- test_passdb_lookup_ok("link2xt@c1.testrun.org")
|
||||||
|
-- test_passdb_lookup_mismatch("llqkwjelqwe@xyz.org")
|
||||||
|
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ from doveauth import get_user_data, verify_user
|
|||||||
|
|
||||||
|
|
||||||
def test_basic():
|
def test_basic():
|
||||||
data = get_user_data(b"link2xt@instant2.testrun.org")
|
data = get_user_data("link2xt@c1.testrun.org")
|
||||||
assert data
|
assert data
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail(reason="no persistence yet")
|
@pytest.mark.xfail(reason="no persistence yet")
|
||||||
def test_verify_or_create():
|
def test_verify_or_create():
|
||||||
res = verify_user(b"newuser1@something.org", b"kajdlkajsldk12l3kj1983")
|
res = verify_user("newuser1@something.org", "kajdlkajsldk12l3kj1983")
|
||||||
assert res["status"] == "ok"
|
assert res["status"] == "ok"
|
||||||
res = verify_user(b"newuser1@something.org", b"kajdlqweqwe")
|
res = verify_user("newuser1@something.org", "kajdlqweqwe")
|
||||||
assert res["status"] == "fail"
|
assert res["status"] == "fail"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user