Files
David Schroeder 8418cbed56 update
2026-07-28 20:14:57 -05:00

29 lines
974 B
Bash

#!/usr/bin/env bash
set -euo pipefail
TEST_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd -P)"
# shellcheck source=../inc/rmm.inc
source "${TEST_ROOT}/inc/rmm.inc"
example_token='a81581f5-2e8c-465a-9eff-a094a75d5bbf'
example_url="https://prod.setup.itsupport247.net/linux/BareboneAgent/64/TA_Green_Bay-Technology_Arch_Corporate_Linux_Server_ITSPlatform_TKN${example_token}/RUN/setup"
actual_token="$(TAPM_RMM_TOKEN_FROM_URL "$example_url")"
if [[ "$actual_token" != "$example_token" ]]; then
printf 'FAIL: extracted %q, want %q\n' "$actual_token" "$example_token" >&2
exit 1
fi
if TAPM_RMM_TOKEN_FROM_URL 'https://prod.setup.itsupport247.net/linux/setup' >/dev/null; then
printf 'FAIL: accepted an RMM URL without a token\n' >&2
exit 1
fi
if TAPM_RMM_TOKEN_FROM_URL \
'https://prod.setup.itsupport247.net/TKNnot-a-token/RUN/setup' >/dev/null; then
printf 'FAIL: accepted a malformed RMM token\n' >&2
exit 1
fi
printf 'PASS: RMM token extraction\n'