Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix: centralize local e2e admin credential resolution
Alfredo Lopezc80e04c9c949
diff --git a/Makefile b/Makefileindex 720b8e7f2..0c3a64b87 100644--- a/Makefile+++ b/Makefile@@ -690,9 +690,8 @@ minikube-db-reset: ## Reset control-api postgres (re-enables first-time admin se@echo "DB reset complete. First-time admin setup is available again.".PHONY: minikube-seed-test-data-minikube-seed-test-data: ## Seed E2E user + agent + context on minikube via admin API (idempotent; default password: changeme123!)- @PASS=$${TEST_ADMIN_PASSWORD:-$${ADMIN_PASSWORD:-changeme123!}}; \- CONTEXT=$(MINIKUBE_PROFILE) ADMIN_PASSWORD=$$PASS bash scripts/e2e/seed-e2e-data.sh+minikube-seed-test-data: ## Seed E2E user + agent + context via canonical-root credentials (local fallback only when unset)+ @CONTEXT=$(MINIKUBE_PROFILE) bash scripts/e2e/seed-e2e-data.sh.PHONY: minikube-seed-sandbox-ui-test-dataminikube-seed-sandbox-ui-test-data: ## Seed default sandbox-ui nginx fixture on minikubediff --git a/scripts/e2e/admin-credentials.sh b/scripts/e2e/admin-credentials.shnew file mode 100644index 000000000..565ad4c2f--- /dev/null+++ b/scripts/e2e/admin-credentials.sh@@ -0,0 +1,83 @@+#!/usr/bin/env bash+# Shared admin-credential resolution for local and E2E harnesses.+#+# Resolution is deliberately layer-first rather than variable-first:+# 1. canonical repository .env+# 2. explicit process environment+# 3. caller-supplied local fallback+#+# This prevents a stale inherited E2E_ADMIN_PASSWORD from shadowing the+# password that actually seeded the branch-owned cluster from the primary+# checkout. Values are returned to the caller only; this helper never logs or+# persists credential material.++if ! declare -F dotenv_canonical_root >/dev/null 2>&1 ||+ ! declare -F dotenv_load_file >/dev/null 2>&1; then+ printf '%s\n' 'admin-credentials.sh requires scripts/e2e/load-dotenv.sh to be sourced first' >&2+ return 1+fi++e2e_first_nonempty_admin_value() {+ local key+ for key in "$@"; do+ if [[ -n "${!key:-}" ]]; then+ printf '%s' "${!key}"+ return 0+ fi+ done+ return 1+}++e2e_admin_password_from_dotenv() {+ local env_file="${1:?dotenv file path is required}"+ (+ unset E2E_ADMIN_PASSWORD ADMIN_PASSWORD TEST_ADMIN_PASSWORD ADMIN_PASS+ dotenv_load_file "${env_file}" || exit 2+ # ADMIN_PASSWORD is the bootstrap source of truth in the canonical repo;+ # TEST/E2E aliases remain accepted for older local configurations.+ e2e_first_nonempty_admin_value \+ ADMIN_PASSWORD TEST_ADMIN_PASSWORD E2E_ADMIN_PASSWORD ADMIN_PASS+ )+}++e2e_resolve_admin_password() {+ local repo_root="${1:?repository root is required}"+ local fallback="${2:-}"+ local env_file value++ env_file="$(dotenv_canonical_root "${repo_root}")"+ if [[ -n "${env_file}" ]]; then+ if value="$(e2e_admin_password_from_dotenv "${env_file}")"; then+ printf '%s' "${value}"+ return 0+ else+ case "$?" in+ 1) : ;;+ *) return 1 ;;+ esac+ fi+ fi++ # Without a canonical value, the test-specific process override is the most+ # precise caller intent, followed by the bootstrap and compatibility names.+ if value="$(e2e_first_nonempty_admin_value \+ E2E_ADMIN_PASSWORD ADMIN_PASSWORD TEST_ADMIN_PASSWORD ADMIN_PASS)"; then+ printf '%s' "${value}"+ return 0+ fi++ if [[ -n "${fallback}" ]]; then+ printf '%s' "${fallback}"+ return 0+ fi+ return 1+}++# Write credentials as two NUL-delimited fields for a stdin consumer. Keeping+# this byte-level contract in one helper prevents shell escape typos (for+# example, an octal escape followed by an identifier) from corrupting login+# input while keeping both values out of argv.+e2e_write_nul_credentials() {+ local username="${1-}" password="${2-}"+ printf '%s\0%s' "${username}" "${password}"+}diff --git a/scripts/e2e/e2e-plugin-workload-sdk.sh b/scripts/e2e/e2e-plugin-workload-sdk.shindex 677151e08..e5a689926 100755--- a/scripts/e2e/e2e-plugin-workload-sdk.sh+++ b/scripts/e2e/e2e-plugin-workload-sdk.sh@@ -23,17 +23,21 @@set -euo pipefailSCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"# Resolve the canonical repository environment before sourcing e2e-lib. A# secondary worktree normally has no .env of its own; the seeded credentials# and provider keys live in the primary checkout. Explicit process values are-# intentionally preserved, then the test-specific defaults are applied below:+# loaded for general E2E configuration. Admin credentials use the stricter+# shared resolver below so the primary checkout remains authoritative:#-# process environment > canonical root .env > safe test defaults+# canonical root .env > process environment > safe local test fallback## shellcheck source=scripts/e2e/load-dotenv.shsource "${SCRIPT_DIR}/load-dotenv.sh"-dotenv_load_canonical_root "$(cd "${SCRIPT_DIR}/../.." && pwd)"+dotenv_load_canonical_root "${REPO_ROOT}"+# shellcheck source=scripts/e2e/admin-credentials.sh+source "${SCRIPT_DIR}/admin-credentials.sh"export RECIPE_NS="${RECIPE_NS:-sandbox-recipes}"# shellcheck source=e2e-lib.shsource "${SCRIPT_DIR}/e2e-lib.sh"@@ -44,6 +48,20 @@ die() {exit 1}+is_local_default_operator_context() {+ local context=${1:-}+ if [[ -z "$context" ]]; then+ context="$(current_e2e_context || true)"+ fi+ case "$context" in+ clerum-test) return 0 ;;+ clerum-codex-* | clerum-cursor-* | clerum-detached-*)+ is_branch_scoped_e2e_context "$context"+ ;;+ *) return 1 ;;+ esac+}+RECIPE_NAME="e2e-plugin-workload-sdk"WORKLOAD_ID="sdk-caller"EVENT_TYPE="e2e.test.notification"@@ -106,8 +124,6 @@ fiE2E_PROMPT_FALLBACK_TARGET_REF="${E2E_PROMPT_FALLBACK_TARGET_REF:-fallback-${E2E_PROMPT_FALLBACK_PROVIDER}}"E2E_PROMPT_FALLBACK_CREDENTIAL_SLOT="${E2E_PROMPT_FALLBACK_CREDENTIAL_SLOT:-}"E2E_ADMIN_TOKEN="${E2E_ADMIN_TOKEN:-}"-# Seeded by scripts/e2e/seed-e2e-data.sh (copies ADMIN_PASSWORD into test users).-E2E_DESKTOP_PASSWORD="${E2E_DESKTOP_PASSWORD:-${ADMIN_PASSWORD:-changeme123!}}"load_branch_profile_ports() {local ctx="${KUBECONTEXT:-${E2E_K8S_CONTEXT:-}}"@@ -125,6 +141,15 @@ load_branch_profile_ports() {fi}load_branch_profile_ports+# The recipe and Desktop fixture users are seeded from this same resolved+# credential. The known fallback is local-only and is selected only when none+# of the supported admin variables exists in the canonical .env or process.+LOCAL_ADMIN_PASSWORD_FALLBACK=""+if is_local_default_operator_context; then+ LOCAL_ADMIN_PASSWORD_FALLBACK="$(printf '%s%s' 'changeme123' '!')"+fi+RESOLVED_ADMIN_PASSWORD="$(e2e_resolve_admin_password "${REPO_ROOT}" "${LOCAL_ADMIN_PASSWORD_FALLBACK}" || true)"+E2E_DESKTOP_PASSWORD="${E2E_DESKTOP_PASSWORD:-${RESOLVED_ADMIN_PASSWORD}}"E2E_CONTROL_API_URL="${E2E_CONTROL_API_URL:-${CONTROL_API_URL:-${CONTROL_API_BASE_URL:-http://127.0.0.1:8090}}}"E2E_EXTERNAL_REST_API_URL="${E2E_EXTERNAL_REST_API_URL:-${EXTERNAL_REST_API_URL:-${EXTERNAL_REST_API_BASE_URL:-http://127.0.0.1:8091}}}"E2E_RPC_PROXY_URL="${E2E_RPC_PROXY_URL:-${RPC_PROXY_URL:-${RPC_PROXY_BASE_URL:-http://127.0.0.1:8094}}}"@@ -449,28 +474,13 @@ control_api_pod() {|| ready_pod_name "$CONTROL_NS" "app.kubernetes.io/name=control-api" 2>/dev/null}-is_local_default_operator_context() {- local context=${1:-}- if [[ -z "$context" ]]; then- context="$(current_e2e_context || true)"- fi- case "$context" in- clerum-test) return 0 ;;- clerum-codex-* | clerum-cursor-* | clerum-detached-*)- is_branch_scoped_e2e_context "$context"- ;;- *) return 1 ;;- esac-}-operator_admin_password() {- if [[ -n "${E2E_ADMIN_PASSWORD:-}" ]]; then printf '%s' "$E2E_ADMIN_PASSWORD"; return 0; fi- if [[ -n "${ADMIN_PASSWORD:-}" ]]; then printf '%s' "$ADMIN_PASSWORD"; return 0; fi- if [[ -n "${ADMIN_PASS:-}" ]]; then printf '%s' "$ADMIN_PASS"; return 0; fi- if [[ -n "${TEST_ADMIN_PASSWORD:-}" ]]; then printf '%s' "$TEST_ADMIN_PASSWORD"; return 0; fi+ if [[ -n "${RESOLVED_ADMIN_PASSWORD:-}" ]]; then+ printf '%s' "${RESOLVED_ADMIN_PASSWORD}"+ return 0+ fiis_local_default_operator_context || return 1- printf '%s%s' 'changeme123' '!'- return 0+ e2e_resolve_admin_password "${REPO_ROOT}" "$(printf '%s%s' 'changeme123' '!')"}ensure_operator_session() {@@ -485,7 +495,7 @@ ensure_operator_session() {# NUL-delimited stdin keeps both credentials out of local and remote argv.response="$(- printf '%s\0%s' "$admin_username" "$admin_password" \+ e2e_write_nul_credentials "$admin_username" "$admin_password" \| kctl exec -i "$pod" -n "$CONTROL_NS" -- node -e 'const chunks = []process.stdin.on("data", chunk => chunks.push(Buffer.from(chunk)))diff --git a/scripts/e2e/load-dotenv.sh b/scripts/e2e/load-dotenv.shindex 73bba1c0c..35f3694bf 100644--- a/scripts/e2e/load-dotenv.sh+++ b/scripts/e2e/load-dotenv.sh@@ -45,24 +45,29 @@ dotenv_load_file() {value="${value:1:${#value}-2}"fiprintf -v "${key}" '%s' "${value}"- export "${key}"+ export "${key?}"done < "${env_file}"}dotenv_canonical_root() {local repo_root="${1:?repository root is required}"local common_dir main_repo_dir- if [[ -f "${repo_root}/.env" ]]; then- printf '%s\n' "${repo_root}/.env"+ common_dir="$(git -C "${repo_root}" rev-parse --git-common-dir 2>/dev/null || true)"+ if [[ -n "${common_dir}" ]]; then+ case "${common_dir}" in+ /*) main_repo_dir="$(cd "${common_dir}/.." && pwd)" ;;+ *) main_repo_dir="$(cd "${repo_root}/${common_dir}/.." && pwd)" ;;+ esac+ if [[ -f "${main_repo_dir}/.env" ]]; then+ printf '%s\n' "${main_repo_dir}/.env"+ return 0+ fi+ # A Git worktree intentionally does not fall back to its own .env. The+ # primary checkout is the canonical local source of truth, and accepting a+ # worktree-local file would reintroduce per-lane credential drift.return 0fi- common_dir="$(git -C "${repo_root}" rev-parse --git-common-dir 2>/dev/null || true)"- if [[ -z "${common_dir}" ]]; then return 0; fi- case "${common_dir}" in- /*) main_repo_dir="$(cd "${common_dir}/.." && pwd)" ;;- *) main_repo_dir="$(cd "${repo_root}/${common_dir}/.." && pwd)" ;;- esac- [[ -f "${main_repo_dir}/.env" ]] && printf '%s\n' "${main_repo_dir}/.env"+ [[ -f "${repo_root}/.env" ]] && printf '%s\n' "${repo_root}/.env"}dotenv_load_canonical_root() {diff --git a/scripts/e2e/seed-e2e-data.sh b/scripts/e2e/seed-e2e-data.shindex 5090b807b..421de711d 100755--- a/scripts/e2e/seed-e2e-data.sh+++ b/scripts/e2e/seed-e2e-data.sh@@ -54,6 +54,14 @@set -euo pipefail+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"+# shellcheck source=scripts/e2e/load-dotenv.sh+source "${SCRIPT_DIR}/load-dotenv.sh"+dotenv_load_canonical_root "${REPO_ROOT}"+# shellcheck source=scripts/e2e/admin-credentials.sh+source "${SCRIPT_DIR}/admin-credentials.sh"+# ─── Config (all overridable) ──────────────────────────────────────────CONTEXT="${CONTEXT:-$(kubectl config current-context)}"KC="kubectl --context=${CONTEXT}"@@ -91,7 +99,7 @@ CONTEXT_ID="${E2E_CONTEXT_ID:-context1}"ADMIN_USERNAME="${ADMIN_USERNAME:-admin}"ADMIN_EMAIL="${ADMIN_EMAIL:[email protected]}"-ADMIN_PASSWORD="${ADMIN_PASSWORD:-}"+ADMIN_PASSWORD="$(e2e_resolve_admin_password "${REPO_ROOT}" || true)"DESKTOP_LOGIN_CREDENTIAL="$ADMIN_PASSWORD"SEED_DESKTOP_LOGIN="${E2E_SEED_DESKTOP_PASSWORDS:-}"SEED_PLUGIN_SDK_DEMO_GRANTS="${E2E_SEED_PLUGIN_SDK_DEMO_GRANTS:-}"diff --git a/scripts/minikube/full-setup.sh b/scripts/minikube/full-setup.shindex 65d53a5ae..b3c41baac 100755--- a/scripts/minikube/full-setup.sh+++ b/scripts/minikube/full-setup.sh@@ -29,6 +29,10 @@ set -euo pipefailSCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"PROJECT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"+# shellcheck source=scripts/e2e/load-dotenv.sh+source "${PROJECT_DIR}/scripts/e2e/load-dotenv.sh"+# shellcheck source=scripts/e2e/admin-credentials.sh+source "${PROJECT_DIR}/scripts/e2e/admin-credentials.sh"# ── Color helpers ──────────────────────────────────────────────────────RED='\033[0;31m'@@ -222,38 +226,20 @@ case "${SEED_PROFILE}" inesac# ── Load .env ──────────────────────────────────────────────────────────-# When running from a git worktree (.claude/worktrees/*/), PROJECT_DIR points-# to the worktree checkout which does NOT contain .env — the file lives in the-# main repo. `git rev-parse --git-common-dir` returns the shared .git dir-# (main/.git for worktrees, same-as-git-dir for normal checkouts); its parent-# is the main repo root.-ENV_FILE=""-if [ -f "${PROJECT_DIR}/.env" ]; then- ENV_FILE="${PROJECT_DIR}/.env"-else- GIT_COMMON_DIR="$(cd "$PROJECT_DIR" && git rev-parse --git-common-dir 2>/dev/null || echo "")"- if [ -n "$GIT_COMMON_DIR" ]; then- # git-common-dir can be relative — resolve it against PROJECT_DIR- case "$GIT_COMMON_DIR" in- /*) MAIN_REPO_DIR="$(cd "${GIT_COMMON_DIR}/.." && pwd)" ;;- *) MAIN_REPO_DIR="$(cd "${PROJECT_DIR}/${GIT_COMMON_DIR}/.." && pwd)" ;;- esac- if [ -f "${MAIN_REPO_DIR}/.env" ]; then- ENV_FILE="${MAIN_REPO_DIR}/.env"- fi- fi-fi+# Worktrees resolve through git-common-dir to the primary checkout. Dotenv is+# parsed as data (never sourced as shell code), and admin aliases use the+# shared layer-first contract: canonical .env, then process, then local fallback.+ENV_FILE="$(dotenv_canonical_root "${PROJECT_DIR}")"if [ -n "$ENV_FILE" ]; thenlog "Loading .env from ${ENV_FILE}..."- set -a- # shellcheck disable=SC1090- source "$ENV_FILE"- set +a+ dotenv_load_file "$ENV_FILE"ok ".env loaded"elsewarn "No .env found in ${PROJECT_DIR} or main repo — channel-reader + LLM secrets will use placeholders"fi+ADMIN_PASSWORD="$(e2e_resolve_admin_password "${PROJECT_DIR}" || true)"+export ADMIN_PASSWORDPROFILE="${MINIKUBE_PROFILE:-clerum-test}"KC="kubectl --context=${PROFILE}"@@ -406,8 +392,8 @@ fi# defer, the bootstrap POST fails with "password must be between 8 and 256# characters" only AFTER image builds + deploy, and the admin account may still# hold the publicly-known default. Keep these bounds in sync with auth.ts. Scope-# to the minimal profile: e2e force-assigns ADMIN_PASSWORD later (search-# E2E_ADMIN_PASSWORD), so a short .env value there is irrelevant.+# to the minimal profile: the E2E profile may use its local-only fallback when+# no canonical or explicit admin credential is configured.if [ "$SEED_PROFILE" = "minimal" ] && [ -n "${ADMIN_PASSWORD:-}" ]; thenpw_len=${#ADMIN_PASSWORD}if [ "$pw_len" -lt 8 ] || [ "$pw_len" -gt 256 ]; then@@ -419,7 +405,11 @@ if [ "$SEED_PROFILE" = "minimal" ] && [ -n "${ADMIN_PASSWORD:-}" ]; thenexit 1fifi-ok "ADMIN_PASSWORD is set"+if [ -n "${ADMIN_PASSWORD:-}" ]; then+ ok "ADMIN_PASSWORD resolved from the canonical environment contract"+else+ ok "No admin password configured; the E2E-only local fallback will be used at seed time"+fi# ======================================================================# Step 2: Cluster@@ -1113,22 +1103,17 @@ fi# ======================================================================step_header 10 $TOTAL_STEPS "Seed Test User"-# The e2e profile reproduces today's inputs exactly: tests/e2e/testUser.ts pins-# [email protected], and ~26 control-ui/e2e specs log in as admin/changeme123!.-# The minimal profile must not seed anything named test*.+# The e2e profile seeds the test identities used by the Desktop and Control UI+# journeys. The minimal profile must not seed anything named test*.if [ "$SEED_PROFILE" = "e2e" ]; thenSEED_USER_DEFAULT_EMAIL="[email protected]"SEED_USER_DEFAULT_NAME="Test User"- # Force-assign, do NOT defer to .env via `: "${ADMIN_PASSWORD:=...}"`.- # .env is sourced with `set -a` above, and this branch requires users to- # set a real ADMIN_PASSWORD there — under the `:=` form that real password- # would win and override the e2e pin. The E2E specs never read .env: they- # hardcode changeme123! (or read ADMIN_PASS), so a leaked .env password- # would seed admin/<real password> while the specs still send- # admin/changeme123!, turning the whole E2E lane red. E2E_ADMIN_PASSWORD- # remains the deliberate escape hatch for callers that need a non-default- # e2e password.- ADMIN_PASSWORD="${E2E_ADMIN_PASSWORD:-changeme123!}"+ # ADMIN_PASSWORD was resolved once above. Use the known local test fallback+ # only when neither the canonical .env nor the process configured any admin+ # alias; never replace a real seeded credential.+ if [ -z "${ADMIN_PASSWORD:-}" ]; then+ ADMIN_PASSWORD="$(printf '%s%s' 'changeme123' '!')"+ fielse# Minimal: the Control-UI admin IS the sole Desktop App member — no separate# seeded user. Point both the admin-bootstrap email and the seeded desktop@@ -1255,13 +1240,13 @@ echo -e " ${BOLD}Already done by setup:${NC}"# so this else branch is reachable only via the e2e soft-fail path).if [ "${SEED_PROFILE:-}" = "e2e" ]; thenif [ "${SEED_USER_OK:-true}" = "true" ]; then- echo -e " ${GREEN}✓${NC} JWT keys + admin bootstrap (admin / changeme123!)"+ echo -e " ${GREEN}✓${NC} JWT keys + admin bootstrap (resolved admin credential)"else- echo -e " ${RED}✗${NC} Admin bootstrap NOT confirmed — Step 10 (Seed Test User) failed; admin/changeme123! may not be live"+ echo -e " ${RED}✗${NC} Admin bootstrap NOT confirmed — Step 10 (Seed Test User) failed"fielseif [ "${SEED_USER_OK:-true}" = "true" ]; then- echo -e " ${GREEN}✓${NC} JWT keys + admin bootstrap (admin / your ADMIN_PASSWORD from .env)"+ echo -e " ${GREEN}✓${NC} JWT keys + admin bootstrap (resolved admin credential)"elseecho -e " ${RED}✗${NC} Admin bootstrap NOT confirmed — Step 10 (Seed Test User) failed"fi@@ -1275,7 +1260,7 @@ if [ "${SEED_PROFILE:-}" = "e2e" ]; thenecho -e " ${GREEN}✓${NC} Workflow-trigger E2E recipes seeded"elseif [ "${SEED_USER_OK:-true}" = "true" ]; then- echo -e " ${GREEN}✓${NC} Owner user seeded (${SEED_USER_EMAIL} → chatllm + context1, password = your ADMIN_PASSWORD)"+ echo -e " ${GREEN}✓${NC} Owner user seeded (${SEED_USER_EMAIL} → chatllm + context1)"elseecho -e " ${RED}✗${NC} Owner user seed FAILED (${SEED_USER_EMAIL}) — check Step 10 output above"fidiff --git a/scripts/minikube/seed-test-data.sh b/scripts/minikube/seed-test-data.shindex 2f8304ea4..7cce07b59 100755--- a/scripts/minikube/seed-test-data.sh+++ b/scripts/minikube/seed-test-data.sh@@ -18,10 +18,22 @@ set -euo pipefailSCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"-: "${ADMIN_PASSWORD:=${TEST_ADMIN_PASSWORD:-changeme123!}}"+# shellcheck source=scripts/e2e/load-dotenv.sh+source "${REPO_ROOT}/scripts/e2e/load-dotenv.sh"+dotenv_load_canonical_root "${REPO_ROOT}"+# shellcheck source=scripts/e2e/admin-credentials.sh+source "${REPO_ROOT}/scripts/e2e/admin-credentials.sh": "${E2E_DEV_LOGIN_EMAIL:=${TEST_USER_EMAIL:-${DEV_EMAIL:[email protected]}}}": "${CONTEXT:=clerum-test}"+LOCAL_ADMIN_PASSWORD_FALLBACK=""+case "$CONTEXT" in+ clerum-test|clerum-codex-*|clerum-cursor-*|clerum-detached-*)+ LOCAL_ADMIN_PASSWORD_FALLBACK="$(printf '%s%s' 'changeme123' '!')"+ ;;+esac+ADMIN_PASSWORD="$(e2e_resolve_admin_password "${REPO_ROOT}" "${LOCAL_ADMIN_PASSWORD_FALLBACK}" || true)"+case "$CONTEXT" inclerum-test|clerum-codex-*|clerum-cursor-*|clerum-detached-*): "${ALLOWED_CONTEXTS:=$CONTEXT}"diff --git a/scripts/tests/test-plugin-workload-sdk-auth-bootstrap.sh b/scripts/tests/test-plugin-workload-sdk-auth-bootstrap.shindex 1d9762991..3aa790e98 100755--- a/scripts/tests/test-plugin-workload-sdk-auth-bootstrap.sh+++ b/scripts/tests/test-plugin-workload-sdk-auth-bootstrap.sh@@ -5,12 +5,18 @@ set -uROOT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"SCRIPT="$ROOT_DIR/scripts/e2e/e2e-plugin-workload-sdk.sh"E2E_LIB="$ROOT_DIR/scripts/e2e/e2e-lib.sh"+DOTENV_LIB="$ROOT_DIR/scripts/e2e/load-dotenv.sh"+ADMIN_CREDENTIAL_LIB="$ROOT_DIR/scripts/e2e/admin-credentials.sh"TMP_ROOT="$(mktemp -d)"trap 'rm -rf "$TMP_ROOT"' EXIT# shellcheck source-path=SCRIPTDIR# shellcheck source=../e2e/e2e-lib.shsource "$E2E_LIB"+# shellcheck source=../e2e/load-dotenv.sh+source "$DOTENV_LIB"+# shellcheck source=../e2e/admin-credentials.sh+source "$ADMIN_CREDENTIAL_LIB"FAIL=0@@ -23,11 +29,17 @@ fail() {# Load only the production auth helpers. Sourcing the complete E2E gate would# run cluster operations, while copying the functions here would let the test# drift from the behavior it is intended to protect.+awk '+ /^is_local_default_operator_context\(\)/ { capture = 1 }+ capture { print }+ capture && /^}/ { exit }+' "$SCRIPT" >"$TMP_ROOT/auth-helpers.sh"+awk '/^# ─── control-api admin helpers/ { capture = 1 }capture && /^# session_curl / { exit }capture { print }-' "$SCRIPT" >"$TMP_ROOT/auth-helpers.sh"+' "$SCRIPT" >>"$TMP_ROOT/auth-helpers.sh"# shellcheck source=/dev/nullsource "$TMP_ROOT/auth-helpers.sh"@@ -151,6 +163,124 @@ elsepass 'admin session material is not passed as a kubectl/node process argument'fi+assert_admin_resolution_contract() {+ local main_repo="$TMP_ROOT/main-repo"+ local worktree="$TMP_ROOT/branch-worktree"+ local canonical_main_repo+ local resolved++ git init -q -b main "$main_repo"+ git -C "$main_repo" config user.name 'E2E Contract Test'+ git -C "$main_repo" config user.email '[email protected]'+ printf '%s\n' fixture >"$main_repo/tracked.txt"+ git -C "$main_repo" add tracked.txt+ git -C "$main_repo" commit -q -m fixture+ git -C "$main_repo" worktree add -q -b credential-test "$worktree"+ canonical_main_repo="$(cd "$main_repo" && pwd -P)"++ printf '%s\n' \+ 'ADMIN_PASSWORD=canonical-fixture-value' \+ 'TEST_ADMIN_PASSWORD=canonical-secondary-value' \+ 'E2E_ADMIN_PASSWORD=canonical-e2e-alias-value' \+ >"$main_repo/.env"+ printf '%s\n' 'ADMIN_PASSWORD=worktree-decoy-value' >"$worktree/.env"++ if [[ "$(dotenv_canonical_root "$worktree")" == "$canonical_main_repo/.env" ]]; then+ pass 'worktree resolution prefers the primary checkout .env through git-common-dir'+ else+ fail 'worktree resolution did not find the primary checkout .env'+ fi++ # shellcheck disable=SC2034 # consumed through intentional indirect expansion+ E2E_ADMIN_PASSWORD='process-e2e-value'+ # shellcheck disable=SC2034 # consumed through intentional indirect expansion+ ADMIN_PASSWORD='process-admin-value'+ # shellcheck disable=SC2034 # consumed through intentional indirect expansion+ TEST_ADMIN_PASSWORD='process-test-value'+ resolved="$(e2e_resolve_admin_password "$worktree" 'fallback-value')"+ if [[ "$resolved" == 'canonical-fixture-value' ]]; then+ pass 'canonical .env wins over every explicit process alias'+ else+ fail 'canonical .env did not win over the process environment'+ fi++ printf '%s\n' 'TEST_ADMIN_PASSWORD=canonical-test-only' >"$main_repo/.env"+ resolved="$(e2e_resolve_admin_password "$worktree" 'fallback-value')"+ if [[ "$resolved" == 'canonical-test-only' ]]; then+ pass 'a canonical TEST_ADMIN_PASSWORD wins over an inherited E2E_ADMIN_PASSWORD'+ else+ fail 'canonical TEST_ADMIN_PASSWORD was shadowed by a process alias'+ fi++ rm -f "$main_repo/.env"+ resolved="$(e2e_resolve_admin_password "$worktree" 'fallback-value')"+ if [[ "$resolved" == 'process-e2e-value' ]]; then+ pass 'explicit aliases are used when the canonical .env has no admin value'+ else+ fail 'explicit alias precedence is incorrect without a canonical value'+ fi++ unset E2E_ADMIN_PASSWORD+ resolved="$(e2e_resolve_admin_password "$worktree" 'fallback-value')"+ if [[ "$resolved" == 'process-admin-value' ]]; then+ pass 'ADMIN_PASSWORD is retained when no higher-precedence value exists'+ else+ fail 'ADMIN_PASSWORD was overwritten by a lower-precedence value or fallback'+ fi++ unset ADMIN_PASSWORD TEST_ADMIN_PASSWORD ADMIN_PASS+ resolved="$(e2e_resolve_admin_password "$worktree" 'fallback-value')"+ if [[ "$resolved" == 'fallback-value' ]]; then+ pass 'the local fallback is used only when no configured value exists'+ else+ fail 'fallback resolution failed when every configured value was absent'+ fi+}++assert_nul_credential_transport() {+ local result+ result="$(+ e2e_write_nul_credentials 'fixture-admin' '007d8-fixture-value!' |+ node --no-warnings -e '+ const chunks = []+ process.stdin.on("data", chunk => chunks.push(Buffer.from(chunk)))+ process.stdin.on("end", () => {+ const input = Buffer.concat(chunks)+ const separator = input.indexOf(0)+ const secondSeparator = input.indexOf(0, separator + 1)+ const username = input.subarray(0, separator).toString("utf8")+ const password = input.subarray(separator + 1).toString("utf8")+ process.stdout.write(+ separator > 0 && secondSeparator === -1 &&+ username === "fixture-admin" && password === "007d8-fixture-value!"+ ? "ok"+ : "invalid"+ )+ })+ '+ )"+ if [[ "$result" == 'ok' ]]; then+ pass 'admin login handoff preserves exact credentials with one NUL delimiter'+ else+ fail 'admin login handoff corrupted the NUL-delimited credential payload'+ fi+}++assert_admin_resolution_contract+assert_nul_credential_transport++if grep -Fq 'e2e_write_nul_credentials "$admin_username" "$admin_password"' "$SCRIPT"; then+ pass 'Plugin Workload SDK login uses the shared NUL-safe transport helper'+else+ fail 'Plugin Workload SDK login bypasses the shared NUL-safe transport helper'+fi++if grep -Fq 'ADMIN_PASSWORD="${E2E_ADMIN_PASSWORD:-changeme123!}"' "$ROOT_DIR/scripts/minikube/full-setup.sh"; then+ fail 'full-setup still overwrites the canonical admin password with the fallback'+else+ pass 'full-setup no longer overwrites a configured admin password'+fi+if grep -Fq 'E2E_HARD_MAX_GATE_SECONDS=600' "$SCRIPT" &&grep -Fq 'E2E_HARD_MAX_PHASE_WAIT_SECONDS=180' "$SCRIPT" &&grep -Fq 'E2E_HARD_MAX_POLL_INTERVAL_SECONDS=5' "$SCRIPT" &&