diff --git a/webinput-csv/test.sh b/webinput-csv/test.sh index 8cf76e8..7bf6ad1 100755 --- a/webinput-csv/test.sh +++ b/webinput-csv/test.sh @@ -22,21 +22,23 @@ wget --no-verbose -O - --header "Authorization: $token" http://localhost:1383/ap docker exec -ti intelmq intelmqctl stop deduplicator-expert docker exec -ti intelmq intelmqctl clear deduplicator-expert-queue -yesterday=$(date --date='yesterday') +# Use a non ISO-formatted date to test datetime parsing +yesterday=$(date --rfc-email --date='yesterday') wget --no-verbose -O - --header "Authorization: $token" --header "Content-Type: application/json;charset=utf-8" --post-data "{\"timezone\":\"+00:00\",\"data\":[{\"time.source\":\" $yesterday \",\"source.ip\":\"192.168.56.7\",\"source.asn\":\"65537\"}],\"custom\":{\"custom_classification.type\":\"blacklist\",\"custom_classification.identifier\":\"test\",\"custom_feed.code\":\"oneshot\",\"custom_feed.name\":\"oneshot-csv\"},\"dryrun\":true}" http://localhost:1383/api/upload | grep 'lines_invalid": 0' result=$(docker exec -ti intelmq intelmqctl run deduplicator-expert message get | grep -Ev 'deduplicator-expert|Waiting for a message|time.observation') -expected_date=$(date --rfc-3339=seconds --date="$yesterday" | tr ' ' T) +expected_date=$(TZ=UTC date --iso-8601=seconds --date="$yesterday") expected="{ - \"classification.identifier\": \"test\", - \"classification.type\": \"test\", - \"feed.code\": \"oneshot\", - \"feed.name\": \"oneshot-csv\", - \"feed.provider\": \"my-organization\", - \"source.asn\": 65537, - \"source.ip\": \"192.168.56.7\", - \"time.source\": \"$expected_date\" -" + \"classification.identifier\": \"test\", + \"classification.type\": \"test\", + \"feed.code\": \"oneshot\", + \"feed.name\": \"oneshot-csv\", + \"feed.provider\": \"my-organization\", + \"source.asn\": 65537, + \"source.ip\": \"192.168.56.7\", + \"time.source\": \"$expected_date\" + }" +result=$(echo $result | tr '\r' '\n') test "$result" = "$expected" echo "Webinput CSV tests completed successfully!"