summaryrefslogtreecommitdiffstats
path: root/tests/json_var_case.sh
blob: 3cc7e1f2ee65061c49a6a4c564e729e44c5ba6d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# added 2015-11-24 by portant
# This file is part of the rsyslog project, released under ASL 2.0
echo ===========================================================================================
echo \[json_var_case.sh\]: test for JSON upper and lower case variables, and leading underscores
. ${srcdir:=.}/diag.sh init
generate_conf
add_conf '
global(variables.casesensitive="on")
module(load="../plugins/mmjsonparse/.libs/mmjsonparse")
module(load="../plugins/imtcp/.libs/imtcp")
input(type="imtcp" port="0" listenPortFileName="'$RSYSLOG_DYNNAME'.tcpflood_port")

# we must make sure the template contains references to the variables
template(name="outfmt" type="string" string="abc:%$!abc% ABC:%$!ABC% aBc:%$!aBc% _abc:%$!_abc% _ABC:%$!_ABC% _aBc:%$!_aBc%\n" option.casesensitive="on")
template(name="outfmt-all-json" type="string" string="%$!all-json%\n")

action(type="mmjsonparse")
set $!_aBc = "7";
action(type="omfile" file=`echo $RSYSLOG_OUT_LOG` template="outfmt")
if $!_aBc != "7" then
	action(type="omfile" file="./'"${RSYSLOG2_OUT_LOG}"'" template="outfmt-all-json")
'
startup
tcpflood -m 1 -M "\"<167>Nov  6 12:34:56 172.0.0.1 test: @cee: { \\\"abc\\\": \\\"1\\\", \\\"ABC\\\": \\\"2\\\", \\\"aBc\\\": \\\"3\\\", \\\"_abc\\\": \\\"4\\\", \\\"_ABC\\\": \\\"5\\\", \\\"_aBc\\\": \\\"6\\\" }\""
echo doing shutdown
shutdown_when_empty
echo wait on shutdown
wait_shutdown
# NOTE: conf file updates _aBc to "7"
content_check  "abc:1 ABC:2 aBc:3 _abc:4 _ABC:5 _aBc:7"
exit_test