The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.
/*
* Modified by BoxLite AI, 2026
* SPDX-License-Identifier: AGPL-3.0
*/
import { describe, expect, it } from 'vitest'
import { CREATE_API_KEY_PERMISSIONS_GROUPS } from './CreateApiKeyPermissionsGroups'
import { ORGANIZATION_ROLE_PERMISSIONS_GROUPS } from './OrganizationPermissionsGroups'
const PERMISSION_GROUPS: ReadonlyArray<readonly [string, ReadonlyArray<{ name: string; permissions: string[] }>]> = [
['ORGANIZATION_ROLE_PERMISSIONS_GROUPS', ORGANIZATION_ROLE_PERMISSIONS_GROUPS],
['CREATE_API_KEY_PERMISSIONS_GROUPS', CREATE_API_KEY_PERMISSIONS_GROUPS],
]
describe('permission groups', () => {
it.each(PERMISSION_GROUPS)('offer list and management permissions for secrets in %s', (_source, groups) => {
expect(groups.find((group) => group.name === 'Secrets')?.permissions).toEqual(['read:secrets', 'write:secrets'])
})
it.each(PERMISSION_GROUPS)('offer App resource permissions immediately after Boxes in %s', (_source, groups) => {
const boxes = groups.findIndex((group) => group.name === 'Boxes')
expect(groups[boxes + 1]).toEqual({ name: 'Apps', permissions: ['read:apps', 'write:apps', 'delete:apps'] })
})
it('omits retired template permissions from the organization role editor', () => {
const permissions = ORGANIZATION_ROLE_PERMISSIONS_GROUPS.flatMap((group) => group.permissions)
expect(permissions.filter((permission) => permission.endsWith(':templates'))).toEqual([])
})
/**
* Both files, because they are the pair a reader assumes is in sync and were
* not: the role file carried an Images group that granted `*:templates`, and
* the API key file had no Images group at all. A key that can read the
* catalog but cannot be granted that scope is the failure this holds off —
* and `write:images` is the scope for alias creation and deletion, so a role or key
* without it could read the catalog but never create or delete catalog aliases.
*/
it.each(PERMISSION_GROUPS)('offer the catalog scopes in %s', (_source, groups) => {
const images = groups.find((group) => group.name === 'Images')
expect(images?.permissions).toEqual(['read:images', 'write:images', 'delete:images'])
})
/**
* The same pair, for the registry logins. A key the SDK adds a login with
* needs these three, and a role without `read:registries` could add a login
* it can never list.
*/
it.each(PERMISSION_GROUPS)('offer the registry scopes in %s', (_source, groups) => {
const registries = groups.find((group) => group.name === 'Registries')
expect(registries?.permissions).toEqual(['read:registries', 'write:registries', 'delete:registries'])
})
})