feat(domain): project verified runtime policy to desktop
This commit is contained in:
parent
fbff657d88
commit
683e135f5e
12 changed files with 224 additions and 25 deletions
|
|
@ -2,7 +2,24 @@ import assert from 'node:assert/strict';
|
|||
import test from 'node:test';
|
||||
import { canEnterSelectedDomainRuntime, createDomainEntryTarget, projectDomainRuntimeBoundary } from './domain-entry-state.js';
|
||||
|
||||
const ready = (domainId: string, nodeType: 'local-terminal' | 'cloud-resident' = 'local-terminal') => ({ blockers: [], domainId, nodeType, runtimeReady: true, stage: 'runtime-ready' as const });
|
||||
const validRuntimePolicy = {
|
||||
allowedSessionScopes: ['domain:enter', 'knowledge:read'],
|
||||
forbiddenDataScopes: ['private:relationship-core'],
|
||||
manifestDigest: 'a'.repeat(64),
|
||||
permissionPolicyRef: 'policy://origin-domain/default',
|
||||
routeRef: 'domain-route://origin-domain/runtime',
|
||||
themeOwner: 'fifth-domain' as const,
|
||||
themePackageRef: 'theme://origin-domain/lake-reflects-stars',
|
||||
};
|
||||
|
||||
const ready = (domainId: string, nodeType: 'local-terminal' | 'cloud-resident' = 'local-terminal') => ({
|
||||
blockers: [],
|
||||
domainId,
|
||||
nodeType,
|
||||
runtimePolicy: validRuntimePolicy,
|
||||
runtimeReady: true,
|
||||
stage: 'runtime-ready' as const,
|
||||
});
|
||||
|
||||
test('a generic login request does not silently target the Fifth Domain', () => {
|
||||
assert.equal(canEnterSelectedDomainRuntime(null, ready('DOM-FIFTH-0001')), false);
|
||||
|
|
@ -30,3 +47,20 @@ test('the Fifth Domain opens only with matching runtime-ready evidence', () => {
|
|||
assert.match(projectDomainRuntimeBoundary(fifth, ready('DOM-FIFTH-0001', 'local-terminal')), /另一种节点类型/);
|
||||
assert.match(projectDomainRuntimeBoundary(fifth, ready('DOM-FIFTH-0001', 'cloud-resident')), /已经匹配/);
|
||||
});
|
||||
|
||||
test('the Fifth Domain stays closed without the exact verified runtime policy projection', () => {
|
||||
const fifth = createDomainEntryTarget('fifth');
|
||||
const base = ready('DOM-FIFTH-0001');
|
||||
assert.equal(canEnterSelectedDomainRuntime(fifth, { ...base, runtimePolicy: undefined }), false);
|
||||
assert.match(projectDomainRuntimeBoundary(fifth, { ...base, runtimePolicy: undefined }), /可信运行策略缺失或不匹配/);
|
||||
|
||||
for (const runtimePolicy of [
|
||||
{ ...validRuntimePolicy, manifestDigest: 'not-a-digest' },
|
||||
{ ...validRuntimePolicy, themeOwner: 'domain-team' as const },
|
||||
{ ...validRuntimePolicy, themePackageRef: 'theme://enterprise/fifth-look' },
|
||||
{ ...validRuntimePolicy, routeRef: 'domain-route://enterprise/fifth' },
|
||||
{ ...validRuntimePolicy, allowedSessionScopes: ['knowledge:read'] },
|
||||
]) {
|
||||
assert.equal(canEnterSelectedDomainRuntime(fifth, { ...base, runtimePolicy }), false);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue