Skip to content

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

TypeScript

test: lock down WRC auth log output

Alfredo Lopez9358f4e0cf8f
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.json
index 4d19bb875..2fd5cc788 100644
--- a/workflow-recipes/package-lock.json
+++ b/workflow-recipes/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.265",
+ "version": "0.1.266",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "workload-recipes-controller",
- "version": "0.1.265",
+ "version": "0.1.266",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@aws-sdk/client-s3": "^3.1009.0",
diff --git a/workflow-recipes/package.json b/workflow-recipes/package.json
index 644c55dcc..99e74f75e 100644
--- a/workflow-recipes/package.json
+++ b/workflow-recipes/package.json
@@ -1,6 +1,6 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.265",
+ "version": "0.1.266",
"description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface",
"main": "dist/main.js",
"engines": {
diff --git a/workflow-recipes/tests/unit/workflow/mcpServerRoutes.test.ts b/workflow-recipes/tests/unit/workflow/mcpServerRoutes.test.ts
index b21c418b9..613799586 100644
--- a/workflow-recipes/tests/unit/workflow/mcpServerRoutes.test.ts
+++ b/workflow-recipes/tests/unit/workflow/mcpServerRoutes.test.ts
@@ -7,13 +7,23 @@ import { initializePublicKey } from '../../../src/workflow/restEndpoints'
describe('ClerumMcpServer workflow routes', () => {
let server: ClerumMcpServer | undefined
+ let consoleErrorSpy: ReturnType<typeof vi.spyOn> | undefined
afterEach(async () => {
await server?.stop()
server = undefined
+ consoleErrorSpy?.mockRestore()
+ consoleErrorSpy = undefined
})
- it('does not register the removed singular direct-trigger endpoint', async () => {
+ async function startTestServer(): Promise<{
+ token: string
+ port: number
+ customApi: {
+ getNamespacedCustomObject: ReturnType<typeof vi.fn>
+ createNamespacedCustomObject: ReturnType<typeof vi.fn>
+ }
+ }> {
const { privateKey, publicKey } = await generateKeyPair('RS256', { extractable: true })
const privateKeyPem = await exportPKCS8(privateKey)
const publicKeyPem = await exportSPKI(publicKey)
@@ -48,23 +58,47 @@ describe('ClerumMcpServer workflow routes', () => {
const address = (
server as unknown as { httpServer: { address: () => AddressInfo | null } }
).httpServer.address()
- expect(address).not.toBeNull()
+ if (!address) throw new Error('test server did not bind')
+ return { token, port: address.port, customApi }
+ }
- const response = await fetch(
- `http://127.0.0.1:${address!.port}/api/v1/workflow/my-recipe/trigger`,
- {
- method: 'POST',
- headers: {
- authorization: `Bearer ${token}`,
- 'content-type': 'application/json',
- },
- body: '{}',
- }
- )
+ it('does not register the removed singular direct-trigger endpoint', async () => {
+ const { token, port, customApi } = await startTestServer()
+
+ const response = await fetch(`http://127.0.0.1:${port}/api/v1/workflow/my-recipe/trigger`, {
+ method: 'POST',
+ headers: {
+ authorization: `Bearer ${token}`,
+ 'content-type': 'application/json',
+ },
+ body: '{}',
+ })
expect(response.status).toBe(404)
await expect(response.json()).resolves.toEqual({ error: 'Not found' })
expect(customApi.getNamespacedCustomObject).not.toHaveBeenCalled()
expect(customApi.createNamespacedCustomObject).not.toHaveBeenCalled()
})
+
+ it('does not reflect hostile auth input in the WRC auth log', async () => {
+ const { port } = await startTestServer()
+ consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => undefined)
+
+ const response = await fetch(
+ `http://127.0.0.1:${port}/api/v1/workflow/my-recipe/status?marker=%25s%0D%0AFORGED`,
+ {
+ headers: { authorization: 'Bearer invalid-%s-FORGED' },
+ }
+ )
+
+ expect(response.status).toBe(401)
+ await expect(response.json()).resolves.toEqual({ error: 'Unauthorized' })
+ expect(consoleErrorSpy).toHaveBeenCalledTimes(1)
+ expect(consoleErrorSpy).toHaveBeenCalledWith('[WRC-AUTH] Token verification failed')
+ const calls = consoleErrorSpy.mock.calls.flat().join(' ')
+ expect(calls).not.toContain('FORGED')
+ expect(calls).not.toContain('%s')
+ expect(calls).not.toContain('\r')
+ expect(calls).not.toContain('\n')
+ })
})