Skip to content

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

TypeScript

fix(test): seed operator user for the real-Postgres grant NOTIFY test (#375)

Alfredo Lopez164dc2ed62bc
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index d6708a2cb..3054c5c6b 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.461",
+ "version": "0.1.462",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.461",
+ "version": "0.1.462",
"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 0a440c422..d9d67f0a0 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.461",
+ "version": "0.1.462",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/test/pluginWorkloadSdkGrantUpdateNotify.realPostgres.integration.test.ts b/control-api/test/pluginWorkloadSdkGrantUpdateNotify.realPostgres.integration.test.ts
index db9654f17..ff2a780b7 100644
--- a/control-api/test/pluginWorkloadSdkGrantUpdateNotify.realPostgres.integration.test.ts
+++ b/control-api/test/pluginWorkloadSdkGrantUpdateNotify.realPostgres.integration.test.ts
@@ -1,6 +1,6 @@
import { afterAll, beforeAll, expect, describe as vitestDescribe } from 'vitest'
import { it } from 'vitest'
-import { randomBytes } from 'node:crypto'
+import { randomBytes, randomUUID } from 'node:crypto'
import { Pool, type PoolClient } from 'pg'
/**
@@ -38,6 +38,11 @@ if (adminUrl && throwawayUrl) {
const NS = 'sandbox-recipes'
const RECIPE = 'notify-recipe'
+// upsertGrant records the acting operator as permission-event `operator_user_id`,
+// a UUID column with a FK to users(id). A real DB rejects a non-UUID like
+// 'operator-1' (22P02) and would reject a non-existent UUID (FK), so seed a real
+// users row and pass its id as the operatorSub.
+const OPERATOR_ID = randomUUID()
describeRealPostgres(
'Plugin Workload SDK grant-update NOTIFY on real PostgreSQL (issue #375)',
@@ -56,6 +61,14 @@ describeRealPostgres(
await db.initDb()
sdk = await import('../src/services/pluginWorkloadSdkDb.js')
+ // Seed the acting operator so upsertGrant's permission-event
+ // operator_user_id FK (→ users(id)) is satisfied on a real database.
+ await db.pool.query(`INSERT INTO users (id, email, name) VALUES ($1, $2, $3)`, [
+ OPERATOR_ID,
+ `sdk-notify-operator-${OPERATOR_ID}@example.test`,
+ 'sdk-notify-operator',
+ ])
+
received = []
listenPool = new Pool({ connectionString: throwawayUrl })
listenClient = await listenPool.connect()
@@ -115,7 +128,7 @@ describeRealPostgres(
allowedModels: ['gpt-5'],
allowedCallers: ['api'],
},
- 'operator-1'
+ OPERATOR_ID
)
const payload = await waitForGrantNotification()