summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHarsha Sharma <harshasharmaiitr@gmail.com>2018-07-10 22:00:21 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2018-07-16 17:49:39 +0200
commitbf91cfd9a619484fa3fde325ac092d69738ecf47 (patch)
tree24eab42cb0972528476600495f412925b20f51e3 /tests
parent88456a7ef011728a98c950447630f0a128dcad13 (diff)
tests: shell: add tests for listing objects
Add tests for listing specific object for a given table name and all objects of a table. Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/shell/testcases/listing/0013objects_033
-rwxr-xr-xtests/shell/testcases/listing/0014objects_024
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/shell/testcases/listing/0013objects_0 b/tests/shell/testcases/listing/0013objects_0
new file mode 100755
index 00000000..c5e0e323
--- /dev/null
+++ b/tests/shell/testcases/listing/0013objects_0
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+# list table with all objects and chains
+
+EXPECTED="table ip test {
+ quota https-quota {
+ 25 mbytes
+ }
+
+ ct helper cthelp {
+ type \"sip\" protocol tcp
+ l3proto ip
+ }
+
+ chain input {
+ }
+}"
+
+set -e
+
+$NFT add table test
+$NFT add chain test input
+$NFT add quota test https-quota 25 mbytes
+$NFT add ct helper test cthelp { type \"sip\" protocol tcp \; }
+$NFT add table test-ip
+
+GET="$($NFT list table test)"
+if [ "$EXPECTED" != "$GET" ] ; then
+ DIFF="$(which diff)"
+ [ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET")
+ exit 1
+fi
+
diff --git a/tests/shell/testcases/listing/0014objects_0 b/tests/shell/testcases/listing/0014objects_0
new file mode 100755
index 00000000..dcfe2e6f
--- /dev/null
+++ b/tests/shell/testcases/listing/0014objects_0
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# list only the object asked for with table
+
+EXPECTED="table ip test {
+ quota https-quota {
+ 25 mbytes
+ }
+}"
+
+set -e
+
+$NFT add table test
+$NFT add quota test https-quota 25 mbytes
+$NFT add ct helper test cthelp { type \"sip\" protocol tcp \; }
+$NFT add table test-ip
+
+GET="$($NFT list quota test https-quota)"
+if [ "$EXPECTED" != "$GET" ] ; then
+ DIFF="$(which diff)"
+ [ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET")
+ exit 1
+fi
+