--- /dev/null
+#
+# Test the "lua" module
+#
+
+LUA_PATH := $(top_builddir)/src/tests/modules/lua/
+export LUA_PATH
+
+# MODULE.test is the main target for this module.
+lua.test:
--- /dev/null
+#
+# Input packet
+#
+User-Name = "caipirinha"
+User-Password = "gelo"
+Called-Station-Id = "aa:bb:cc:dd:ee:ff"
+Framed-IPv6-Prefix = "11:22:33:44:55:66:77:88/128"
+
+#
+# Expected answer
+#
+Response-Packet-Type == Access-Accept
--- /dev/null
+# fr.*
+lmod1_check_fr_istable
+if (!ok) {
+ test_fail
+} else {
+ test_pass
+}
+
+lmod2_check_fr_values
+if (!ok) {
+ test_fail
+} else {
+ test_pass
+}
+
+lmod3_check_request_value
+if (!ok) {
+ test_fail
+} else {
+ test_pass
+}
+
+lmod4_request_check_user
+if (!ok) {
+ test_fail
+} else {
+ test_pass
+}
+
+lmod5_check_if_return_is_string_ok
+if (!ok) {
+ test_fail
+} else {
+ test_pass
+}
+
+lmod6_check_if_return_is_const_ok
+if (!ok) {
+ test_fail
+} else {
+ test_pass
+}
+
+lmod7_check_fr_overwrite
+if (!noop) {
+ test_fail
+} else {
+ test_pass
+}
--- /dev/null
+function authorize()
+ if not type(fr) == "table" then
+ print("error: the 'fr' should be a table")
+ return fr.fail
+ end
+
+ return fr.ok
+end
--- /dev/null
+function authorize()
+ for k, v in pairs(fr) do
+ -- print("debug: table fr = { k: "..k.. "=("..type(k).."), v: "..v.."=("..type(v)..") }")
+
+ if not type(k) == "string" then
+ print("error: the k should be a string")
+ return fr.fail
+ end
+
+ if not type(v) == "number" then
+ print("error: the v should be a number")
+ return fr.fail
+ end
+ end
+
+ return fr.ok
+end
--- /dev/null
+function authorize()
+ for k, v in request.pairs() do
+ if k == "Framed-IPv6-Prefix" and v == "11:22:33:44:55:66:77:88/128" then
+ return fr.ok
+ end
+ end
+ return fr.fail
+end
--- /dev/null
+function authorize()
+ for k, v in request.pairs() do
+ if k == "User-Name" and v == "caipirinha" then
+ return fr.ok
+ end
+ end
+ return fr.fail
+end
--- /dev/null
+function authorize()
+ return fr.ok
+end
--- /dev/null
+function authorize()
+ return "ok"
+end
--- /dev/null
+function authorize()
+ print("mod7: trying to overwrite fr.noop with 12345 (current value "..fr.noop..")")
+ fr.noop = 12345
+ print("mod7: Checking the fr.noop value: "..fr.noop)
+ return fr.noop
+end
--- /dev/null
+ lua lmod1_check_fr_istable {
+ filename = "src/tests/modules/lua/mod1.lua"
+ func_authorize = authorize
+}
+
+lua lmod2_check_fr_values {
+ filename = "src/tests/modules/lua/mod2.lua"
+ func_authorize = authorize
+}
+
+lua lmod3_check_request_value {
+ filename = "src/tests/modules/lua/mod3.lua"
+ func_authorize = authorize
+}
+
+lua lmod4_request_check_user {
+ filename = "src/tests/modules/lua/mod4.lua"
+ func_authorize = authorize
+}
+
+lua lmod5_check_if_return_is_string_ok {
+ filename = "src/tests/modules/lua/mod5.lua"
+ func_authorize = authorize
+}
+
+lua lmod6_check_if_return_is_const_ok {
+ filename = "src/tests/modules/lua/mod6.lua"
+ func_authorize = authorize
+}
+
+lua lmod7_check_fr_overwrite {
+ filename = "src/tests/modules/lua/mod7.lua"
+ func_authorize = authorize
+}
+
+