|
|
bacbc8 |
From c4bc472abe9f92ca2fcb9696e8e84083dcc29269 Mon Sep 17 00:00:00 2001
|
|
|
bacbc8 |
From: Harsha Sharma <harshasharmaiitr@gmail.com>
|
|
|
bacbc8 |
Date: Tue, 10 Jul 2018 22:00:21 +0200
|
|
|
bacbc8 |
Subject: [PATCH] tests: shell: add tests for listing objects
|
|
|
bacbc8 |
|
|
|
bacbc8 |
Add tests for listing specific object for a given table name and all
|
|
|
bacbc8 |
objects of a table.
|
|
|
bacbc8 |
|
|
|
bacbc8 |
Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
|
|
|
bacbc8 |
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
bacbc8 |
(cherry picked from commit bf91cfd9a619484fa3fde325ac092d69738ecf47)
|
|
|
bacbc8 |
|
|
|
bacbc8 |
Conflicts:
|
|
|
bacbc8 |
-> adjust expected output in 0013objects_0 to old code base.
|
|
|
bacbc8 |
|
|
|
bacbc8 |
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
|
bacbc8 |
---
|
|
|
bacbc8 |
tests/shell/testcases/listing/0013objects_0 | 34 +++++++++++++++++++++
|
|
|
bacbc8 |
tests/shell/testcases/listing/0014objects_0 | 24 +++++++++++++++
|
|
|
bacbc8 |
2 files changed, 58 insertions(+)
|
|
|
bacbc8 |
create mode 100755 tests/shell/testcases/listing/0013objects_0
|
|
|
bacbc8 |
create mode 100755 tests/shell/testcases/listing/0014objects_0
|
|
|
bacbc8 |
|
|
|
bacbc8 |
diff --git a/tests/shell/testcases/listing/0013objects_0 b/tests/shell/testcases/listing/0013objects_0
|
|
|
bacbc8 |
new file mode 100755
|
|
|
bacbc8 |
index 0000000000000..c237e932a4483
|
|
|
bacbc8 |
--- /dev/null
|
|
|
bacbc8 |
+++ b/tests/shell/testcases/listing/0013objects_0
|
|
|
bacbc8 |
@@ -0,0 +1,34 @@
|
|
|
bacbc8 |
+#!/bin/bash
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
+# list table with all objects and chains
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
+EXPECTED="table ip test {
|
|
|
bacbc8 |
+ quota https-quota {
|
|
|
bacbc8 |
+ 25 mbytes
|
|
|
bacbc8 |
+ }
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
+ ct helper cthelp {
|
|
|
bacbc8 |
+ type \"sip\" protocol tcp
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
+ l3proto ip
|
|
|
bacbc8 |
+ }
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
+ chain input {
|
|
|
bacbc8 |
+ }
|
|
|
bacbc8 |
+}"
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
+set -e
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
+$NFT add table test
|
|
|
bacbc8 |
+$NFT add chain test input
|
|
|
bacbc8 |
+$NFT add quota test https-quota 25 mbytes
|
|
|
bacbc8 |
+$NFT add ct helper test cthelp { type \"sip\" protocol tcp \; }
|
|
|
bacbc8 |
+$NFT add table test-ip
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
+GET="$($NFT list table test)"
|
|
|
bacbc8 |
+if [ "$EXPECTED" != "$GET" ] ; then
|
|
|
bacbc8 |
+ DIFF="$(which diff)"
|
|
|
bacbc8 |
+ [ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET")
|
|
|
bacbc8 |
+ exit 1
|
|
|
bacbc8 |
+fi
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
diff --git a/tests/shell/testcases/listing/0014objects_0 b/tests/shell/testcases/listing/0014objects_0
|
|
|
bacbc8 |
new file mode 100755
|
|
|
bacbc8 |
index 0000000000000..dcfe2e6f80947
|
|
|
bacbc8 |
--- /dev/null
|
|
|
bacbc8 |
+++ b/tests/shell/testcases/listing/0014objects_0
|
|
|
bacbc8 |
@@ -0,0 +1,24 @@
|
|
|
bacbc8 |
+#!/bin/bash
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
+# list only the object asked for with table
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
+EXPECTED="table ip test {
|
|
|
bacbc8 |
+ quota https-quota {
|
|
|
bacbc8 |
+ 25 mbytes
|
|
|
bacbc8 |
+ }
|
|
|
bacbc8 |
+}"
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
+set -e
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
+$NFT add table test
|
|
|
bacbc8 |
+$NFT add quota test https-quota 25 mbytes
|
|
|
bacbc8 |
+$NFT add ct helper test cthelp { type \"sip\" protocol tcp \; }
|
|
|
bacbc8 |
+$NFT add table test-ip
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
+GET="$($NFT list quota test https-quota)"
|
|
|
bacbc8 |
+if [ "$EXPECTED" != "$GET" ] ; then
|
|
|
bacbc8 |
+ DIFF="$(which diff)"
|
|
|
bacbc8 |
+ [ -x $DIFF ] && $DIFF -u <(echo "$EXPECTED") <(echo "$GET")
|
|
|
bacbc8 |
+ exit 1
|
|
|
bacbc8 |
+fi
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
--
|
|
|
bacbc8 |
2.21.0
|
|
|
bacbc8 |
|