hub-roles-first-write-guard.test.mjs
sha256:87f84653ce4706be8c65b0c4494ed6fb891213cca82db2b1824772cddc41a752
feat(auth): durable MCP OAuth refresh via shared strong sto…
Agent
minor
57 days ago
| 1 | /** |
| 2 | * First write to hub_roles.json must keep the acting user as admin so local operators |
| 3 | * are not locked out of Team / POST /api/v1/roles (see hub/roles.mjs + hub/server.mjs). |
| 4 | */ |
| 5 | import { test } from 'node:test'; |
| 6 | import assert from 'node:assert/strict'; |
| 7 | import { ensureActorAdminOnFirstRolesPopulation } from '../hub/roles.mjs'; |
| 8 | |
| 9 | test('first population: adds actor as admin alongside new row', () => { |
| 10 | const out = ensureActorAdminOnFirstRolesPopulation( |
| 11 | 0, |
| 12 | { 'google:999': 'viewer' }, |
| 13 | 'google:111', |
| 14 | ); |
| 15 | assert.deepEqual(out, { |
| 16 | 'google:999': 'viewer', |
| 17 | 'google:111': 'admin', |
| 18 | }); |
| 19 | }); |
| 20 | |
| 21 | test('first population: actor already in map keeps admin if set', () => { |
| 22 | const out = ensureActorAdminOnFirstRolesPopulation( |
| 23 | 0, |
| 24 | { 'google:111': 'admin', 'google:999': 'editor' }, |
| 25 | 'google:111', |
| 26 | ); |
| 27 | assert.equal(out['google:111'], 'admin'); |
| 28 | assert.equal(out['google:999'], 'editor'); |
| 29 | }); |
| 30 | |
| 31 | test('subsequent writes: does not inject admin row', () => { |
| 32 | const out = ensureActorAdminOnFirstRolesPopulation( |
| 33 | 2, |
| 34 | { 'google:111': 'admin', 'google:999': 'evaluator' }, |
| 35 | 'google:111', |
| 36 | ); |
| 37 | assert.deepEqual(out, { 'google:111': 'admin', 'google:999': 'evaluator' }); |
| 38 | }); |
| 39 | |
| 40 | test('empty actor sub: unchanged', () => { |
| 41 | const row = { 'google:999': 'viewer' }; |
| 42 | assert.deepEqual(ensureActorAdminOnFirstRolesPopulation(0, row, ''), row); |
| 43 | assert.deepEqual(ensureActorAdminOnFirstRolesPopulation(0, row, ' '), row); |
| 44 | }); |
File History
4 commits
sha256:87f84653ce4706be8c65b0c4494ed6fb891213cca82db2b1824772cddc41a752
feat(auth): durable MCP OAuth refresh via shared strong sto…
Agent
minor
57 days ago
sha256:873e30b7fafe601346295f8f4289f388f21d8f715f28584d5481899ba2b714fc
Merge pull request #249 from aaronrene/muse-mirror
Agent
73 days ago
sha256:d8c648b20a4d53b2673c5c082ee7edfa7b2fc9b11080832da1f38807b6bf940b
fix(7C-L1b): route hosted delegation proposals through cani…
Human
minor
⚠
76 days ago
sha256:2827ba9e7632a4b141c50caf1e8f7d77abbc3515be20e7465f2bccb0ac4edf91
fix: repair endpoint now sets has_active_subscription when …
Human
minor
⚠
96 days ago