Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(external-rest-api): cover desktop authorization mappings
Josuée036977d4993
diff --git a/external-rest-api/package-lock.json b/external-rest-api/package-lock.jsonindex 9df13ec7f..47d829962 100644--- a/external-rest-api/package-lock.json+++ b/external-rest-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-external-rest-api",- "version": "0.1.115",+ "version": "0.1.116","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-external-rest-api",- "version": "0.1.115",+ "version": "0.1.116","dependencies": {"@clerum/jwt-key-policy": "file:../packages/jwt-key-policy","cors": "^2.8.5",diff --git a/external-rest-api/package.json b/external-rest-api/package.jsonindex d29b621ad..9942d9963 100644--- a/external-rest-api/package.json+++ b/external-rest-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-external-rest-api",- "version": "0.1.115",+ "version": "0.1.116","description": "External REST API for profile, team management, and RPC token brokerage","main": "dist/main.js","engines": {diff --git a/external-rest-api/src/releaseManifest.ts b/external-rest-api/src/releaseManifest.tsindex f9b75168b..e80b593f3 100644--- a/external-rest-api/src/releaseManifest.ts+++ b/external-rest-api/src/releaseManifest.ts@@ -8,7 +8,7 @@ export type ReleaseManifest = {export const releaseManifest: ReleaseManifest = {releaseId: 'v0.11.0',- externalRestApiVersion: '0.1.115',+ externalRestApiVersion: '0.1.116',rpcProxyVersion: '0.1.126',desktopVersion: '0.11.0',minimumDesktopVersion: '0.1.252',diff --git a/external-rest-api/test/r6.invitationProducerMappings.contract.test.ts b/external-rest-api/test/r6.invitationProducerMappings.contract.test.tsindex 0b5321d16..337bfb473 100644--- a/external-rest-api/test/r6.invitationProducerMappings.contract.test.ts+++ b/external-rest-api/test/r6.invitationProducerMappings.contract.test.ts@@ -221,4 +221,64 @@ describe('R6 invitation/password producer response mappings', () => {expect(response.headers['set-cookie']).toBeUndefined()expect(JSON.stringify(response.body)).not.toMatch(/verification_busy|r6-|sql|stack/i)})++ it('maps a real producer password mismatch for desktop authorization', async () => {+ directory.verifyUserPassword.mockResolvedValueOnce(false)++ const response = await request(publicApp())+ .post('/invitations/desktop-authorization')+ .set('authorization', 'Bearer r6-synthetic-session')+ .send({ password: 'R6-synthetic-current-password' })++ expect(response.status).toBe(401)+ expect(response.body).toEqual({ error: 'Invalid password' })+ expect(response.headers['set-cookie']).toBeUndefined()+ expect(JSON.stringify(response.body)).not.toMatch(/invalid_password|r6-|sql|stack/i)+ expect(directory.verifyUserPassword).toHaveBeenCalledWith({+ userId: 'r6-user',+ email: '[email protected]',+ password: 'R6-synthetic-current-password',+ })+ expect(desktopFlow.storeDesktopAuthorizationToken).not.toHaveBeenCalled()+ })++ it('maps an unavailable desktop-authorization producer to bounded public retry guidance', async () => {+ directory.verifyUserPassword.mockRejectedValueOnce(+ new PasswordAdmissionError(503, 23, 'authority_failure')+ )++ const response = await request(publicApp())+ .post('/invitations/desktop-authorization')+ .set('authorization', 'Bearer r6-synthetic-session')+ .send({ password: 'R6-synthetic-current-password' })++ expect(response.status).toBe(503)+ expect(response.body).toEqual({ error: 'authority_unavailable', retryAfterSeconds: 23 })+ expect(response.headers['retry-after']).toBe('23')+ expect(response.headers['set-cookie']).toBeUndefined()+ expect(JSON.stringify(response.body)).not.toMatch(/authority_failure|r6-|sql|stack/i)+ expect(desktopFlow.storeDesktopAuthorizationToken).not.toHaveBeenCalled()+ })++ it('maps the producer desktop-registration not-found code without leaking details', async () => {+ directory.verifyUserPassword.mockResolvedValueOnce(true)+ desktopFlow.storeDesktopAuthorizationToken.mockRejectedValueOnce(+ new Error(+ 'Member registration service POST /invitations-flow/desktop-authorizations failed (404): private'+ )+ )++ const response = await request(publicApp())+ .post('/invitations/desktop-authorization')+ .set('authorization', 'Bearer r6-synthetic-session')+ .send({ password: 'R6-synthetic-current-password' })++ expect(response.status).toBe(404)+ expect(response.body).toEqual({ error: 'Invitation setup not found' })+ expect(response.headers['set-cookie']).toBeUndefined()+ expect(JSON.stringify(response.body)).not.toMatch(+ /desktop-authorization|private|r6-|sql|stack/i+ )+ expect(desktopFlow.storeDesktopAuthorizationToken).toHaveBeenCalledOnce()+ })})