Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix: exempt exact synthetic bearer fixture

Josué86e57fe77614
diff --git a/scripts/tests/test-minikube-t2-contract.sh b/scripts/tests/test-minikube-t2-contract.sh
index c5bd2d179..863b81d30 100755
--- a/scripts/tests/test-minikube-t2-contract.sh
+++ b/scripts/tests/test-minikube-t2-contract.sh
@@ -777,6 +777,62 @@ for leaked in \
exit 1
fi
done
+bearer_repo="$tmp/public-bearer-fixture-repo"
+mkdir -p "$bearer_repo"
+git init -q -b dev "$bearer_repo"
+git -C "$bearer_repo" config user.email [email protected]
+git -C "$bearer_repo" config user.name boundary-test
+printf 'base\n' >"$bearer_repo/README.md"
+git -C "$bearer_repo" add README.md
+git -C "$bearer_repo" commit -q -m base
+bearer_base="$(git -C "$bearer_repo" rev-parse HEAD)"
+bearer_fixture_path='tests/e2e/playwright/profile-ui-recovery-fixture.mjs'
+bearer_other_path='tests/e2e/playwright/other-fixture.mjs'
+bearer_value='synthetic-profile-recovery-token'
+bearer_prefix='Bearer '
+bearer_marker='PUBLIC_SYNTHETIC_BEARER_FIXTURE'
+exact_bearer_line="const syntheticBearer = '${bearer_prefix}${bearer_value}' // $bearer_marker"
+bearer_fixtures_dir="$bearer_repo/tests/e2e/playwright"
+mkdir -p "$bearer_fixtures_dir"
+printf '%s\n' "$exact_bearer_line" >"$bearer_repo/$bearer_fixture_path"
+if ! T2_PUBLIC_ROOT="$bearer_repo" T2_PUBLIC_BASE_REF="$bearer_base" \
+ bash "$ROOT/scripts/tests/test-minikube-t2-public-boundary.sh" >"$tmp/bearer-boundary.out" 2>"$tmp/bearer-boundary.err"; then
+ echo 'FAIL: public boundary rejected the exact marked synthetic bearer fixture' >&2
+ cat "$tmp/bearer-boundary.err" >&2
+ exit 1
+fi
+if ! grep -Fxq 'PUBLIC_BOUNDARY_PASS' "$tmp/bearer-boundary.out"; then
+ echo 'FAIL: marked synthetic bearer fixture passed without PUBLIC_BOUNDARY_PASS' >&2
+ exit 1
+fi
+reject_bearer_fixture() {
+ local relative_path="$1"
+ shift
+ local fixture="$bearer_repo/$relative_path"
+ rm -f -- "$bearer_repo/$bearer_fixture_path" "$bearer_repo/$bearer_other_path"
+ mkdir -p "$(dirname "$fixture")"
+ printf '%s\n' "$@" >"$fixture"
+ if T2_PUBLIC_ROOT="$bearer_repo" T2_PUBLIC_BASE_REF="$bearer_base" \
+ bash "$ROOT/scripts/tests/test-minikube-t2-public-boundary.sh" \
+ >"$tmp/bearer-boundary.out" 2>"$tmp/bearer-boundary.err"; then
+ echo "FAIL: public boundary accepted an unauthorized bearer fixture at $relative_path" >&2
+ exit 1
+ fi
+ if ! grep -Fq -- "- $relative_path: bearer token" "$tmp/bearer-boundary.err"; then
+ echo "FAIL: public boundary rejected $relative_path for another reason" >&2
+ cat "$tmp/bearer-boundary.err" >&2
+ exit 1
+ fi
+}
+unmarked_bearer_line="const syntheticBearer = '${bearer_prefix}${bearer_value}'"
+reject_bearer_fixture "$bearer_fixture_path" "$unmarked_bearer_line"
+reject_bearer_fixture "$bearer_other_path" "$exact_bearer_line"
+altered_bearer_line="const syntheticBearer = '${bearer_prefix}${bearer_value}-altered' // $bearer_marker"
+reject_bearer_fixture "$bearer_fixture_path" "$altered_bearer_line"
+extra_bearer_value='synthetic-added-token-value'
+extra_bearer_line="const extraBearer = '${bearer_prefix}${extra_bearer_value}'"
+reject_bearer_fixture "$bearer_fixture_path" "$exact_bearer_line" "$extra_bearer_line"
+echo 'PASS: public boundary accepts only the exact marked synthetic bearer fixture'
echo 'PASS: public boundary reads a string-literal key as data and still rejects real assignments'
bash "$ROOT/scripts/tests/test-minikube-t2-scenarios.sh"
bash "$ROOT/scripts/tests/test-minikube-t2-proxy-runtime.sh"
diff --git a/scripts/tests/test-minikube-t2-public-boundary.sh b/scripts/tests/test-minikube-t2-public-boundary.sh
index 23d12dbcc..77cc58b0c 100755
--- a/scripts/tests/test-minikube-t2-public-boundary.sh
+++ b/scripts/tests/test-minikube-t2-public-boundary.sh
@@ -124,6 +124,13 @@ for line in diff.splitlines():
if not line.startswith("+") or line.startswith("+++"):
continue
value = line[1:]
+ # Only this fully matched fixture line may contain a bearer-looking value.
+ synthetic_bearer_fixture_line = (
+ current.lower() == "tests/e2e/playwright/profile-ui-recovery-fixture.mjs"
+ and value
+ == "const syntheticBearer = 'Bearer "
+ "synthetic-profile-recovery-token' // PUBLIC_SYNTHETIC_BEARER_FIXTURE"
+ )
# The boundary is intended to catch materialized credentials, not source
# identifiers or test fixtures. The old expression accepted an optional
# quote and an arbitrary unquoted expression, so ordinary code such as
@@ -176,6 +183,8 @@ for line in diff.splitlines():
if match is None:
break
position = match.end()
+ if reason == "bearer token" and synthetic_bearer_fixture_line:
+ continue
if reason == "private key" and "evidence-scanner" in current:
continue
# A key inside a string literal ending in `=` or `:` (for example
diff --git a/tests/e2e/playwright/package-lock.json b/tests/e2e/playwright/package-lock.json
index 7d95c3c0e..a4822028a 100644
--- a/tests/e2e/playwright/package-lock.json
+++ b/tests/e2e/playwright/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-playwright-tests",
- "version": "0.1.81",
+ "version": "0.1.82",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-playwright-tests",
- "version": "0.1.81",
+ "version": "0.1.82",
"devDependencies": {
"@playwright/test": "^1.50.0",
"@types/node": "^22.0.0",
diff --git a/tests/e2e/playwright/package.json b/tests/e2e/playwright/package.json
index 48081cffb..e2b025e30 100644
--- a/tests/e2e/playwright/package.json
+++ b/tests/e2e/playwright/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-playwright-tests",
- "version": "0.1.81",
+ "version": "0.1.82",
"private": true,
"description": "Playwright E2E tests for Control UI and Desktop App",
"scripts": {
diff --git a/tests/e2e/playwright/profile-ui-recovery-fixture.mjs b/tests/e2e/playwright/profile-ui-recovery-fixture.mjs
index 985a6c055..c082057d4 100644
--- a/tests/e2e/playwright/profile-ui-recovery-fixture.mjs
+++ b/tests/e2e/playwright/profile-ui-recovery-fixture.mjs
@@ -11,9 +11,7 @@ const externalRestRoot = path.join(repositoryRoot, 'external-rest-api')
const port = Number(process.env.PROFILE_UI_RECOVERY_PORT || 31873)
const profileOrigin = `http://127.0.0.1:${port}`
const invitationToken = 'synthetic-reset-proof'
-const syntheticServiceAuthorization = ['Bearer', 'synthetic-profile-recovery-service-token'].join(
- ' '
-)
+const syntheticBearer = 'Bearer synthetic-profile-recovery-token' // PUBLIC_SYNTHETIC_BEARER_FIXTURE
const contractPasswordPrefix = 'Synthetic-Recovery-Contract-'
const invitation = {
id: 'synthetic-reset-row',
@@ -380,7 +378,7 @@ const apiServer = createServer(async (request, response) => {
/^\/api\/v1\/external\/invitations\/token\/([^/]+)$/
)
if (request.method === 'GET' && invitationTokenMatch) {
- if (request.headers.authorization !== syntheticServiceAuthorization) {
+ if (request.headers.authorization !== syntheticBearer) {
sendJson(response, 401, { error: 'Unauthorized' })
return
}
@@ -403,7 +401,7 @@ const apiServer = createServer(async (request, response) => {
return
}
const invited = invitationForToken(String(body.token || ''))
- if (request.headers.authorization !== syntheticServiceAuthorization) {
+ if (request.headers.authorization !== syntheticBearer) {
sendJson(response, 401, { error: 'Unauthorized' })
return
}
@@ -439,7 +437,7 @@ const apiServer = createServer(async (request, response) => {
sendJson(response, 400, { error: 'invalid_payload' })
return
}
- if (request.headers.authorization !== syntheticServiceAuthorization) {
+ if (request.headers.authorization !== syntheticBearer) {
sendJson(response, 401, { error: 'Unauthorized' })
return
}
@@ -485,7 +483,7 @@ const apiServer = createServer(async (request, response) => {
const meMatch = url.pathname.match(/^\/api\/v1\/external\/users\/([^/]+)\/me$/)
if (request.method === 'GET' && meMatch) {
- if (request.headers.authorization !== syntheticServiceAuthorization) {
+ if (request.headers.authorization !== syntheticBearer) {
sendJson(response, 401, { error: 'Unauthorized' })
return
}
@@ -528,7 +526,7 @@ const apiServer = createServer(async (request, response) => {
return
}
if (
- request.headers.authorization !== syntheticServiceAuthorization ||
+ request.headers.authorization !== syntheticBearer ||
body.token !== invitationToken ||
body.email !== invitation.email ||
body.invitationId !== invitation.id ||
@@ -585,7 +583,7 @@ const externalRestProcess = spawn(
env: {
NODE_ENV: 'development',
EXTERNAL_REST_API_CONTROL_API_BASE_URL: `http://127.0.0.1:${apiAddress.port}/api/v1`,
- EXTERNAL_REST_API_CONTROL_API_SERVICE_TOKEN: 'synthetic-profile-recovery-service-token',
+ EXTERNAL_REST_API_CONTROL_API_SERVICE_TOKEN: 'synthetic-profile-recovery-token',
EXTERNAL_REST_API_JWT_PUBLIC_KEY: publicKey
.export({ type: 'spki', format: 'pem' })
.toString(),