Skip to content

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

TypeScript

fix(control-api): migrate PG-gated shared-grant refresh test to refreshOAuthGrantTokens (R1-B1)

Diego Zacarias4b807749776b
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index 64ff50baf..5c4876868 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.512",
+ "version": "0.1.513",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.512",
+ "version": "0.1.513",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/image-policy": "file:../packages/image-policy",
diff --git a/control-api/package.json b/control-api/package.json
index 67552a319..2a27b2c23 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.512",
+ "version": "0.1.513",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/test/oauth.store.sharedGrants.realPostgres.integration.test.ts b/control-api/test/oauth.store.sharedGrants.realPostgres.integration.test.ts
index bc2b9a799..67f9ee86b 100644
--- a/control-api/test/oauth.store.sharedGrants.realPostgres.integration.test.ts
+++ b/control-api/test/oauth.store.sharedGrants.realPostgres.integration.test.ts
@@ -5,7 +5,12 @@ import { config } from '../src/config.js'
import type { DbClient } from '../src/db.js'
import { initDb } from '../src/db.js'
import { deriveOAuthEncryptionKey } from '../src/oauth/encryption.js'
-import { bootstrapSharedOAuthGrant, getOAuthGrant, upsertOAuthGrant } from '../src/oauth/store.js'
+import {
+ bootstrapSharedOAuthGrant,
+ getOAuthGrant,
+ refreshOAuthGrantTokens,
+ upsertOAuthGrant,
+} from '../src/oauth/store.js'
// T1/T5 — shared-identity grant semantics derived from the REAL producer
// (real ON CONFLICT DO NOTHING + CHECK constraints), not a hand-built fixture.
@@ -88,15 +93,17 @@ describeRealPostgres('oauth store — shared grants (real Postgres)', () => {
expect(afterBootstrap?.accessToken).toBe('ACCESS-1')
expect(afterBootstrap?.bootstrappedByUserId).toBe('user-1')
- // Token refresh (upsert by key) rotates the tokens but MUST NOT rewrite the
- // audit column or the shared identity.
- await upsertOAuthGrant(db, KEY, {
+ // Token refresh (UPDATE by key, R1-B1) rotates the tokens but MUST NOT
+ // rewrite the audit column or the shared identity, and reports it touched a
+ // row.
+ const refreshed = await refreshOAuthGrantTokens(db, KEY, {
...sharedKey(server, 'ctx-1'),
provider: 'google',
accessToken: 'ACCESS-3',
refreshToken: 'REFRESH-3',
accessTokenExpiresInSec: 3600,
})
+ expect(refreshed.updated).toBe(true)
const afterRefresh = await getOAuthGrant(db, KEY, sharedKey(server, 'ctx-1'))
expect(afterRefresh?.accessToken).toBe('ACCESS-3')
expect(afterRefresh?.refreshToken).toBe('REFRESH-3')