From e918b3a5072ff94bc1bd3fb4072e6aa6a5b4c429 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Thu, 12 Oct 2023 17:16:57 +0200 Subject: [PATCH] adding a lua test for chatctl.py --- src/chatmail/chatctl/test.lua | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/chatmail/chatctl/test.lua b/src/chatmail/chatctl/test.lua index cf1a9df9..a1e1f051 100644 --- a/src/chatmail/chatctl/test.lua +++ b/src/chatmail/chatctl/test.lua @@ -1,4 +1,6 @@ +-- To run this test: run "lua test.lua" while in the same directory as chatctl.py + dovecot = { auth = { PASSDB_RESULT_OK="OK", @@ -12,6 +14,8 @@ function escape(data) return ("'"..b16.."'") end +-- call out to python program to actually manage authentication for dovecot + function chatctl_verify(user, password) return os.execute("python chatctl.py hexauth "..escape(user).." "..escape(password)) end @@ -50,6 +54,17 @@ function split_chatctl_results(output) return ret end -local res = auth_password_verify({user="link2xt@instant2.testrun.org"}, "Ahyei6ie") -print(res) +function test_ok(user, password) + 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")