mirror of
https://github.com/saltbo/zpan.git
synced 2026-08-29 00:01:42 +08:00
d7ba55b9da
Replace bundled agent profiles, API keys, plugin, and skill surfaces with dynamic OAuth client registration, delegated DPoP tokens, discoverable scopes, and Arazzo-backed direct upload workflows. Refs realmroot/realmroot#115
33 lines
1.4 KiB
TypeScript
33 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { AGENT_OAUTH_RESOURCE_SCOPES } from './agent-oauth'
|
|
import { WEBDAV_API_KEY_PERMISSIONS } from './api-key-templates'
|
|
import {
|
|
AuthorizationScope,
|
|
authorizationScope,
|
|
CANONICAL_AUTHORIZATION_SCOPES,
|
|
scopePermissions,
|
|
} from './authorization'
|
|
|
|
describe('authorization scope registry', () => {
|
|
it('uses lowercase resource:action scopes without wildcard semantics', () => {
|
|
for (const scope of CANONICAL_AUTHORIZATION_SCOPES) {
|
|
expect(scope).toMatch(/^[a-z][a-z-]*s?:[a-z][a-z-]*$/)
|
|
expect(scope).not.toContain('*')
|
|
expect(scope).not.toContain('zpan')
|
|
}
|
|
expect(authorizationScope('download-tasks', 'read')).toBe(AuthorizationScope.DOWNLOAD_TASKS_READ)
|
|
expect(authorizationScope('remoteDownload', 'read')).toBeNull()
|
|
expect(authorizationScope('objects', '*')).toBeNull()
|
|
})
|
|
|
|
it('keeps permanent object purge out of agent-grantable scopes', () => {
|
|
expect(CANONICAL_AUTHORIZATION_SCOPES).toContain(AuthorizationScope.OBJECTS_PURGE)
|
|
expect(AGENT_OAUTH_RESOURCE_SCOPES).not.toContain(AuthorizationScope.OBJECTS_PURGE)
|
|
expect(scopePermissions([AuthorizationScope.OBJECTS_DELETE])).toEqual({ objects: ['delete'] })
|
|
})
|
|
|
|
it('does not grant share mutation scopes to user-wide WebDAV app passwords', () => {
|
|
expect(WEBDAV_API_KEY_PERMISSIONS.shares).toEqual(['read'])
|
|
})
|
|
})
|