#!/usr/bin/env bash
set -eu
# Supply the test PAT, organization, project, and an isolated AZURE_CONFIG_DIR.
: "${AZURE_DEVOPS_EXT_PAT:?}" "${AZURE_DEVOPS_TEST_ORG:?}" "${AZURE_DEVOPS_TEST_PROJECT:?}" "${AZURE_CONFIG_DIR:?}"
# Point AZURE_EXTENSION_DIR at the installed Azure DevOps extension directory.
az devops configure --defaults organization="$AZURE_DEVOPS_TEST_ORG" project="$AZURE_DEVOPS_TEST_PROJECT"
# T3's readiness probe uses account show, which does not recognize PAT authentication.
# This synthetic local profile satisfies discovery only; repository requests use the real PAT.
python3 - <<'PY'
import json, os
from pathlib import Path
zero = '00000000-0000-0000-0000-000000000000'
profile = {'subscriptions': [{'id': zero, 'name': 'Azure DevOps test', 'state': 'Enabled', 'user': {'name': 'factory@example.invalid', 'type': 'user'}, 'isDefault': True, 'tenantId': zero, 'environmentName': 'AzureCloud'}]}
(Path(os.environ['AZURE_CONFIG_DIR']) / 'azureProfile.json').write_text(json.dumps(profile))
PY
export T3CODE_DEV_SEED=0
export T3_SCENARIO_INHERIT_ENV='AZURE_*,T3CODE_DEV_SEED'
vp run scenarios:prove scripts/scenarios/azure-repository-literal-at.e2e.ts --base f28ced81b36027597c2fe45a1cc271e880975451 --head 5a0bd52a97b76fc23d96b0f89bb4a38973edeb96 --upload-command 'ghdrop upload'
