mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 04:18:09 +00:00
adding a lua test for chatctl.py
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
|
|
||||||
|
-- To run this test: run "lua test.lua" while in the same directory as chatctl.py
|
||||||
|
|
||||||
dovecot = {
|
dovecot = {
|
||||||
auth = {
|
auth = {
|
||||||
PASSDB_RESULT_OK="OK",
|
PASSDB_RESULT_OK="OK",
|
||||||
@@ -12,6 +14,8 @@ function escape(data)
|
|||||||
return ("'"..b16.."'")
|
return ("'"..b16.."'")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- call out to python program to actually manage authentication for dovecot
|
||||||
|
|
||||||
function chatctl_verify(user, password)
|
function chatctl_verify(user, password)
|
||||||
return os.execute("python chatctl.py hexauth "..escape(user).." "..escape(password))
|
return os.execute("python chatctl.py hexauth "..escape(user).." "..escape(password))
|
||||||
end
|
end
|
||||||
@@ -50,6 +54,17 @@ function split_chatctl_results(output)
|
|||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
local res = auth_password_verify({user="link2xt@instant2.testrun.org"}, "Ahyei6ie")
|
function test_ok(user, password)
|
||||||
print(res)
|
local res = auth_password_verify({user=user}, password)
|
||||||
|
assert(res=="OK")
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_mismatch(user, password)
|
||||||
|
local res = auth_password_verify({user=user}, password)
|
||||||
|
assert(res == "MISMATCH")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
test_ok("link2xt@instant2.testrun.org", "Ahyei6ie")
|
||||||
|
test_mismatch("link2xt@instant2.testrun.org", "Aqwlek")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user