calendar-bridge-hosted-route.test.mjs
sha256:94ec65bd2b200240ac785a97cf14c5db066832bd608a24d6a9c151f17b918b02
feat(calendar): hosted bridge/gateway route parity and time…
Human
minor
⚠ breaking
12 hours ago
| 1 | /** |
| 2 | * Hosted bridge calendar route contract tests (step 12 parity). |
| 3 | */ |
| 4 | import { describe, it } from 'node:test'; |
| 5 | import assert from 'node:assert/strict'; |
| 6 | import fs from 'fs'; |
| 7 | import path from 'path'; |
| 8 | import { fileURLToPath } from 'url'; |
| 9 | |
| 10 | const __dirname = path.dirname(fileURLToPath(import.meta.url)); |
| 11 | const repoRoot = path.dirname(__dirname); |
| 12 | |
| 13 | function readRepoFile(relativePath) { |
| 14 | return fs.readFileSync(path.join(repoRoot, relativePath), 'utf8'); |
| 15 | } |
| 16 | |
| 17 | describe('hosted bridge calendar routes', () => { |
| 18 | it('unit: registers timeline, agent-context, source-calendars, and import routes', () => { |
| 19 | const bridge = readRepoFile('hub/bridge/server.mjs'); |
| 20 | const gateway = readRepoFile('hub/gateway/server.mjs'); |
| 21 | |
| 22 | assert.match(bridge, /app\.get\('\/api\/v1\/calendar\/timeline', requireBridgeAuth/); |
| 23 | assert.match(bridge, /app\.get\('\/api\/v1\/calendar\/agent-context', requireBridgeAuth/); |
| 24 | assert.match(bridge, /app\.get\('\/api\/v1\/calendar\/source-calendars', requireBridgeAuth/); |
| 25 | assert.match(bridge, /app\.patch\('\/api\/v1\/calendar\/source-calendars\/:id', requireBridgeAuth, requireBridgeEditorOrAdmin/); |
| 26 | assert.match(bridge, /app\.post\('\/api\/v1\/calendar\/events\/import', requireBridgeAuth, requireBridgeEditorOrAdmin/); |
| 27 | assert.match(bridge, /fetchCanisterNoteRecordsForTimeline/); |
| 28 | |
| 29 | assert.match(gateway, /app\.get\('\/api\/v1\/calendar\/timeline'/); |
| 30 | assert.match(gateway, /app\.get\('\/api\/v1\/calendar\/agent-context'/); |
| 31 | assert.match(gateway, /app\.get\('\/api\/v1\/calendar\/source-calendars'/); |
| 32 | assert.match(gateway, /app\.patch\('\/api\/v1\/calendar\/source-calendars\/:id'/); |
| 33 | assert.match(gateway, /app\.post\('\/api\/v1\/calendar\/events\/import'/); |
| 34 | }); |
| 35 | |
| 36 | it('security: bridge calendar routes require auth before hosted context resolution', () => { |
| 37 | const bridge = readRepoFile('hub/bridge/server.mjs'); |
| 38 | const timelineBlock = bridge.slice( |
| 39 | bridge.indexOf("app.get('/api/v1/calendar/timeline'"), |
| 40 | bridge.indexOf("app.get('/api/v1/calendar/agent-context'"), |
| 41 | ); |
| 42 | |
| 43 | assert.match(timelineBlock, /requireBridgeAuth/); |
| 44 | assert.match(timelineBlock, /resolveHostedBridgeContext/); |
| 45 | assert.doesNotMatch(timelineBlock, /oauth_ref|refresh_token/); |
| 46 | }); |
| 47 | |
| 48 | it('integration: timeline merge can use canister note records without a local vault path', () => { |
| 49 | const timeline = readRepoFile('lib/calendar/timeline.mjs'); |
| 50 | assert.match(timeline, /noteRecords/); |
| 51 | assert.match(timeline, /input\.noteRecords != null/); |
| 52 | }); |
| 53 | }); |
File History
1 commit
sha256:94ec65bd2b200240ac785a97cf14c5db066832bd608a24d6a9c151f17b918b02
feat(calendar): hosted bridge/gateway route parity and time…
Human
minor
⚠
12 hours ago