Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(host-context-controller): drive hostFrontsOAuthServer through the real producer (R1-L6)
Diego Zacariase27dc1ed31be
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.jsonindex 19660ea9d..14e65ae26 100644--- a/host-context-controller/package-lock.json+++ b/host-context-controller/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-host-context-controller",- "version": "0.1.243",+ "version": "0.1.244","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-host-context-controller",- "version": "0.1.243",+ "version": "0.1.244","license": "SEE LICENSE IN LICENSE","dependencies": {"@clerum/image-policy": "file:../packages/image-policy",diff --git a/host-context-controller/package.json b/host-context-controller/package.jsonindex 678d01aaf..188c7577e 100644--- a/host-context-controller/package.json+++ b/host-context-controller/package.json@@ -1,6 +1,6 @@{"name": "clerum-host-context-controller",- "version": "0.1.243",+ "version": "0.1.244","description": "Host Context Controller - provides McpServer CRDs to mcp-host via REST API","main": "dist/main.js","engines": {diff --git a/host-context-controller/src/k8sClient.test.ts b/host-context-controller/src/k8sClient.test.tsindex c1929b203..c82e043f8 100644--- a/host-context-controller/src/k8sClient.test.ts+++ b/host-context-controller/src/k8sClient.test.ts@@ -9878,57 +9878,64 @@ describe('McpServerWatcher.hostFrontsOAuthServer (oauth:user-token scope probe)'spec: { host: 'h', contextRef, secretRef: 's' },}) as HostCRD+ // Build a REAL McpServerCRD (the shape held in the watcher's server cache),+ // so the fixture flows through the REAL getServerInfosByContext filter ++ // toServerInfo projection — not a hand-written McpServerInfo (R1-L6, T1).+ const serverCRD = (over: { name?: string; auth?: { type: string }; enabled?: boolean }): any => ({+ name: over.name ?? 'notion',+ namespace: 'mcp-server',+ spec: {+ contextRef: 'ctx',+ transport: { type: 'streamableHttp', url: 'http://notion/mcp', port: 8080 },+ auth: over.auth ?? { type: 'oauth' },+ enabled: over.enabled ?? true,+ },+ })++ /** Drive the REAL getServerInfosByContext: populate the server cache and answer+ * the Context read the producer makes with an allow-list of those servers. */+ const withServers = (watcher: McpServerWatcher, servers: any[]): void => {+ for (const s of servers) (watcher as any).servers.set(s.name, s)+ mocks.getNamespacedCustomObject.mockImplementation(async ({ plural }: { plural: string }) =>+ plural === 'contexts'+ ? {+ metadata: { name: 'ctx', namespace: 'mcp-server' },+ spec: { contextId: 'ctx', mcpServers: servers.map(s => s.name) },+ }+ : undefined+ )+ }+it('returns true when the Context fronts an enabled auth.type=oauth mcp-server', async () => {const watcher = new McpServerWatcher()- vi.spyOn(watcher, 'getServerInfosByContext').mockResolvedValue([- {- name: 'notion',- contextRef: 'ctx',- transport: { type: 'streamableHttp' },- enabled: true,- auth: { type: 'oauth' },- status: {},- },- ] as any)+ withServers(watcher, [serverCRD({ name: 'notion', auth: { type: 'oauth' }, enabled: true })])await expect((watcher as any).hostFrontsOAuthServer(hostFor('ctx'))).resolves.toBe(true)watcher.stop()})it('returns false for a non-oauth mcp-server', async () => {const watcher = new McpServerWatcher()- vi.spyOn(watcher, 'getServerInfosByContext').mockResolvedValue([- {- name: 'redis',- contextRef: 'ctx',- transport: { type: 'streamableHttp' },- enabled: true,- auth: { type: 'bearer' },- status: {},- },- ] as any)+ withServers(watcher, [serverCRD({ name: 'redis', auth: { type: 'bearer' }, enabled: true })])await expect((watcher as any).hostFrontsOAuthServer(hostFor('ctx'))).resolves.toBe(false)watcher.stop()})- it('returns false for a disabled oauth mcp-server', async () => {+ it('returns false for a disabled oauth mcp-server (filtered by the real producer)', async () => {+ // The disabled server is dropped by getServerInfosByContext's own+ // `enabled !== false` filter BEFORE it reaches hostFrontsOAuthServer — so the+ // producer never emits it. The prior test hand-built an enabled:false+ // McpServerInfo the producer cannot emit, exercising a dead guard instead of+ // the real filter (R1-L6).const watcher = new McpServerWatcher()- vi.spyOn(watcher, 'getServerInfosByContext').mockResolvedValue([- {- name: 'notion',- contextRef: 'ctx',- transport: { type: 'streamableHttp' },- enabled: false,- auth: { type: 'oauth' },- status: {},- },- ] as any)+ withServers(watcher, [serverCRD({ name: 'notion', auth: { type: 'oauth' }, enabled: false })])+ await expect((watcher as any).getServerInfosByContext('ctx')).resolves.toEqual([])await expect((watcher as any).hostFrontsOAuthServer(hostFor('ctx'))).resolves.toBe(false)watcher.stop()})it('returns false when the Context fronts no servers', async () => {const watcher = new McpServerWatcher()- vi.spyOn(watcher, 'getServerInfosByContext').mockResolvedValue([] as any)+ withServers(watcher, [])await expect((watcher as any).hostFrontsOAuthServer(hostFor('ctx'))).resolves.toBe(false)watcher.stop()})