Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(control-api): require a publish after a manual refresh marks the row (#753)
Alfredo Lopezacab60388690
diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex beaecc0fd..8fa990243 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.608",+ "version": "0.1.609","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.608",+ "version": "0.1.609","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",diff --git a/control-api/package.json b/control-api/package.jsonindex 9919d7f2e..6b17fc92c 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.608",+ "version": "0.1.609","description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets","main": "dist/main.js","engines": {diff --git a/control-api/test/routes.admin.codexSubscription.test.ts b/control-api/test/routes.admin.codexSubscription.test.tsindex a0cd1fb96..ec7001e73 100644--- a/control-api/test/routes.admin.codexSubscription.test.ts+++ b/control-api/test/routes.admin.codexSubscription.test.ts@@ -507,6 +507,64 @@ describe('admin Codex subscription routes', () => {assertNoLeak(res.body)})+ it('T-753g publishes the runtime ConfigMap when a manual refresh is rejected after marking the row', async () => {+ const materialize = vi.fn(async () => {})+ oauth.refresh.mockRejectedValue(+ new CodexSubscriptionOAuthError('reauth_required', 'refresh token was rejected', {+ persistedConnectionStatus: true,+ })+ )+ const res = await request(makeAuthedApp(makeGateway(materialize))).post(+ '/admin/llm/providers/codex-subscription/connections/codex-aaa/refresh'+ )+ // The rejected refresh wrote `reauth_required` before it threw. mcp-host and+ // HCC read the ConfigMap, not Postgres, so the publish comes before the+ // error response, as on the catalog-sync route (T-753f).+ expect(oauth.refresh).toHaveBeenCalledTimes(1)+ expect(materialize).toHaveBeenCalledTimes(1)+ expect(res.status).toBe(400)+ expect(res.body).toEqual({ error: 'reauth_required' })+ assertNoLeak(res.body)+ })++ it('T-753g does not publish when a manual refresh fails without writing the row', async () => {+ const materialize = vi.fn(async () => {})+ oauth.refresh.mockRejectedValue(+ new CodexSubscriptionOAuthError('provider_unavailable', 'refresh token exchange failed')+ )+ const res = await request(makeAuthedApp(makeGateway(materialize))).post(+ '/admin/llm/providers/codex-subscription/connections/codex-aaa/refresh'+ )+ expect(res.body).toEqual({ error: 'provider_unavailable' })+ // Liveness witness: the handler ran the refresh and took the failure path,+ // so the absent publish is the rule and not an unreached branch.+ expect(oauth.refresh).toHaveBeenCalledTimes(1)+ expect(materialize).not.toHaveBeenCalled()+ assertNoLeak(res.body)+ })++ it('T-753g answers 503 when the publish after a rejected manual refresh fails', async () => {+ const materialize = vi.fn(async () => {+ throw new Error('apiserver down')+ })+ oauth.refresh.mockRejectedValue(+ new CodexSubscriptionOAuthError('reauth_required', 'refresh token was rejected', {+ persistedConnectionStatus: true,+ })+ )+ const res = await request(makeAuthedApp(makeGateway(materialize))).post(+ '/admin/llm/providers/codex-subscription/connections/codex-aaa/refresh'+ )+ // The row already reads `reauth_required`; the runtime snapshot does not.+ // The ConfigMap failure is the one the operator must act on, so it wins+ // over the refresh error, as on the success path.+ expect(oauth.refresh).toHaveBeenCalledTimes(1)+ expect(materialize).toHaveBeenCalledTimes(1)+ expect(res.status).toBe(503)+ expect(res.body).toMatchObject({ error: 'configmap_write_failed' })+ assertNoLeak(res.body)+ })+it('returns 503 when refresh cannot publish the runtime ConfigMap', async () => {const materialize = vi.fn(async () => {throw new Error('apiserver down')diff --git a/control-api/test/routes.admin.grokSubscription.test.ts b/control-api/test/routes.admin.grokSubscription.test.tsindex 2d2cfbde6..6862eefa3 100644--- a/control-api/test/routes.admin.grokSubscription.test.ts+++ b/control-api/test/routes.admin.grokSubscription.test.ts@@ -508,9 +508,29 @@ describe('admin Grok subscription routes', () => {)expect(res.status).toBe(400)expect(res.body).toEqual({ error: 'reauth_required' })+ // Liveness witness: the refresh ran and failed without writing the row.+ expect(grokOAuth.refreshGrokSubscriptionConnection).toHaveBeenCalledTimes(1)expect(materialize).not.toHaveBeenCalled()})+ it('publishes when a rejected refresh already marked the row reauth_required', async () => {+ const materialize = vi.fn(async () => {})+ grokOAuth.refreshGrokSubscriptionConnection.mockRejectedValue(+ new GrokSubscriptionOAuthError('reauth_required', 'refresh token was rejected', {+ persistedConnectionStatus: true,+ })+ )+ const res = await request(makeApp(makeGateway(materialize))).post(+ `${GROK}/connections/team-grok/refresh`+ )+ // The row changed before the throw, so the ConfigMap is republished and+ // the operator still gets the typed reason.+ expect(grokOAuth.refreshGrokSubscriptionConnection).toHaveBeenCalledTimes(1)+ expect(materialize).toHaveBeenCalledTimes(1)+ expect(res.status).toBe(400)+ expect(res.body).toEqual({ error: 'reauth_required' })+ })+it('revokes only the addressed key, reports Grok Hosts, and publishes', async () => {const materialize = vi.fn(async () => {})const gateway = makeGateway(materialize)