summaryrefslogtreecommitdiffstats
path: root/tests/shell
diff options
context:
space:
mode:
authorHarsha Sharma <harshasharmaiitr@gmail.com>2017-10-05 15:45:39 +0530
committerPablo Neira Ayuso <pablo@netfilter.org>2017-10-06 14:34:50 +0200
commit05b43a8d695b3d8190a600ad6db62970617e0563 (patch)
treed1627fe3623ad96fa0a3f14efa6f901d6a3a86bc /tests/shell
parentbea09fd12c1853a7e213891f71921aedf536b4cf (diff)
tests: shell: add testcases for named objects
Add testcases for creating named objects with unique name, defined by user and referencing them from rule. Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tests/shell')
-rwxr-xr-xtests/shell/testcases/sets/0024named_objects_041
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/shell/testcases/sets/0024named_objects_0 b/tests/shell/testcases/sets/0024named_objects_0
new file mode 100755
index 00000000..19dd1cd5
--- /dev/null
+++ b/tests/shell/testcases/sets/0024named_objects_0
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# This is the testscase:
+# * creating valid named objects
+# * referencing them from a valid rule
+
+tmpfile=$(mktemp)
+if [ ! -w $tmpfile ] ; then
+ echo "Failed to create tmp file" >&2
+ exit 0
+fi
+
+trap "rm -rf $tmpfile" EXIT # cleanup if aborted
+
+echo "
+table inet x {
+ counter user123 {
+ packets 12 bytes 1433
+ }
+ quota user123 {
+ over 2000 bytes
+ }
+ quota user124 {
+ over 2000 bytes
+ }
+ set y {
+ type ipv4_addr
+ }
+ map test {
+ type ipv4_addr : quota
+ elements = { 192.168.2.2 : "user124", 192.168.2.3 : "user124"}
+ }
+ chain y {
+ type filter hook input priority 0; policy accept;
+ counter name ip saddr map { 192.168.2.2 : "user123", 1.1.1.1 : "user123", 2.2.2.2 : "user123"}
+ quota name ip saddr map @test drop
+ }
+}" > $tmpfile
+
+set -e
+$NFT -f $tmpfile