Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(np-08): make synthetic gate two-context specific
Alfredo Lopezd1175c79b24d
diff --git a/host-context-controller/src/mcpAuthorization.test.ts b/host-context-controller/src/mcpAuthorization.test.tsindex 009fb1b83..cc3292495 100644--- a/host-context-controller/src/mcpAuthorization.test.ts+++ b/host-context-controller/src/mcpAuthorization.test.ts@@ -21,6 +21,13 @@ const principal: VerifiedMcpHostPrincipal = {expiresAt: 4_000_000_000,audiences: ['host-context-controller'],}+const principalB: VerifiedMcpHostPrincipal = {+ ...principal,+ subject: 'mcp-host/standalone-b',+ hostName: 'host-b',+ hostUid: 'host-uid-b',+ jti: 'jti-b',+}const host: AuthorityHost = {name: 'host-a',namespace: 'mcp-host',@@ -33,6 +40,12 @@ const context: AuthorityContext = {metadata: meta('context-uid-a', '20'),mcpServers: ['server-a'],}+const contextB: AuthorityContext = {+ name: 'context-b',+ namespace: 'mcp-server',+ metadata: meta('context-uid-b', '21'),+ mcpServers: ['server-b'],+}const server: AuthorityMcpServer = {name: 'server-a',namespace: 'mcp-server',@@ -42,6 +55,13 @@ const server: AuthorityMcpServer = {enabled: true,status: { deployed: true, ready: true, authoritative: false },}+const serverB: AuthorityMcpServer = {+ ...server,+ name: 'server-b',+ metadata: meta('server-uid-b', '31'),+ transport: { type: 'streamableHttp', url: 'http://server-b/mcp' },+ auth: { type: 'bearer', secretRef: 'server-b-auth', secretKey: 'token' },+}const secret: AuthoritySecret = {name: 'server-a-auth',namespace: 'mcp-server',@@ -97,6 +117,53 @@ class FakeStore implements McpAuthorizationStore {}describe('McpAuthorizationService', () => {+ it('keeps two Host/Context grant sets disjoint in both directions', async () => {+ const storeA = new FakeStore()+ const storeB = new FakeStore()+ storeB.hostObject = {+ name: 'host-b',+ namespace: 'mcp-host',+ metadata: meta('host-uid-b', '11'),+ contextRef: 'context-b',+ }+ storeB.contextObject = contextB+ storeB.serverObject = serverB+ storeB.secretMetadataSequence = [+ {+ name: 'server-b-auth',+ namespace: 'mcp-server',+ metadata: meta('secret-uid-b', '41'),+ },+ ]+ storeB.secretSequence = [+ {+ name: 'server-b-auth',+ namespace: 'mcp-server',+ metadata: meta('secret-uid-b', '41'),+ data: { token: Buffer.from('credential-b').toString('base64') },+ },+ ]++ const serviceA = new McpAuthorizationService(storeA)+ const serviceB = new McpAuthorizationService(storeB)+ await expect(serviceA.listServers(principal)).resolves.toEqual([+ expect.objectContaining({ name: 'server-a' }),+ ])+ await expect(serviceB.listServers(principalB)).resolves.toEqual([+ expect.objectContaining({ name: 'server-b' }),+ ])+ await expect(serviceA.getCredential(principal, 'server-b')).rejects.toMatchObject({+ code: 'not_found',+ })+ await expect(serviceB.getCredential(principalB, 'server-a')).rejects.toMatchObject({+ code: 'not_found',+ })+ expect(storeA.secretMetadataReads).toBe(1)+ expect(storeA.secretValueReads).toBe(0)+ expect(storeB.secretMetadataReads).toBe(1)+ expect(storeB.secretValueReads).toBe(0)+ })+it('projects only valid TCP ports into the public transport contract', () => {expect(toPublicMcpTransport({ type: 'streamableHttp', port: 65_535 })).toEqual({type: 'streamableHttp',diff --git a/scripts/security/run-np08-synthetic-gate.sh b/scripts/security/run-np08-synthetic-gate.shindex 76c4e9999..f60676868 100755--- a/scripts/security/run-np08-synthetic-gate.sh+++ b/scripts/security/run-np08-synthetic-gate.sh@@ -2,8 +2,9 @@set -euo pipefail# Synthetic NP-08 gate. It performs no Kubernetes writes, never reads a Secret,-# and only runs the repository-owned authorization unit suite after checking an-# explicit branch-owned context. The live deployment probe remains Gate F.+# and only runs the repository-owned two-Context authorization unit suite after+# checking an explicit branch-owned context. The live deployment probe remains+# Gate F.context=''test_file='host-context-controller/src/mcpAuthorization.test.ts'@@ -34,8 +35,8 @@ if [[ -z "${context}" || -z "${summary}" ]]; thenecho "usage: $0 --context <kube-context> [--test <HCC unit test>] --summary <file>" >&2exit 2fi-if [[ "${test_file}" != host-context-controller/src/*.test.ts ]]; then- echo "FAIL: synthetic gate accepts only the HCC authorization unit suite" >&2+if [[ "${test_file}" != "host-context-controller/src/mcpAuthorization.test.ts" ]]; then+ echo "FAIL: synthetic gate accepts only mcpAuthorization.test.ts" >&2exit 2fiif [[ ! -f "${test_file}" ]]; then