- Setup wizard with auto-detection of OpenClaw paths and Claude CLI - Token sync watcher (inotifywait) for real-time credential updates - Auto-refresh trigger timer that runs Claude CLI every 30 min - Supports Claude CLI in Docker container or on host - Temporary ANTHROPIC_BASE_URL override for container environments - Anthropic model configuration for OpenClaw - Auth profile management (fixes key vs access field) - Systemd services and timers for both sync and trigger - Comprehensive documentation and troubleshooting guides - Re-authentication notification system Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
81 lines
2.2 KiB
Bash
Executable File
81 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# test-sync-flow.sh — Test that file-watch -> sync -> gateway flow works
|
|
# Triggers a fake file change and verifies the sync happens
|
|
|
|
set -uo pipefail
|
|
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
NC='\033[0m'
|
|
|
|
pass() { echo -e "${GREEN}[PASS]${NC} $*"; }
|
|
fail() { echo -e "${RED}[FAIL]${NC} $*"; }
|
|
|
|
echo ""
|
|
echo "Testing OAuth Token Sync Flow"
|
|
echo "=============================="
|
|
echo ""
|
|
|
|
# Find the source credentials file
|
|
SYNC_SCRIPT=$(which sync-oauth-token.sh 2>/dev/null || echo "/usr/local/bin/sync-oauth-token.sh")
|
|
if [ ! -f "$SYNC_SCRIPT" ]; then
|
|
fail "sync-oauth-token.sh not found at $SYNC_SCRIPT"
|
|
exit 1
|
|
fi
|
|
|
|
SOURCE_FILE=$(grep 'CLAUDE_CREDS_FILE=' "$SYNC_SCRIPT" | head -1 | cut -d'"' -f2)
|
|
OAUTH_FILE=$(grep 'OPENCLAW_OAUTH_FILE=' "$SYNC_SCRIPT" | head -1 | cut -d'"' -f2)
|
|
|
|
if [ ! -f "$SOURCE_FILE" ]; then
|
|
fail "Source file not found: $SOURCE_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Source: $SOURCE_FILE"
|
|
echo "Target: $OAUTH_FILE"
|
|
echo ""
|
|
|
|
# Record current oauth.json modification time
|
|
BEFORE_MTIME="none"
|
|
if [ -f "$OAUTH_FILE" ]; then
|
|
BEFORE_MTIME=$(stat -c %Y "$OAUTH_FILE" 2>/dev/null || stat -f %m "$OAUTH_FILE" 2>/dev/null)
|
|
fi
|
|
|
|
echo "1. Triggering file change (touch)..."
|
|
touch "$SOURCE_FILE"
|
|
|
|
echo "2. Waiting 15 seconds for sync to complete..."
|
|
sleep 15
|
|
|
|
# Check if oauth.json was updated
|
|
if [ -f "$OAUTH_FILE" ]; then
|
|
AFTER_MTIME=$(stat -c %Y "$OAUTH_FILE" 2>/dev/null || stat -f %m "$OAUTH_FILE" 2>/dev/null)
|
|
if [ "$AFTER_MTIME" != "$BEFORE_MTIME" ]; then
|
|
pass "oauth.json was updated (mtime changed)"
|
|
else
|
|
fail "oauth.json was NOT updated (mtime unchanged)"
|
|
fi
|
|
|
|
# Verify format
|
|
HAS_ACCESS=$(python3 -c "
|
|
import json
|
|
with open('$OAUTH_FILE') as f:
|
|
d = json.load(f)
|
|
print('yes' if d.get('anthropic', {}).get('access') else 'no')
|
|
" 2>/dev/null || echo "no")
|
|
|
|
if [ "$HAS_ACCESS" = "yes" ]; then
|
|
pass "oauth.json has correct format (anthropic.access present)"
|
|
else
|
|
fail "oauth.json has wrong format (missing anthropic.access)"
|
|
fi
|
|
else
|
|
fail "oauth.json does not exist after sync"
|
|
fi
|
|
|
|
echo ""
|
|
echo "3. Checking service logs..."
|
|
journalctl -u sync-oauth-token.service --since "1 minute ago" --no-pager -n 10 2>/dev/null || echo " (journalctl not available)"
|
|
echo ""
|
|
echo "Done."
|