Harden Gitea login fallback selection
This commit is contained in:
@@ -46,6 +46,10 @@ JSON
|
||||
fi
|
||||
|
||||
printf 'tea %s\n' "$*" >> "$MOSAIC_TEST_LOG"
|
||||
if [[ "${MOSAIC_TEA_FAIL_PR_CREATE:-}" == "1" && "$*" == pr\ create* ]]; then
|
||||
echo 'GetUserByName: simulated stale login failure' >&2
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
SH
|
||||
|
||||
@@ -94,6 +98,17 @@ if [[ "$usc_login" != "usc" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
usc_login_with_usc_url=$(run_in_repo bash -c '
|
||||
export GITEA_LOGIN=mosaicstack
|
||||
export GITEA_URL=https://git.uscllc.com
|
||||
source "'"$SCRIPT_DIR"'/detect-platform.sh"
|
||||
get_gitea_login
|
||||
')
|
||||
if [[ "$usc_login_with_usc_url" != "usc" ]]; then
|
||||
echo "Expected USC host to reject stale GITEA_LOGIN even when GITEA_URL matches USC; got '$usc_login_with_usc_url'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
usc_login_without_url=$(run_in_repo bash -c '
|
||||
export GITEA_LOGIN=mosaicstack
|
||||
unset GITEA_URL
|
||||
@@ -197,6 +212,15 @@ run_in_repo "$SCRIPT_DIR/pr-ci-wait.sh" --repo USC/uconnect --host git.uscllc.co
|
||||
grep -q -- 'curl .*https://git.uscllc.com/api/v1/repos/USC/uconnect/pulls/9' "$LOG_FILE"
|
||||
grep -q -- 'curl .*https://git.uscllc.com/api/v1/repos/USC/uconnect/commits/abc123/status' "$LOG_FILE"
|
||||
|
||||
: > "$LOG_FILE"
|
||||
run_in_repo env MOSAIC_TEA_FAIL_PR_CREATE=1 GITEA_TOKEN=usc-token GITEA_URL=https://git.uscllc.com "$SCRIPT_DIR/pr-create.sh" -t "USC API fallback" -H feature/pr-create
|
||||
grep -q -- 'tea pr create --repo USC/uconnect --login usc --title USC API fallback --head feature/pr-create' "$LOG_FILE"
|
||||
grep -q -- 'curl .*Authorization: token usc-token .*https://git.uscllc.com/api/v1/repos/USC/uconnect/pulls' "$LOG_FILE"
|
||||
if grep -q -- 'git.mosaicstack.dev/api/v1/repos/USC/uconnect/pulls' "$LOG_FILE"; then
|
||||
echo "pr-create.sh API fallback defaulted USC repo to git.mosaicstack.dev" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git -C "$REPO_DIR" remote set-url origin https://git.mosaicstack.dev/mosaicstack/stack.git
|
||||
: > "$LOG_FILE"
|
||||
run_in_repo env GITEA_TOKEN=mosaic-token GITEA_URL=https://git.mosaicstack.dev "$SCRIPT_DIR/issue-close.sh" -i 536
|
||||
|
||||
Reference in New Issue
Block a user