diff --git a/scripts/live-test.sh b/scripts/live-test.sh index e92c8d6..e5de30c 100755 --- a/scripts/live-test.sh +++ b/scripts/live-test.sh @@ -31,8 +31,11 @@ Env: GOG_LIVE_GROUP_EMAIL= GOG_LIVE_CLASSROOM_COURSE= GOG_LIVE_CLASSROOM_CREATE=1 + GOG_LIVE_CLASSROOM_ALLOW_STATE=1 GOG_LIVE_TRACK=1 GOG_LIVE_ALLOW_NONTEST=1 + GOG_LIVE_CALENDAR_RESPOND=1 + GOG_LIVE_GMAIL_BATCH_DELETE=1 GOG_KEEP_SERVICE_ACCOUNT=/path/to/service-account.json GOG_KEEP_IMPERSONATE=user@workspace-domain USAGE diff --git a/scripts/live-tests/calendar.sh b/scripts/live-tests/calendar.sh index 88790b1..9d27779 100644 --- a/scripts/live-tests/calendar.sh +++ b/scripts/live-tests/calendar.sh @@ -34,7 +34,11 @@ PY run_required "calendar" "calendar freebusy" gog calendar freebusy primary --from "$START" --to "$END" --json >/dev/null run_required "calendar" "calendar conflicts" gog calendar conflicts --from "$START" --to "$END" --json >/dev/null - run_optional "calendar-respond" "calendar respond" gog calendar respond primary "$ev_id" --status accepted --json >/dev/null + if [ -n "${GOG_LIVE_CALENDAR_RESPOND:-}" ]; then + run_optional "calendar-respond" "calendar respond" gog calendar respond primary "$ev_id" --status accepted --json >/dev/null + else + echo "==> calendar respond (skipped; needs invite from another account)" + fi run_required "calendar" "calendar delete event" gog calendar delete primary "$ev_id" --force >/dev/null @@ -44,9 +48,13 @@ PY run_optional "calendar-enterprise" "calendar working-location" gog calendar create primary --event-type working-location --working-location-type office --working-office-label "HQ" --from "$DAY1" --to "$DAY2" --json >/dev/null 2>&1 || true fi - if [ -n "${GOG_LIVE_GROUP_EMAIL:-}" ]; then + if [ -n "${GOG_LIVE_GROUP_EMAIL:-}" ] && ! is_consumer_account "$ACCOUNT"; then run_optional "calendar-team" "calendar team" gog calendar team "$GOG_LIVE_GROUP_EMAIL" --json --max 5 >/dev/null fi - run_optional "calendar-users" "calendar users list" gog calendar users --json --max 1 >/dev/null + if is_consumer_account "$ACCOUNT"; then + echo "==> calendar users (skipped; Workspace only)" + else + run_optional "calendar-users" "calendar users list" gog calendar users --json --max 1 >/dev/null + fi } diff --git a/scripts/live-tests/classroom.sh b/scripts/live-tests/classroom.sh index 5ab7b95..b0325e2 100644 --- a/scripts/live-tests/classroom.sh +++ b/scripts/live-tests/classroom.sh @@ -37,12 +37,18 @@ run_classroom_tests() { echo "==> classroom (optional; set GOG_LIVE_CLASSROOM_COURSE to expand)" fi - if [ -n "${GOG_LIVE_CLASSROOM_CREATE:-}" ]; then + # Disabled by default: creator account lacks course state permissions. + if [ -n "${GOG_LIVE_CLASSROOM_CREATE:-}" ] && [ -n "${GOG_LIVE_CLASSROOM_ALLOW_STATE:-}" ]; then local course_json course_id topic_json topic_id announcement_json announcement_id material_json material_id coursework_json coursework_id echo "==> classroom courses create" - course_json=$(gog classroom courses create --name "gogcli-smoke-$TS" --section "gogcli" --state ACTIVE --json 2>/dev/null || \ - gog classroom courses create --name "gogcli-smoke-$TS" --section "gogcli" --state PROVISIONED --json) + if course_json=$(gog classroom courses create --name "gogcli-smoke-$TS" --section "gogcli" --state ACTIVE --json 2>/dev/null); then + : + elif course_json=$(gog classroom courses create --name "gogcli-smoke-$TS" --section "gogcli" --state PROVISIONED --json 2>/dev/null); then + : + else + course_json="" + fi course_id=$(extract_id "$course_json") if [ -z "$course_id" ]; then echo "Classroom course create failed; skipping create tests." @@ -97,5 +103,7 @@ run_classroom_tests() { return 1 fi fi + elif [ -n "${GOG_LIVE_CLASSROOM_CREATE:-}" ]; then + echo "==> classroom create (skipped; no account with course state permissions)" fi } diff --git a/scripts/live-tests/common.sh b/scripts/live-tests/common.sh index d5d4f52..e4966d7 100644 --- a/scripts/live-tests/common.sh +++ b/scripts/live-tests/common.sh @@ -180,6 +180,18 @@ is_test_account() { return 1 } +is_consumer_account() { + local a domain + a=$(echo "$1" | tr 'A-Z' 'a-z') + domain="${a##*@}" + case "$domain" in + gmail.com|googlemail.com) + return 0 + ;; + esac + return 1 +} + ensure_test_account() { if [ "${ALLOW_NONTEST:-false}" = true ] || [ -n "${GOG_LIVE_ALLOW_NONTEST:-}" ]; then return 0 diff --git a/scripts/live-tests/contacts.sh b/scripts/live-tests/contacts.sh index 00b2b18..9bb41dd 100644 --- a/scripts/live-tests/contacts.sh +++ b/scripts/live-tests/contacts.sh @@ -20,8 +20,13 @@ run_contacts_tests() { run_required "contacts" "contacts search" gog contacts search "gogcli-smoke-$TS@example.com" --json --max 1 >/dev/null run_required "contacts" "contacts delete" gog contacts delete "$contact_id" --force >/dev/null - run_optional "contacts-directory" "contacts directory list" gog contacts directory list --json --max 1 >/dev/null - run_optional "contacts-directory" "contacts directory search" gog contacts directory search "gogcli" --json --max 1 >/dev/null - run_optional "contacts-other" "contacts other list" gog contacts other list --json --max 1 >/dev/null - run_optional "contacts-other" "contacts other search" gog contacts other search "gogcli" --json --max 1 >/dev/null + if is_consumer_account "$ACCOUNT"; then + echo "==> contacts directory (skipped; Workspace only)" + echo "==> contacts other (skipped; Workspace only)" + else + run_optional "contacts-directory" "contacts directory list" gog contacts directory list --json --max 1 >/dev/null + run_optional "contacts-directory" "contacts directory search" gog contacts directory search "gogcli" --json --max 1 >/dev/null + run_optional "contacts-other" "contacts other list" gog contacts other list --json --max 1 >/dev/null + run_optional "contacts-other" "contacts other search" gog contacts other search "gogcli" --json --max 1 >/dev/null + fi } diff --git a/scripts/live-tests/gmail.sh b/scripts/live-tests/gmail.sh index 48671c8..e426f68 100644 --- a/scripts/live-tests/gmail.sh +++ b/scripts/live-tests/gmail.sh @@ -15,7 +15,11 @@ run_gmail_tests() { run_required "gmail" "gmail settings sendas list" gog gmail settings sendas list --json >/dev/null run_required "gmail" "gmail settings vacation get" gog gmail settings vacation get --json >/dev/null run_required "gmail" "gmail settings filters list" gog gmail settings filters list --json >/dev/null - run_optional "gmail-delegates" "gmail settings delegates list" gog gmail settings delegates list --json >/dev/null + if is_consumer_account "$ACCOUNT"; then + echo "==> gmail delegates (skipped; Workspace/SA only)" + else + run_optional "gmail-delegates" "gmail settings delegates list" gog gmail settings delegates list --json >/dev/null + fi run_required "gmail" "gmail settings forwarding list" gog gmail settings forwarding list --json >/dev/null run_required "gmail" "gmail settings autoforward get" gog gmail settings autoforward get --json >/dev/null fi @@ -49,7 +53,7 @@ run_gmail_tests() { run_required "gmail" "gmail batch modify add" gog gmail batch modify "$send_msg_id" --add STARRED --json >/dev/null run_required "gmail" "gmail batch modify remove" gog gmail batch modify "$send_msg_id" --remove STARRED --json >/dev/null - if skip "gmail-batch-delete"; then + if [ -z "${GOG_LIVE_GMAIL_BATCH_DELETE:-}" ] || skip "gmail-batch-delete"; then echo "==> gmail batch delete (skipped)" else echo "==> gmail batch delete" diff --git a/scripts/live-tests/workspace.sh b/scripts/live-tests/workspace.sh index 4736cfa..7b0e55b 100644 --- a/scripts/live-tests/workspace.sh +++ b/scripts/live-tests/workspace.sh @@ -3,10 +3,13 @@ set -euo pipefail run_workspace_tests() { - run_optional "groups" "groups list" gog groups list --json --max 5 >/dev/null - - if [ -n "${GOG_LIVE_GROUP_EMAIL:-}" ]; then - run_optional "groups" "groups members" gog groups members "$GOG_LIVE_GROUP_EMAIL" --json --max 5 >/dev/null + if is_consumer_account "$ACCOUNT"; then + echo "==> groups (skipped; Workspace only)" + else + run_optional "groups" "groups list" gog groups list --json --max 5 >/dev/null + if [ -n "${GOG_LIVE_GROUP_EMAIL:-}" ]; then + run_optional "groups" "groups members" gog groups members "$GOG_LIVE_GROUP_EMAIL" --json --max 5 >/dev/null + fi fi if skip "keep"; then @@ -14,6 +17,11 @@ run_workspace_tests() { return 0 fi + if is_consumer_account "$ACCOUNT"; then + echo "==> keep (skipped; Workspace only)" + return 0 + fi + if [ -z "${GOG_KEEP_SERVICE_ACCOUNT:-}" ] || [ -z "${GOG_KEEP_IMPERSONATE:-}" ]; then if [ "${STRICT:-false}" = true ]; then echo "Missing GOG_KEEP_SERVICE_ACCOUNT/GOG_KEEP_IMPERSONATE for keep tests." >&2