|
Packit |
1422b7 |
# some more tests for the "rest" motif, especially to ensure that
|
|
Packit |
1422b7 |
# "rest" will not interfere with more specific rules.
|
|
Packit |
1422b7 |
# added 2015-04-27
|
|
Packit |
1422b7 |
# This file is part of the liblognorm project, released under ASL 2.0
|
|
Packit |
1422b7 |
. $srcdir/exec.sh
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
test_def $0 "rest matches"
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
#tail recursion with default tail field
|
|
Packit |
1422b7 |
add_rule 'version=2'
|
|
Packit |
1422b7 |
add_rule 'rule=:%iface:char-to:\x3a%\x3a%ip:ipv4%/%port:number% (%label2:char-to:)%)'
|
|
Packit |
1422b7 |
add_rule 'rule=:%iface:char-to:\x3a%\x3a%ip:ipv4%/%port:number% (%label2:char-to:)%)%tail:rest%'
|
|
Packit |
1422b7 |
add_rule 'rule=:%iface:char-to:\x3a%\x3a%ip:ipv4%/%port:number%'
|
|
Packit |
1422b7 |
add_rule 'rule=:%iface:char-to:\x3a%\x3a%ip:ipv4%/%port:number%%tail:rest%'
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
# real-world cisco samples
|
|
Packit |
1422b7 |
execute 'Outside:10.20.30.40/35 (40.30.20.10/35)'
|
|
Packit |
1422b7 |
assert_output_json_eq '{ "label2": "40.30.20.10\/35", "port": "35", "ip": "10.20.30.40", "iface": "Outside" }'
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
execute 'Outside:10.20.30.40/35 (40.30.20.10/35) with rest'
|
|
Packit |
1422b7 |
assert_output_json_eq '{ "tail": " with rest", "label2": "40.30.20.10\/35", "port": "35", "ip": "10.20.30.40", "iface": "Outside" }'
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
execute 'Outside:10.20.30.40/35 (40.30.20.10/35 brace missing'
|
|
Packit |
1422b7 |
assert_output_json_eq '{ "tail": " (40.30.20.10\/35 brace missing", "port": "35", "ip": "10.20.30.40", "iface": "Outside" }'
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
execute 'Outside:10.20.30.40/35 40.30.20.10/35'
|
|
Packit |
1422b7 |
assert_output_json_eq '{ "tail": " 40.30.20.10\/35", "port": "35", "ip": "10.20.30.40", "iface": "Outside" }'
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
#
|
|
Packit |
1422b7 |
# test expected mismatches
|
|
Packit |
1422b7 |
#
|
|
Packit |
1422b7 |
execute 'not at all!'
|
|
Packit |
1422b7 |
assert_output_json_eq '{ "originalmsg": "not at all!", "unparsed-data": "not at all!" }'
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
execute 'Outside 10.20.30.40/35 40.30.20.10/35'
|
|
Packit |
1422b7 |
assert_output_json_eq '{ "originalmsg": "Outside 10.20.30.40\/35 40.30.20.10\/35", "unparsed-data": "Outside 10.20.30.40\/35 40.30.20.10\/35" }'
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
execute 'Outside:10.20.30.40/aa 40.30.20.10/35'
|
|
Packit |
1422b7 |
assert_output_json_eq '{ "originalmsg": "Outside:10.20.30.40\/aa 40.30.20.10\/35", "unparsed-data": "aa 40.30.20.10\/35" }'
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
|
|
Packit |
1422b7 |
cleanup_tmp_files
|
|
Packit |
1422b7 |
|