AI default/tests: env-passed key, secure creation, harness install, isolated strict mocks
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QKxGW1raAWaqeU8WdHsMsp
This commit is contained in:
@@ -19,6 +19,17 @@ cleanup() {
|
||||
trap cleanup EXIT
|
||||
export HOME="$TEST_HOME"
|
||||
|
||||
# Force the file backend: production Secret Service / pass must never be touched
|
||||
mkdir -p "$TEST_HOME/stubs"
|
||||
printf '#!/bin/bash
|
||||
exit 1
|
||||
' > "$TEST_HOME/stubs/secret-tool"
|
||||
printf '#!/bin/bash
|
||||
exit 1
|
||||
' > "$TEST_HOME/stubs/pass"
|
||||
chmod +x "$TEST_HOME/stubs/secret-tool" "$TEST_HOME/stubs/pass"
|
||||
export PATH="$TEST_HOME/stubs:$PATH"
|
||||
|
||||
# Registries parse and carry the P0 providers and harnesses
|
||||
for reg in ai-providers ai-harnesses ai-compatibility; do
|
||||
jq -e . "$ROOT/cn/registry/$reg.json" > /dev/null || fail "$reg.json parses"
|
||||
@@ -91,11 +102,15 @@ python3 - "$port" <<'PYEOF' &
|
||||
import http.server, sys
|
||||
class H(http.server.BaseHTTPRequestHandler):
|
||||
def do_POST(self):
|
||||
self.rfile.read(int(self.headers.get("Content-Length", 0)))
|
||||
body = self.rfile.read(int(self.headers.get("Content-Length", 0)))
|
||||
key = self.headers.get("x-api-key") or (self.headers.get("Authorization") or "").replace("Bearer ", "")
|
||||
if key != "sk-secret-1":
|
||||
code = 401
|
||||
elif self.path in ("/v1/messages", "/responses", "/chat/completions"):
|
||||
elif self.path == "/v1/messages" and b"messages" in body and self.headers.get("anthropic-version"):
|
||||
code = 200
|
||||
elif self.path == "/responses" and b"input" in body and b"messages" not in body:
|
||||
code = 200
|
||||
elif self.path == "/chat/completions" and b"messages" in body:
|
||||
code = 200
|
||||
else:
|
||||
code = 404
|
||||
@@ -122,6 +137,10 @@ fi
|
||||
pass "mock regression: 200 pass, 401 fail, responses path exercised"
|
||||
|
||||
# ai-default merges into claude settings without clobbering user config
|
||||
printf '#!/bin/bash
|
||||
exit 0
|
||||
' > "$TEST_HOME/stubs/claude"
|
||||
chmod +x "$TEST_HOME/stubs/claude"
|
||||
echo "sk-secret-1" | omarchy-cn-ai-secret set deepseek > /dev/null
|
||||
mkdir -p "$HOME/.claude"
|
||||
printf '{"permissions":{"allow":["Bash"]},"env":{"KEEP":"1"}}' > "$HOME/.claude/settings.json"
|
||||
@@ -130,4 +149,5 @@ omarchy-cn-ai-default good > /dev/null
|
||||
[[ $(jq -r '.permissions.allow[0]' "$HOME/.claude/settings.json") == Bash ]] || fail "ai-default preserves permissions"
|
||||
[[ $(jq -r '.env.ANTHROPIC_BASE_URL' "$HOME/.claude/settings.json") == "https://api.deepseek.com/anthropic" ]] || fail "ai-default env written"
|
||||
[[ $(cat "$HOME/.config/omarchy/defaults/agent") == claude ]] || fail "upstream default agent set"
|
||||
[[ $(stat -c %a "$HOME/.claude/settings.json") == 600 ]] || fail "claude settings 0600"
|
||||
pass "ai-default maps the profile onto the upstream agent entry"
|
||||
|
||||
Reference in New Issue
Block a user