Skip to content

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

TypeScript

fix(test): give the rejected-refresh grant its own xAI account

Alfredo Lopez681a5dca462f
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index 457f61f6a..cc624b3db 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.598",
+ "version": "0.1.599",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.598",
+ "version": "0.1.599",
"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.json
index 393630037..944361935 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.598",
+ "version": "0.1.599",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/test/services.subscriptionCatalogSyncCron.realPostgres.integration.test.ts b/control-api/test/services.subscriptionCatalogSyncCron.realPostgres.integration.test.ts
index 1b194f9e6..3f42266b2 100644
--- a/control-api/test/services.subscriptionCatalogSyncCron.realPostgres.integration.test.ts
+++ b/control-api/test/services.subscriptionCatalogSyncCron.realPostgres.integration.test.ts
@@ -76,6 +76,18 @@ function jsonResponse(status: number, body: Record<string, unknown>): Response {
*/
const GRANT_SUBJECT = 'subject-cron-grok'
+/**
+ * A second xAI account, for the grant whose refresh is rejected.
+ *
+ * The subject must be stable across one grant and its refreshes, and it must
+ * differ between two grants that are live at the same time: the fingerprint is
+ * derived from the subject, and `persistGrantedTokens` refuses a second live
+ * subscription on one account with `fingerprint_in_use`. The rejected grant is
+ * created while the healthy one is still connected, so reusing `GRANT_SUBJECT`
+ * here makes the connect throw before the tick under test ever runs.
+ */
+const REJECTED_GRANT_SUBJECT = 'subject-cron-grok-rejected'
+
/**
* Simulated xAI device-authorization provider for the healthy cases. Its grant
* is valid for an hour, well outside `ACCESS_TOKEN_REFRESH_SKEW_MS`, so a tick
@@ -146,7 +158,7 @@ function rejectingRefreshGrokProvider(): typeof fetch {
access_token: `access-${randomBytes(4).toString('hex')}`,
refresh_token: `refresh-${randomBytes(4).toString('hex')}`,
expires_in: 60,
- id_token: idTokenFor(GRANT_SUBJECT),
+ id_token: idTokenFor(REJECTED_GRANT_SUBJECT),
})
}
return jsonResponse(400, { error: 'invalid_grant' })