import * as Scope from '../../Scope.js' import * as TestAdmin from '../../../test/Admin.js' import * as TestApp from '../../../test/App.js' import * as Scopes from './scopes.js' describe('GET /scopes', () => { test('serves the issuable scope catalog', async () => { const { client } = TestAdmin.setup() const response = await client.scopes.$get() const body = await TestApp.json(response, Scopes.schema.getScopes.Response) expect(response.status).toBe(200) expect(body).toMatchInlineSnapshot(` { "data": [ { "description": "Read public chain data: tokens, transactions, transfers, blocks, and receipts.", "scope": "data:read", "selfServe": true, }, { "description": "Read organization funding transfers, deposit addresses, and deposits.", "scope": "funding:read", "selfServe": false, }, { "description": "Create funding transfers and register their source transactions.", "scope": "funding:write", "selfServe": false, }, { "description": "Run ad-hoc queries against the raw indexer passthrough.", "scope": "indexer:query", "selfServe": true, }, { "description": "Read organization resources across projects and environments.", "scope": "management:read", "selfServe": true, }, { "description": "Create, update, and delete organization resources across projects and environments.", "scope": "management:write", "selfServe": true, }, { "description": "Validate and broadcast MPP credentials through Tempo.", "scope": "mpp:write", "selfServe": true, }, { "description": "Fill and submit transactions through the relay.", "scope": "rpc-relay:read", "selfServe": true, }, { "description": "Sponsor transaction fees through the relay as the managed fee payer.", "scope": "rpc-relay:sponsor", "selfServe": true, }, { "description": "Read webhook subscriptions.", "scope": "webhooks:read", "selfServe": false, }, { "description": "Create, update, and delete webhook subscriptions.", "scope": "webhooks:write", "selfServe": false, }, { "description": "Read RPC and indexed data for one zone chain id.", "scope": "zone::read", "selfServe": false, }, { "description": "Broadcast signed transactions to one zone chain id.", "scope": "zone::write", "selfServe": false, }, ], } `) }) test('serves the extended Scope catalog source of truth verbatim', async () => { const { client } = TestAdmin.setup() const response = await client.scopes.$get() const body = await TestApp.json(response, Scopes.schema.getScopes.Response) expect(body.data).toEqual(Scope.extend()) }) test('is never cached (admin responses are per-principal)', async () => { const { client } = TestAdmin.setup() const response = await client.scopes.$get() expect(response.headers.get('cache-control')).toMatchInlineSnapshot(`"no-store"`) }) })