Skip to content

Commit

Permalink
test: verify property baseed filtering on msgid and structured data
Browse files Browse the repository at this point in the history
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
  • Loading branch information
troglobit committed Dec 31, 2024
1 parent 91a2191 commit 0c2d017
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
EXTRA_DIST = lib.sh opts.sh
EXTRA_DIST += api.sh local.sh unicode.sh remote.sh fwd.sh mark.sh \
memleak.sh facility.sh notify.sh rotate_all.sh secure.sh \
logger.sh listen.sh sighup.sh tag.sh hostname.sh property.sh
logger.sh listen.sh sighup.sh tag.sh hostname.sh \
property.sh raw.sh
CLEANFILES = *~ *.trs *.log
TEST_EXTENSIONS = .sh
TESTS_ENVIRONMENT= unshare -mrun
Expand Down Expand Up @@ -30,5 +31,6 @@ TESTS += sighup.sh
TESTS += tag.sh
TESTS += hostname.sh
TESTS += property.sh
TESTS += raw.sh

programs: $(check_PROGRAMS)
39 changes: 39 additions & 0 deletions test/raw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh
. "${srcdir:-.}/lib.sh"

ID47="$DIR/id47.log"
DATA="$DIR/data.log"

setup_rfc5424()
{
cat <<-EOF > "${CONF}"
# Match all log messages, store in RC5424
*.* -${LOG} ;RFC5424
# Match ID47
:msgid, equal, "ID47"
*.* ${ID47} ;RFC5424
:data, regex, ".*eventSource=\"Application\".*"
*.* ${DATA} ;RFC5424
EOF
setup -m0 >"${LOG2}"
}

verify_netcat()
{
MSG='<165>1 2003-10-11T22:14:15.003Z mymachine.example.com su 12345 ID47 [exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"][id@2 test="tast"] BOM"su root" failed for lonvick on /dev/pts/8" '

echo "$MSG" | nc -w1 -Uu "${SOCK}"
grep -H "mymachine" "${ID47}"
}

check_log()
{
log="$1"; shift
msg="$*"

grep -H "$msg" "$log"
}

run_step "Set up syslogd w/ RFC5424" setup_rfc5424
run_step "Verify parsing of netcat message" verify_netcat
run_step "Verify regexp on structured data" check_log "$DATA" "mymachine"

0 comments on commit 0c2d017

Please sign in to comment.