Skip to content

Commit

Permalink
webinput test: workaround timezone issues
Browse files Browse the repository at this point in the history
work around certat/intelmq-webinput-csv#78
(webinput not knowing about 'CEST'/etc. timezone) by using a different
format (+02:00 syntax) and fixing the comparison step
  • Loading branch information
wagner-intevation committed Jul 13, 2022
1 parent fe7cec9 commit 6fac765
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions webinput-csv/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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!"

0 comments on commit 6fac765

Please sign in to comment.