summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Gignac <martin.gignac@gmail.com>2022-04-09 08:57:02 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2022-04-10 17:19:34 +0200
commitc36ecfc21ba87b11bdf714250e86afcc075280cd (patch)
tree1c65ace0e2051df4207859ee7df1a1ef03f61a7a
parent6fa4ff56385831f01bd9d993178969a4eddbcdbf (diff)
tests: py: Add meta time tests without 'meta' keyword
v1.0.2 of 'nft' fails on 'time < "2022-07-01 11:00:00"' but succeeds when 'meta' is specified ('meta time < "2022-07-01 11:00:00"'). This extends coverage by testing 'time' without 'meta'. Signed-off-by: Martin Gignac <martin.gignac@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--tests/py/any/meta.t2
-rw-r--r--tests/py/any/meta.t.json36
-rw-r--r--tests/py/any/meta.t.payload14
3 files changed, 52 insertions, 0 deletions
diff --git a/tests/py/any/meta.t b/tests/py/any/meta.t
index e3beea2e..12fabb79 100644
--- a/tests/py/any/meta.t
+++ b/tests/py/any/meta.t
@@ -218,6 +218,8 @@ meta hour "17:00:00" drop;ok;meta hour "17:00" drop
meta hour "17:00:01" drop;ok
meta hour "00:00" drop;ok
meta hour "00:01" drop;ok
+time < "2022-07-01 11:00:00" accept;ok;meta time < "2022-07-01 11:00:00" accept
+time > "2022-07-01 11:00:00" accept;ok;meta time > "2022-07-01 11:00:00" accept
meta time "meh";fail
meta hour "24:00" drop;fail
diff --git a/tests/py/any/meta.t.json b/tests/py/any/meta.t.json
index 5472dc85..4734bbf9 100644
--- a/tests/py/any/meta.t.json
+++ b/tests/py/any/meta.t.json
@@ -2722,3 +2722,39 @@
"drop": null
}
]
+
+# time < "2022-07-01 11:00:00" accept
+[
+ {
+ "match": {
+ "left": {
+ "meta": {
+ "key": "time"
+ }
+ },
+ "op": "<",
+ "right": "2022-07-01 11:00:00"
+ }
+ },
+ {
+ "accept": null
+ }
+]
+
+# time > "2022-07-01 11:00:00" accept
+[
+ {
+ "match": {
+ "left": {
+ "meta": {
+ "key": "time"
+ }
+ },
+ "op": ">",
+ "right": "2022-07-01 11:00:00"
+ }
+ },
+ {
+ "accept": null
+ }
+]
diff --git a/tests/py/any/meta.t.payload b/tests/py/any/meta.t.payload
index 15439062..16dc1211 100644
--- a/tests/py/any/meta.t.payload
+++ b/tests/py/any/meta.t.payload
@@ -1058,3 +1058,17 @@ ip meta-test input
[ meta load hour => reg 1 ]
[ cmp eq reg 1 0x0001359c ]
[ immediate reg 0 drop ]
+
+# time < "2022-07-01 11:00:00" accept
+ip test-ip4 input
+ [ meta load time => reg 1 ]
+ [ byteorder reg 1 = hton(reg 1, 8, 8) ]
+ [ cmp lt reg 1 0xf3a8fd16 0x00a07719 ]
+ [ immediate reg 0 accept ]
+
+# time > "2022-07-01 11:00:00" accept
+ip test-ip4 input
+ [ meta load time => reg 1 ]
+ [ byteorder reg 1 = hton(reg 1, 8, 8) ]
+ [ cmp gt reg 1 0xf3a8fd16 0x00a07719 ]
+ [ immediate reg 0 accept ]