2022-02-12 20:28:38 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
cd $(dirname $0)
|
2022-06-23 14:40:29 +02:00
|
|
|
. ../util.sh
|
|
|
|
current_test=$(basename $(pwd))
|
2022-02-12 20:28:38 +01:00
|
|
|
|
2023-09-02 15:17:46 +02:00
|
|
|
export LOCAL_DIR=$(mktemp -d)
|
2022-02-12 20:28:38 +01:00
|
|
|
|
2023-08-27 19:19:11 +02:00
|
|
|
docker compose up -d --quiet-pull
|
2022-02-12 20:28:38 +01:00
|
|
|
sleep 5
|
|
|
|
|
|
|
|
GOTIFY_TOKEN=$(curl -sSLX POST -H 'Content-Type: application/json' -d '{"name":"test"}' http://admin:custom@localhost:8080/application | jq -r '.token')
|
2022-06-23 14:40:29 +02:00
|
|
|
info "Set up Gotify application using token $GOTIFY_TOKEN"
|
2022-02-12 20:28:38 +01:00
|
|
|
|
2023-01-07 18:50:27 +01:00
|
|
|
docker compose exec backup backup
|
2022-02-12 20:28:38 +01:00
|
|
|
|
2022-02-13 09:41:36 +01:00
|
|
|
NUM_MESSAGES=$(curl -sSL http://admin:custom@localhost:8080/message | jq -r '.messages | length')
|
|
|
|
if [ "$NUM_MESSAGES" != 0 ]; then
|
2022-06-23 14:40:29 +02:00
|
|
|
fail "Expected no notifications to be sent when not configured"
|
2022-02-12 20:28:38 +01:00
|
|
|
fi
|
2022-06-23 14:40:29 +02:00
|
|
|
pass "No notifications were sent when not configured."
|
2022-02-13 09:41:36 +01:00
|
|
|
|
2023-01-07 18:50:27 +01:00
|
|
|
docker compose down
|
2022-02-12 20:28:38 +01:00
|
|
|
|
2023-01-07 18:50:27 +01:00
|
|
|
NOTIFICATION_URLS="gotify://gotify/${GOTIFY_TOKEN}?disableTLS=true" docker compose up -d
|
2022-02-12 20:28:38 +01:00
|
|
|
|
2023-01-07 18:50:27 +01:00
|
|
|
docker compose exec backup backup
|
2022-02-13 09:41:36 +01:00
|
|
|
|
|
|
|
NUM_MESSAGES=$(curl -sSL http://admin:custom@localhost:8080/message | jq -r '.messages | length')
|
|
|
|
if [ "$NUM_MESSAGES" != 1 ]; then
|
2022-06-23 14:40:29 +02:00
|
|
|
fail "Expected one notifications to be sent when configured"
|
2022-02-13 09:41:36 +01:00
|
|
|
fi
|
2022-06-23 14:40:29 +02:00
|
|
|
pass "Correct number of notifications were sent when configured."
|
2022-02-12 20:28:38 +01:00
|
|
|
|
2022-02-13 09:41:36 +01:00
|
|
|
MESSAGE_TITLE=$(curl -sSL http://admin:custom@localhost:8080/message | jq -r '.messages[0].title')
|
|
|
|
MESSAGE_BODY=$(curl -sSL http://admin:custom@localhost:8080/message | jq -r '.messages[0].message')
|
2022-02-12 20:28:38 +01:00
|
|
|
|
2022-07-06 13:16:32 +02:00
|
|
|
if [ "$MESSAGE_TITLE" != "Successful test run with extra-value, yay!" ]; then
|
2022-06-23 14:40:29 +02:00
|
|
|
fail "Unexpected notification title $MESSAGE_TITLE"
|
2022-02-13 09:41:36 +01:00
|
|
|
fi
|
2022-06-23 14:40:29 +02:00
|
|
|
pass "Custom notification title was used."
|
2022-02-13 09:41:36 +01:00
|
|
|
|
|
|
|
if [ "$MESSAGE_BODY" != "Backing up /tmp/test.tar.gz succeeded." ]; then
|
2022-06-23 14:40:29 +02:00
|
|
|
fail "Unexpected notification body $MESSAGE_BODY"
|
2022-02-13 09:41:36 +01:00
|
|
|
fi
|
2022-06-23 14:40:29 +02:00
|
|
|
pass "Custom notification body was used."
|