diff options
author | Florian Westphal <fw@strlen.de> | 2024-02-29 00:13:27 +0100 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2024-03-01 13:19:01 +0100 |
commit | 424a7f17848e9399ee3d360fcf134fb44f9a3ab0 (patch) | |
tree | 243989e008a45e55774118e3739f96e24b667803 /tests/shell/testcases/maps | |
parent | 8d2f36763d23201100a11161b179e29dbec5be3a (diff) |
tests: move test case to "maps" directory
This tests named object maps, so this should reside in maps/
not sets/ directory.
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'tests/shell/testcases/maps')
-rwxr-xr-x | tests/shell/testcases/maps/0024named_objects_0 | 48 | ||||
-rw-r--r-- | tests/shell/testcases/maps/dumps/0024named_objects_0.nft | 32 |
2 files changed, 80 insertions, 0 deletions
diff --git a/tests/shell/testcases/maps/0024named_objects_0 b/tests/shell/testcases/maps/0024named_objects_0 new file mode 100755 index 00000000..21200c3c --- /dev/null +++ b/tests/shell/testcases/maps/0024named_objects_0 @@ -0,0 +1,48 @@ +#!/bin/bash + +# This is the testscase: +# * creating valid named objects +# * referencing them from a valid rule + +RULESET=" +table inet x { + counter user123 { + packets 12 bytes 1433 + } + counter user321 { + 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 + } +}" + +set -e +$NFT -f - <<< "$RULESET" + +EXPECTED="table inet x { + counter user321 { + packets 12 bytes 1433 + } +}" + +GET="$($NFT reset counter inet x user321)" +if [ "$EXPECTED" != "$GET" ] ; then + $DIFF -u <(echo "$EXPECTED") <(echo "$GET") + exit 1 +fi diff --git a/tests/shell/testcases/maps/dumps/0024named_objects_0.nft b/tests/shell/testcases/maps/dumps/0024named_objects_0.nft new file mode 100644 index 00000000..2ffa4f2f --- /dev/null +++ b/tests/shell/testcases/maps/dumps/0024named_objects_0.nft @@ -0,0 +1,32 @@ +table inet x { + counter user123 { + packets 12 bytes 1433 + } + + counter user321 { + packets 0 bytes 0 + } + + 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 filter; policy accept; + counter name ip saddr map { 1.1.1.1 : "user123", 2.2.2.2 : "user123", 192.168.2.2 : "user123" } + quota name ip saddr map @test drop + } +} |