diff options
-rwxr-xr-x | test.sh | 6 | ||||
-rw-r--r-- | test/mandatory/filter-limit.json | 301 | ||||
-rw-r--r-- | test/mandatory/filter-limit.lua | 36 |
3 files changed, 41 insertions, 302 deletions
@@ -8,10 +8,14 @@ cd "$(dirname "$0")" export LUA_PATH="./?.lua;;" +LUA=lua${LUA_VERSION} for cls in mandatory optional private; do eval "export AWALL_PATH_$(echo $cls | tr a-z A-Z)=test/$cls" mkdir -p test/$cls + for script in test/$cls/*.lua; do + [ -f "$script" ] && $LUA "$script" > "${script%.lua}.json" + done done -exec lua${LUA_VERSION} ./awall-cli ${1:-diff} -o test/output +exec $LUA ./awall-cli ${1:-diff} -o test/output diff --git a/test/mandatory/filter-limit.json b/test/mandatory/filter-limit.json deleted file mode 100644 index 3082dc1..0000000 --- a/test/mandatory/filter-limit.json +++ /dev/null @@ -1,301 +0,0 @@ -{ - "filter": [ - { "conn-limit": 1 }, - { "conn-limit": 1, "action": "pass" }, - { "conn-limit": 1, "log": true }, - { "conn-limit": 1, "log": true, "action": "pass" }, - { "conn-limit": 1, "log": "none" }, - { "conn-limit": 1, "log": "none", "action": "pass" }, - { "conn-limit": { "count": 1, "log": false } }, - { "conn-limit": { "count": 1, "log": false }, "action": "pass" }, - { "conn-limit": { "count": 1, "log": false }, "log": true }, - { - "conn-limit": { "count": 1, "log": false }, - "log": true, - "action": "pass" - }, - { "conn-limit": { "count": 1, "log": false }, "log": "none" }, - { - "conn-limit": { "count": 1, "log": false }, - "log": "none", - "action": "pass" - }, - { "conn-limit": { "count": 1, "log": "none" } }, - { "conn-limit": { "count": 1, "log": "none" }, "action": "pass" }, - { "conn-limit": { "count": 1, "log": "none" }, "log": true }, - { - "conn-limit": { "count": 1, "log": "none" }, - "log": true, - "action": "pass" - }, - { "conn-limit": { "count": 1, "log": "none" }, "log": "none" }, - { - "conn-limit": { "count": 1, "log": "none" }, - "log": "none", - "action": "pass" - }, - - { "conn-limit": 30 }, - { "conn-limit": 30, "action": "pass" }, - { "conn-limit": 30, "log": true }, - { "conn-limit": 30, "log": "none" }, - { "conn-limit": { "count": 30, "log": false } }, - { "conn-limit": { "count": 30, "log": false }, "action": "pass" }, - { "conn-limit": { "count": 30, "log": false }, "log": true }, - { "conn-limit": { "count": 30, "log": false }, "log": "none" }, - { "conn-limit": { "count": 30, "log": "none" } }, - { "conn-limit": { "count": 30, "log": "none" }, "action": "pass" }, - { "conn-limit": { "count": 30, "log": "none" }, "log": true }, - { "conn-limit": { "count": 30, "log": "none" }, "log": "none" }, - - { "flow-limit": 1 }, - { "flow-limit": 1, "action": "pass" }, - { "flow-limit": 1, "log": true }, - { "flow-limit": 1, "log": true, "action": "pass" }, - { "flow-limit": 1, "log": "none" }, - { "flow-limit": 1, "log": "none", "action": "pass" }, - { "flow-limit": { "count": 1, "log": false } }, - { "flow-limit": { "count": 1, "log": false }, "action": "pass" }, - { "flow-limit": { "count": 1, "log": false }, "log": true }, - { - "flow-limit": { "count": 1, "log": false }, - "log": true, - "action": "pass" - }, - { "flow-limit": { "count": 1, "log": false }, "log": "none" }, - { - "flow-limit": { "count": 1, "log": false }, - "log": "none", - "action": "pass" - }, - { "flow-limit": { "count": 1, "log": "none" } }, - { "flow-limit": { "count": 1, "log": "none" }, "action": "pass" }, - { "flow-limit": { "count": 1, "log": "none" }, "log": true }, - { - "flow-limit": { "count": 1, "log": "none" }, - "log": true, - "action": "pass" - }, - { "flow-limit": { "count": 1, "log": "none" }, "log": "none" }, - { - "flow-limit": { "count": 1, "log": "none" }, - "log": "none", - "action": "pass" - }, - - { "flow-limit": 30 }, - { "flow-limit": 30, "action": "pass" }, - { "flow-limit": 30, "log": true }, - { "flow-limit": 30, "log": "none" }, - { "flow-limit": { "count": 30, "log": false } }, - { "flow-limit": { "count": 30, "log": false }, "action": "pass" }, - { "flow-limit": { "count": 30, "log": false }, "log": true }, - { "flow-limit": { "count": 30, "log": false }, "log": "none" }, - { "flow-limit": { "count": 30, "log": "none" } }, - { "flow-limit": { "count": 30, "log": "none" }, "action": "pass" }, - { "flow-limit": { "count": 30, "log": "none" }, "log": true }, - { "flow-limit": { "count": 30, "log": "none" }, "log": "none" }, - - { "in": "A", "out": "_fw", "flow-limit": 1, "no-track": true }, - { - "in": "A", - "out": "_fw", - "flow-limit": 1, - "action": "pass", - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": 1, - "log": true, - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": 1, - "log": true, - "action": "pass", - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": 1, - "log": "none", - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": 1, - "log": "none", - "action": "pass", - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 1, "log": false }, - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 1, "log": false }, - "action": "pass", - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 1, "log": false }, - "log": true, - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 1, "log": false }, - "log": true, - "action": "pass", - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 1, "log": false }, - "log": "none", - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 1, "log": false }, - "log": "none", - "action": "pass", - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 1, "log": "none" }, - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 1, "log": "none" }, - "action": "pass", - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 1, "log": "none" }, - "log": true, - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 1, "log": "none" }, - "log": true, - "action": "pass", - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 1, "log": "none" }, - "log": "none", - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 1, "log": "none" }, - "log": "none", - "action": "pass", - "no-track": true - }, - - { "in": "A", "out": "_fw", "flow-limit": 30, "no-track": true }, - { - "in": "A", - "out": "_fw", - "flow-limit": 30, - "action": "pass", - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": 30, - "log": true, - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": 30, - "log": "none", - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 30, "log": false }, - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 30, "log": false }, - "action": "pass", - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 30, "log": false }, - "log": true, - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 30, "log": false }, - "log": "none", - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 30, "log": "none" }, - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 30, "log": "none" }, - "action": "pass", - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 30, "log": "none" }, - "log": true, - "no-track": true - }, - { - "in": "A", - "out": "_fw", - "flow-limit": { "count": 30, "log": "none" }, - "log": "none", - "no-track": true - } - ] -} diff --git a/test/mandatory/filter-limit.lua b/test/mandatory/filter-limit.lua new file mode 100644 index 0000000..a2f2838 --- /dev/null +++ b/test/mandatory/filter-limit.lua @@ -0,0 +1,36 @@ +util = require('awall.util') +json = require('cjson') + +res = {} + +function add(limit_type, base) + for _, count in ipairs{1, 30} do + for _, limit in ipairs{ + count, {count=count, log=false}, {count=count, log='none'} + } do + for _, log in ipairs{false, true, 'none'} do + for _, action in ipairs{false, 'pass'} do + if not (count == 30 and log and action) then + table.insert( + res, + util.update( + util.copy(base or {}), + { + [limit_type..'-limit']=limit, + log=log or nil, + action=action or nil + } + ) + ) + end + end + end + end + end +end + +add('conn') +add('flow') +add('flow', {['in']='A', out='_fw', ['no-track']=true}) + +print(json.encode{filter=res}) |