2020-04-21 10:40:25 +00:00
#!/bin/sh
2020-01-23 11:59:22 +00:00
PROG = " $1 "
TEST = testaes
rm -rf $TEST
mkdir -p $TEST
TESTNAME = "Test aes encrypted telegrams"
TESTRESULT = "ERROR"
2022-11-20 12:29:28 +00:00
cat simulations/serial_aes.msg | grep '^{' | tr -d '#' | jq --sort-keys . > $TEST /test_expected.txt
2022-02-05 15:00:52 +00:00
cat simulations/serial_aes.msg | grep '^[CT]' | tr -d '#' > $TEST /test_input.txt
2020-01-23 11:59:22 +00:00
cat $TEST /test_input.txt | $PROG --format= json "stdin:rtlwmbus" \
ApWater apator162 88888888 00000000000000000000000000000000 \
2022-12-30 00:30:36 +00:00
Vatten multical21 76348799 28F64A24988064A079AA2C807D6102AE 2> $TEST /test_stderr.txt | jq --sort-keys . > $TEST /test_output.txt
2020-01-23 11:59:22 +00:00
2022-11-20 12:29:28 +00:00
cat $TEST /test_output.txt | sed 's/"timestamp": "....-..-..T..:..:..Z"/"timestamp": "1111-11-11T11:11:11Z"/' > $TEST /test_response.txt
2020-01-23 11:59:22 +00:00
diff $TEST /test_expected.txt $TEST /test_response.txt
2020-04-22 06:07:19 +00:00
if [ " $? " = "0" ]
2020-01-23 11:59:22 +00:00
then
echo " OK: $TESTNAME "
TESTRESULT = "OK"
2022-12-30 00:30:36 +00:00
else
if [ " $USE_MELD " = "true" ]
then
meld $TEST /test_expected.txt $TEST /test_response.txt
fi
2020-01-23 11:59:22 +00:00
fi
if [ " $TESTRESULT " = "ERROR" ] ; then echo ERROR: $TESTNAME ; exit 1; fi
2021-11-06 20:41:36 +00:00
TESTNAME = "Test that telegram really is encrypted"
TESTRESULT = "ERROR"
cat > $TEST /test_expected.txt <<EOF
2022-03-27 19:48:42 +00:00
( wmbus) WARNING!! telegram should have been fully encrypted, but was not! id: 88888888 mfct: ( APA) Apator, Poland ( 0x601) type: Water meter ( 0x07) ver: 0x05
2024-03-03 11:57:40 +00:00
( meter) newly created meter ( ApWater 88888888 apator162) did not handle telegram!
2021-11-06 20:41:36 +00:00
( wmbus) WARNING! decrypted payload crc failed check, did you use the correct decryption key? e1d6 payload crc ( calculated a528) Permanently ignoring telegrams from id: 76348799 mfct: ( KAM) Kamstrup Energi ( 0x2c2d) type: Cold water meter ( 0x16) ver: 0x1b
2024-03-03 11:57:40 +00:00
( meter) newly created meter ( Vatten 76348799 multical21) did not handle telegram!
2022-03-27 19:48:42 +00:00
( wmbus) WARNING!! telegram should have been fully encrypted, but was not! id: 77777777 mfct: ( SON) Sontex, Switzerland ( 0x4dee) type: Water meter ( 0x07) ver: 0x3c
2024-03-03 11:57:40 +00:00
( meter) newly created meter ( Wasser 77777777 supercom587) did not handle telegram!
2022-03-27 19:48:42 +00:00
( wmbus) WARNING!!! telegram should have been encrypted, but was not! id: 77777777 mfct: ( SON) Sontex, Switzerland ( 0x4dee) type: Water meter ( 0x07) ver: 0x3c
2021-11-06 20:41:36 +00:00
EOF
$PROG --format= json simulations/simulation_aes_removed.msg \
ApWater apator162 88888888 00000000000000000000000000000000 \
Vatten multical21 76348799 28F64A24988064A079AA2C807D6102AE \
Wasser supercom587 77777777 5065747220486F6C79737A6577736B69 > $TEST /test_output.txt 2>& 1
diff $TEST /test_expected.txt $TEST /test_output.txt
if [ " $? " = "0" ]
then
echo " OK: $TESTNAME "
TESTRESULT = "OK"
2022-12-30 00:30:36 +00:00
else
if [ " $USE_MELD " = "true" ]
then
meld $TEST /test_expected.txt $TEST /test_output.txt
fi
2021-11-06 20:41:36 +00:00
fi
if [ " $TESTRESULT " = "ERROR" ] ; then echo ERROR: $TESTNAME ; exit 1; fi