wmbusmeters/tests/test_key_warnings.sh

42 wiersze
1.3 KiB
Bash

2021-01-06 12:28:56 +00:00
#!/bin/sh
PROG="$1"
mkdir -p testoutput
TEST=testoutput
TESTNAME="Test that failed decryption warning only prints once."
TESTRESULT="OK"
$PROG --format=json simulations/simulation_bad_keys.txt room fhkvdataiv 03065716 NOKEY \
2> $TEST/test_stderr.txt | jq --sort-keys . > $TEST/test_output.txt
2021-01-06 12:28:56 +00:00
2021-01-06 18:48:56 +00:00
cat > $TEST/expected_err.txt <<EOF
(wmbus) WARNING! no key to decrypt payload! Permanently ignoring telegrams from id: 03065716 mfct: (TCH) Techem Service (0x5068) type: Heat Cost Allocator (0x08) ver: 0x94
2024-03-03 11:57:40 +00:00
(meter) newly created meter (room 03065716 fhkvdataiv) did not handle telegram!
2021-01-06 18:48:56 +00:00
EOF
diff $TEST/test_stderr.txt $TEST/expected_err.txt
2021-01-06 12:28:56 +00:00
2021-01-06 18:48:56 +00:00
if [ "$?" != "0" ]
2021-01-06 12:28:56 +00:00
then
TESTRESULT="ERROR"
fi
$PROG --format=json simulations/simulation_bad_keys.txt room fhkvdataiv 03065716 00112233445566778899AABBCCDDEEFF \
2> $TEST/test_stderr.txt | jq --sort-keys . > $TEST/test_output.txt
2021-01-06 18:48:56 +00:00
cat > $TEST/expected_err.txt <<EOF
(wmbus) WARNING!! decrypted content failed check, did you use the correct decryption key? Permanently ignoring telegrams from id: 03065716 mfct: (TCH) Techem Service (0x5068) type: Heat Cost Allocator (0x08) ver: 0x94
2024-03-03 11:57:40 +00:00
(meter) newly created meter (room 03065716 fhkvdataiv) did not handle telegram!
2021-01-06 18:48:56 +00:00
EOF
diff $TEST/test_stderr.txt $TEST/expected_err.txt
if [ "$?" != "0" ]
2021-01-06 12:28:56 +00:00
then
TESTRESULT="ERROR"
fi
echo ${TESTRESULT}: $TESTNAME