Files
zpan/server/middleware/audit-actor.test.ts
T
agent-kanban[bot] d22227ed2f feat: add delegated agent OAuth provider (#539)
* feat: add delegated agent oauth provider

Agent-Profile: https://agent-kanban.dev/agents/e0a1ce35687e48ef

* test(auth): cover delegated OAuth configuration

* fix(auth): route OAuth metadata through worker

* fix(auth): advertise canonical OAuth issuer

* test: cover agent oauth provider integration

Agent-Profile: https://agent-kanban.dev/agents/e0a1ce35687e48ef

* test(auth): cover managed OAuth consent flow

---------

Co-authored-by: Ravi Shah <ravi-shah@mails.agent-kanban.dev>
Co-authored-by: saltbo <saltbo@foxmail.com>
2026-07-29 13:26:44 -04:00

40 lines
1013 B
TypeScript

import { describe, expect, it } from 'vitest'
import { auditActor } from './audit-actor'
import type { AuthPrincipal } from './platform'
describe('auditActor', () => {
it('records Agent OAuth principals as delegated Agent actors', () => {
const principal: AuthPrincipal = {
kind: 'agent-oauth',
userId: 'user-1',
grantId: 'grant-1',
clientId: 'zpan-agent',
orgId: 'org-1',
scopes: [],
authMethod: 'bearer',
}
expect(auditActor(principal)).toEqual({
userId: 'user-1',
actorType: 'agent_oauth',
actorRef: 'grant-1',
})
})
it('records downloader bootstrap principals as user actors', () => {
const principal: AuthPrincipal = {
kind: 'downloader-bootstrap',
userId: 'user-1',
sessionToken: 'bootstrap-token',
scope: 'downloader:register',
authMethod: 'bearer',
}
expect(auditActor(principal)).toEqual({
userId: 'user-1',
actorType: 'user',
actorRef: null,
})
})
})