Skip to content

Business operating system for Claude Code — 57 skills, 21 agents, smart daemon. Unified inbox (WhatsApp/Email/Slack/Telegram), autonomous PR merge, full-AWS monitoring, revenue (Stripe+RevenueCat), e-commerce (Shopify), marketing (Klaviyo/Meta/GA4), voice (Bland/ElevenLabs), APM (Datadog/NewRelic/OTEL), YOLO mode.

test(reauth): cover profile-first reauth, and bump releases from the published version (#870)

Aurora Capital7965bb81b95c
diff --git a/claude-ops/bin/ops-release b/claude-ops/bin/ops-release
index 8d6110bb..9c73962d 100755
--- a/claude-ops/bin/ops-release
+++ b/claude-ops/bin/ops-release
@@ -239,8 +239,49 @@ wait_for_release_ci() {
return 1
}
-CUR="$(jq -r '.version' "$PLUGIN_JSON")"
-[[ "$CUR" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "ops-release: current version '$CUR' is not semver" >&2; exit 1; }
+# ----- version base -----
+# Bump from what is PUBLISHED, never from whatever this checkout happens to
+# hold. Running from a stale branch or a feature worktree would otherwise take
+# that branch's older number as the base and cut a release that moves the
+# version backwards. Base = highest of (checkout, origin/main, newest tag).
+PLUGIN_JSON_REL="${PLUGIN_JSON#"$REPO_ROOT"/}"
+
+local_ver="$(jq -r '.version // empty' "$PLUGIN_JSON")"
+[[ "$local_ver" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "ops-release: checkout version '$local_ver' is not semver" >&2; exit 1; }
+
+if ! git -C "$REPO_ROOT" fetch origin --quiet 2>/dev/null; then
+ echo "ops-release: git fetch failed — reading the published version over the API" >&2
+fi
+
+main_ver="$(git -C "$REPO_ROOT" show "origin/main:$PLUGIN_JSON_REL" 2>/dev/null | jq -r '.version // empty' 2>/dev/null || true)"
+if [ -z "$main_ver" ]; then
+ main_ver="$(gh api -H 'Accept: application/vnd.github.raw' \
+ "repos/$GH_REPO/contents/$PLUGIN_JSON_REL?ref=main" 2>/dev/null \
+ | jq -r '.version // empty' 2>/dev/null || true)"
+fi
+
+# Never guess the base. A stale or unreadable origin/main is exactly the case
+# this block exists to catch, so refuse rather than fall back to the checkout.
+if [[ ! "$main_ver" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ echo "ops-release: cannot read the published version from origin/main (git fetch and API both failed)." >&2
+ echo "ops-release: refusing to release from an unverified base — it could cut a regressive version." >&2
+ exit 1
+fi
+
+# Local tags only ever raise the base, so a stale tag list cannot lower it.
+tag_ver="$(git -C "$REPO_ROOT" tag --list 'v[0-9]*' 2>/dev/null | sed 's/^v//' \
+ | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1 || true)"
+
+CUR="$local_ver"
+for candidate in "$main_ver" "$tag_ver"; do
+ [[ "$candidate" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || continue
+ CUR="$(printf '%s\n%s\n' "$CUR" "$candidate" | sort -V | tail -1)"
+done
+
+if [ "$CUR" != "$local_ver" ]; then
+ echo "ops-release: checkout says $local_ver but $CUR is already published${main_ver:+ (origin/main $main_ver)}${tag_ver:+ (tag v$tag_ver)}." >&2
+ echo "ops-release: bumping from $CUR so the release cannot go backwards." >&2
+fi
if [ -n "$explicit_ver" ]; then
NEW="$explicit_ver"
diff --git a/claude-ops/scripts/crsproxy-reauth/test_auto_reauth_profiles.py b/claude-ops/scripts/crsproxy-reauth/test_auto_reauth_profiles.py
new file mode 100644
index 00000000..3077a363
--- /dev/null
+++ b/claude-ops/scripts/crsproxy-reauth/test_auto_reauth_profiles.py
@@ -0,0 +1,240 @@
+#!/usr/bin/env python3
+"""test_auto_reauth_profiles.py — Unit tests for profile-first reauth.
+
+auto_reauth.trigger_reauth() picks between two reauth scripts: if
+reauth_seats.json maps a Browser Use Cloud profile to the account it runs
+bu_profile_reauth.py with -profile-id, otherwise it falls back to the
+email-based bu_reauth.py. That choice, the 2FA arguments it forwards, and
+the promise that neither the full email nor the full profile ID reaches the
+log had no coverage.
+
+Run: python3 test_auto_reauth_profiles.py
+"""
+
+import os
+import sys
+import unittest
+from unittest.mock import patch
+
+# Add parent directory to path so we can import the module
+sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
+
+import auto_reauth
+
+
+PROFILE_ID = "prof-0123456789abcdef-tail"
+
+
+def make_account(provider="claude", email=EMAIL, two_factor=None):
+ """Build the account dict trigger_reauth expects."""
+ account = {"provider": provider, "email": email, "reason": "expired"}
+ if two_factor is not None:
+ account["two_factor"] = two_factor
+ return account
+
+
+def seats_for(provider="claude", email=EMAIL, profile_id=PROFILE_ID):
+ return {"seats": [{"provider": provider, "email": email,
+ "profile_id": profile_id}]}
+
+
+class FakeProc:
+ def __init__(self, returncode=0):
+ self.returncode = returncode
+ self.stdout = ""
+ self.stderr = ""
+
+
+class TestFindSeat(unittest.TestCase):
+ """find_seat matches on provider AND email, never one alone."""
+
+ def test_matches_provider_and_email(self):
+ seat = auto_reauth.find_seat(seats_for(), "claude", EMAIL)
+ self.assertIsNotNone(seat)
+ self.assertEqual(seat["profile_id"], PROFILE_ID)
+
+ def test_same_email_different_provider_does_not_match(self):
+ # One person can hold seats on several providers; matching on email
+ # alone would reauth the wrong provider's profile.
+ self.assertIsNone(auto_reauth.find_seat(seats_for(), "xai", EMAIL))
+
+ def test_same_provider_different_email_does_not_match(self):
+ self.assertIsNone(
+ auto_reauth.find_seat(seats_for(), "claude", "[email protected]"))
+
+ def test_missing_seats_key_returns_none(self):
+ self.assertIsNone(auto_reauth.find_seat({}, "claude", EMAIL))
+
+
+class TestTriggerReauthScriptChoice(unittest.TestCase):
+ """A mapped seat selects the profile script; no seat falls back to email."""
+
+ def _run(self, account, seats, env=None):
+ env = env or {"GOG_ACCOUNT": "[email protected]"}
+ with patch.object(auto_reauth, "subprocess") as mock_sub:
+ mock_sub.run.return_value = FakeProc(0)
+ ok, msg = auto_reauth.trigger_reauth(account, env, seats)
+ cmd = mock_sub.run.call_args[0][0]
+ return ok, msg, cmd
+
+ def test_mapped_seat_uses_profile_script(self):
+ ok, msg, cmd = self._run(make_account(), seats_for())
+ self.assertTrue(ok)
+ self.assertIn("profile", msg)
+ self.assertIn(auto_reauth.PROFILE_REAUTH_SCRIPT, cmd)
+ self.assertNotIn(auto_reauth.REAUTH_SCRIPT, cmd)
+ self.assertIn("-profile-id", cmd)
+ self.assertEqual(cmd[cmd.index("-profile-id") + 1], PROFILE_ID)
+
+ def test_unmapped_account_falls_back_to_email_script(self):
+ ok, msg, cmd = self._run(make_account(), {"seats": []})
+ self.assertTrue(ok)
+ self.assertIn("email", msg)
+ self.assertIn(auto_reauth.REAUTH_SCRIPT, cmd)
+ self.assertNotIn(auto_reauth.PROFILE_REAUTH_SCRIPT, cmd)
+ self.assertNotIn("-profile-id", cmd)
+
+ def test_seat_without_profile_id_falls_back(self):
+ # A seat row can exist with the profile field not yet filled in.
+ seats = {"seats": [{"provider": "claude", "email": EMAIL}]}
+ _, msg, cmd = self._run(make_account(), seats)
+ self.assertIn("email", msg)
+ self.assertIn(auto_reauth.REAUTH_SCRIPT, cmd)
+
+ def test_seats_none_falls_back(self):
+ env = {"GOG_ACCOUNT": "[email protected]"}
+ with patch.object(auto_reauth, "subprocess") as mock_sub:
+ mock_sub.run.return_value = FakeProc(0)
+ auto_reauth.trigger_reauth(make_account(), env, None)
+ cmd = mock_sub.run.call_args[0][0]
+ self.assertIn(auto_reauth.REAUTH_SCRIPT, cmd)
+
+
+class TestTriggerReauthGogAccount(unittest.TestCase):
+ """Claude verification mail lands in a central inbox, not the account."""
+
+ def _cmd(self, account, env):
+ with patch.object(auto_reauth, "subprocess") as mock_sub:
+ mock_sub.run.return_value = FakeProc(0)
+ auto_reauth.trigger_reauth(account, env, {"seats": []})
+ return mock_sub.run.call_args[0][0]
+
+ def test_claude_polls_the_central_inbox(self):
+ cmd = self._cmd(make_account("claude"),
+ {"GOG_ACCOUNT": "[email protected]"})
+ self.assertEqual(cmd[cmd.index("-gog-account") + 1],
+
+ def test_claude_without_gog_account_falls_back_to_own_address(self):
+ cmd = self._cmd(make_account("claude"), {})
+ self.assertEqual(cmd[cmd.index("-gog-account") + 1], EMAIL)
+
+ def test_other_providers_poll_their_own_address(self):
+ cmd = self._cmd(make_account("xai"),
+ {"GOG_ACCOUNT": "[email protected]"})
+ self.assertEqual(cmd[cmd.index("-gog-account") + 1], EMAIL)
+
+
+class TestTriggerReauthTwoFactorArgs(unittest.TestCase):
+ """2FA arguments are forwarded only when a method is configured."""
+
+ def _cmd(self, two_factor, seats=None):
+ with patch.object(auto_reauth, "subprocess") as mock_sub:
+ mock_sub.run.return_value = FakeProc(0)
+ auto_reauth.trigger_reauth(
+ make_account(two_factor=two_factor),
+ {"GOG_ACCOUNT": "[email protected]"},
+ seats if seats is not None else {"seats": []})
+ return mock_sub.run.call_args[0][0]
+
+ def test_no_two_factor_block_omits_the_flags(self):
+ self.assertNotIn("-two-factor-method", self._cmd(None))
+
+ def test_method_none_omits_the_flags(self):
+ self.assertNotIn("-two-factor-method", self._cmd({"method": "none"}))
+
+ def test_onepassword_totp_forwards_vault_item_and_field(self):
+ cmd = self._cmd({
+ "method": "onepassword_totp",
+ "op_vault_id": "vault-1",
+ "op_item_id": "item-1",
+ "op_field": "one-time password",
+ })
+ self.assertEqual(cmd[cmd.index("-two-factor-method") + 1],
+ "onepassword_totp")
+ self.assertEqual(cmd[cmd.index("-op-vault-id") + 1], "vault-1")
+ self.assertEqual(cmd[cmd.index("-op-item-id") + 1], "item-1")
+ self.assertEqual(cmd[cmd.index("-op-field") + 1], "one-time password")
+
+ def test_two_factor_args_also_reach_the_profile_script(self):
+ cmd = self._cmd({"method": "onepassword_totp"}, seats_for())
+ self.assertIn(auto_reauth.PROFILE_REAUTH_SCRIPT, cmd)
+ self.assertIn("-two-factor-method", cmd)
+
+
+class TestTriggerReauthDoesNotLeak(unittest.TestCase):
+ """The docstring promises masked emails and a truncated profile ID."""
+
+ def _logs(self, account, seats):
+ lines = []
+ with patch.object(auto_reauth, "subprocess") as mock_sub, \
+ patch.object(auto_reauth, "log", side_effect=lines.append):
+ mock_sub.run.return_value = FakeProc(0)
+ auto_reauth.trigger_reauth(
+ account, {"GOG_ACCOUNT": "[email protected]"}, seats)
+ return "\n".join(lines)
+
+ def test_full_email_is_never_logged(self):
+ for seats in (seats_for(), {"seats": []}):
+ out = self._logs(make_account(), seats)
+ self.assertNotIn(EMAIL, out)
+ self.assertIn(auto_reauth.mask_email(EMAIL), out)
+
+ def test_profile_id_is_truncated(self):
+ out = self._logs(make_account(), seats_for())
+ self.assertNotIn(PROFILE_ID, out)
+ self.assertIn(PROFILE_ID[:12], out)
+
+ def test_subprocess_output_is_never_logged(self):
+ lines = []
+ with patch.object(auto_reauth, "subprocess") as mock_sub, \
+ patch.object(auto_reauth, "log", side_effect=lines.append):
+ proc = FakeProc(1)
+ proc.stdout = "SENSITIVE-STDOUT-TOKEN"
+ proc.stderr = "SENSITIVE-STDERR-TOKEN"
+ mock_sub.run.return_value = proc
+ auto_reauth.trigger_reauth(make_account(), {}, {"seats": []})
+ out = "\n".join(lines)
+ self.assertNotIn("SENSITIVE-STDOUT-TOKEN", out)
+ self.assertNotIn("SENSITIVE-STDERR-TOKEN", out)
+
+
+class TestTriggerReauthExitCodes(unittest.TestCase):
+ """Exit code 2 is a human checkpoint, not a generic failure."""
+
+ def _result(self, returncode):
+ with patch.object(auto_reauth, "subprocess") as mock_sub:
+ mock_sub.run.return_value = FakeProc(returncode)
+ return auto_reauth.trigger_reauth(
+ make_account(), {"GOG_ACCOUNT": "[email protected]"},
+ seats_for())
+
+ def test_zero_succeeds(self):
+ ok, msg = self._result(0)
+ self.assertTrue(ok)
+ self.assertIn("succeeded", msg)
+
+ def test_two_reports_a_captcha_checkpoint(self):
+ ok, msg = self._result(2)
+ self.assertFalse(ok)
+ self.assertIn("checkpoint", msg)
+
+ def test_other_nonzero_is_a_plain_failure(self):
+ ok, msg = self._result(1)
+ self.assertFalse(ok)
+ self.assertIn("exit 1", msg)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/claude-ops/tests/run-all.sh b/claude-ops/tests/run-all.sh
index da4345e6..635471f2 100755
--- a/claude-ops/tests/run-all.sh
+++ b/claude-ops/tests/run-all.sh
@@ -56,6 +56,7 @@ run_suite "$TESTS_DIR/test-template.sh"
run_suite "$TESTS_DIR/test-claude-md.sh"
run_suite "$TESTS_DIR/test-plugin-validate.sh"
run_suite "$TESTS_DIR/test-hermes-plugin.sh"
+run_suite "$TESTS_DIR/test-crsproxy-reauth.sh"
run_suite "$TESTS_DIR/test-no-secrets.sh"
run_suite "$TESTS_DIR/test-agent-teams.sh"
run_suite "$TESTS_DIR/test-pocket-env-broker.sh"
diff --git a/claude-ops/tests/test-crsproxy-reauth.sh b/claude-ops/tests/test-crsproxy-reauth.sh
new file mode 100755
index 00000000..9ff4b170
--- /dev/null
+++ b/claude-ops/tests/test-crsproxy-reauth.sh
@@ -0,0 +1,59 @@
+#!/usr/bin/env bash
+# test-crsproxy-reauth.sh — run the cliproxy reauth Python unit tests
+#
+# The scripts/crsproxy-reauth/test_*.py files existed but no suite ran them,
+# so a break in the reauth path only showed up on the hub. This wraps them
+# so run-all.sh (and CI) covers them like every other suite.
+set -euo pipefail
+
+PLUGIN_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+REAUTH_DIR="$PLUGIN_ROOT/scripts/crsproxy-reauth"
+
+pass=0
+fail=0
+ok() { echo " PASS: $1"; pass=$((pass + 1)); }
+err() { echo " FAIL: $1"; fail=$((fail + 1)); }
+
+echo "Checking: crsproxy-reauth"
+echo ""
+
+if [[ ! -d "$REAUTH_DIR" ]]; then
+ err "scripts/crsproxy-reauth missing"
+ echo ""
+ echo "Passed: $pass Failed: $fail"
+ exit 1
+fi
+
+if ! command -v python3 >/dev/null 2>&1; then
+ echo " SKIP: python3 not available"
+ echo ""
+ echo "Passed: $pass Failed: $fail"
+ exit 0
+fi
+
+# Keep __pycache__ out of the checkout; a stray cache dir trips the
+# public-cleanliness and no-secrets suites.
+PYCACHE="$(mktemp -d)"
+trap 'rm -rf "$PYCACHE"' EXIT
+export PYTHONPYCACHEPREFIX="$PYCACHE"
+export PYTHONDONTWRITEBYTECODE=1
+
+count=0
+while IFS= read -r t; do
+ count=$((count + 1))
+ name="$(basename "$t")"
+ if output="$(cd "$REAUTH_DIR" && python3 "$name" 2>&1)"; then
+ ok "$name"
+ else
+ err "$name"
+ echo "$output" | tail -20 | sed 's/^/ /'
+ fi
+done < <(find "$REAUTH_DIR" -maxdepth 1 -name 'test_*.py' | sort)
+
+if [[ "$count" -eq 0 ]]; then
+ err "no test_*.py found in scripts/crsproxy-reauth"
+fi
+
+echo ""
+echo "Passed: $pass Failed: $fail"
+[[ "$fail" -eq 0 ]]