another test

This commit is contained in:
holger krekel
2023-10-12 17:55:46 +02:00
parent 77d800b13f
commit 067252703f

View File

@@ -48,7 +48,7 @@ function auth_userdb_lookup(request)
return dovecot.auth.USERDB_RESULT_USER_UNKNOWN, "no such user" return dovecot.auth.USERDB_RESULT_USER_UNKNOWN, "no such user"
end end
function split_chatctl_results(output) function split_chatctl(output)
local ret = {} local ret = {}
for key, value in output:gmatch "(%w+)%s*=%s*(%w+)" do for key, value in output:gmatch "(%w+)%s*=%s*(%w+)" do
ret[key] = value ret[key] = value
@@ -56,18 +56,29 @@ function split_chatctl_results(output)
return ret return ret
end end
function test_ok(user, password) -- Tests for testing the lua<->python interaction
function test_verify_ok(user, password)
local res = auth_password_verify({user=user}, password) local res = auth_password_verify({user=user}, password)
assert(res=="OK") assert(res=="OK")
print("OK test_ok "..user.." "..password) print("OK test_verify_ok "..user.." "..password)
end end
function test_mismatch(user, password) function test_verify_mismatch(user, password)
local res = auth_password_verify({user=user}, password) local res = auth_password_verify({user=user}, password)
assert(res == "MISMATCH") assert(res == "MISMATCH")
print("OK test_mismatch "..user.." "..password) print("OK test_verify_mismatch "..user.." "..password)
end end
test_ok("link2xt@instant2.testrun.org", "Ahyei6ie") function test_split_chatctl()
test_mismatch("link2xt@instant2.testrun.org", "Aqwlek") local res = split_chatctl("a=3 b=4\nc=5")
assert(res["a"] == "3")
assert(res["b"] == "4")
assert(res["c"] == "5")
print("OK test_split_chatctl")
end
test_split_chatctl()
test_verify_ok("link2xt@instant2.testrun.org", "Ahyei6ie")
test_verify_mismatch("link2xt@instant2.testrun.org", "Aqwlek")