94 lines
1.7 KiB
Bash
Executable File
94 lines
1.7 KiB
Bash
Executable File
#! /usr/bin/env bash
|
|
|
|
set -o pipefail
|
|
set -o errexit
|
|
set -o nounset
|
|
|
|
: ${DOMAIN:?specify domain name}
|
|
|
|
readonly AUTH_HEADER="Authorization: Bearer du-dummy-api-token"
|
|
readonly QUERY='query AllServices {
|
|
services {
|
|
allServices {
|
|
id
|
|
isEnabled
|
|
status
|
|
}
|
|
}
|
|
}'
|
|
|
|
# shellcheck disable=SC2116
|
|
# shellcheck disable=SC2086
|
|
REQUEST=$(cat << EOF
|
|
{
|
|
"query": "$(echo $QUERY)",
|
|
"variables": null,
|
|
"operationName": "AllServices"
|
|
}
|
|
EOF
|
|
)
|
|
readonly REQUEST
|
|
|
|
# TODO fix jitsi "isEnabled" expected response value
|
|
EXPECTED_RESPONSE=$(cat << EOF
|
|
{
|
|
"data": {
|
|
"services": {
|
|
"allServices": [
|
|
{
|
|
"id": "bitwarden",
|
|
"isEnabled": true,
|
|
"status": "ACTIVE"
|
|
},
|
|
{
|
|
"id": "gitea",
|
|
"isEnabled": true,
|
|
"status": "ACTIVE"
|
|
},
|
|
{
|
|
"id": "email",
|
|
"isEnabled": true,
|
|
"status": "ACTIVE"
|
|
},
|
|
{
|
|
"id": "nextcloud",
|
|
"isEnabled": true,
|
|
"status": "ACTIVE"
|
|
},
|
|
{
|
|
"id": "pleroma",
|
|
"isEnabled": true,
|
|
"status": "ACTIVE"
|
|
},
|
|
{
|
|
"id": "ocserv",
|
|
"isEnabled": true,
|
|
"status": "ACTIVE"
|
|
},
|
|
{
|
|
"id": "jitsi",
|
|
"isEnabled": false,
|
|
"status": "ACTIVE"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
EOF
|
|
)
|
|
readonly EXPECTED_RESPONSE
|
|
|
|
received_response="$(curl --show-error -s "https://api.$DOMAIN/graphql" \
|
|
--compressed \
|
|
-H 'Content-Type: application/json' \
|
|
--data-raw "$REQUEST" -k -H "$AUTH_HEADER" | jq --sort-keys)"
|
|
|
|
jq <<<"$received_response"
|
|
|
|
if [ "$EXPECTED_RESPONSE" == "$received_response" ]; then
|
|
echo -e "\e[1;32mOK"
|
|
else
|
|
echo -e "\e[1;31mFAIL: response does not match!"
|
|
exit 1
|
|
fi
|