refactor(authorization): simplify cross-instance testing
CI / Test and build (push) Canceled after 0s

This commit is contained in:
go0p
2026-09-04 16:43:11 +08:00
parent 71a14eb17a
commit dd61541c3e
36 changed files with 475 additions and 9178 deletions
-207
View File
@@ -92,213 +92,6 @@ describe('Bridge v3 protocol', () => {
})).toThrow();
});
it('binds authorization context capture to a proof, slot and exact document target', () => {
expect(parseCapabilityParams('browser.authorization.context.capture', {
tabId: 12,
frameId: 0,
documentId: 'document-1',
isolationProofId: 'proof-1',
slotId: 'left',
accountLabel: '低权限账号',
})).toEqual({
tabId: 12,
frameId: 0,
documentId: 'document-1',
isolationProofId: 'proof-1',
slotId: 'left',
accountLabel: '低权限账号',
});
expect(parseCapabilityParams('browser.authorization.context.get', {
id: 'auth-context-1',
})).toEqual({ id: 'auth-context-1' });
expect(parseCapabilityParams('browser.authorization.context.attest', {
tabId: 12,
frameId: 0,
documentId: 'document-1',
})).toEqual({
tabId: 12,
frameId: 0,
documentId: 'document-1',
});
expect(parseCapabilityParams('browser.authorization.context.attestation.get', {
id: 'attestation-1',
})).toEqual({ id: 'attestation-1' });
expect(parseCapabilityParams('browser.isolation.container.open', {
url: 'https://example.test/login',
name: '身份 B',
})).toEqual({
url: 'https://example.test/login',
name: '身份 B',
});
expect(parseCapabilityParams('browser.isolation.container.list', {})).toEqual({});
expect(parseCapabilityParams('browser.isolation.container.remove', {
cookieStoreId: 'firefox-container-7',
})).toEqual({ cookieStoreId: 'firefox-container-7' });
expect(parseCapabilityParams('browser.authorization.baseline.capture', {
tabId: 12,
frameId: 0,
documentId: 'document-1',
authContextKind: 'handle',
authContextId: 'auth-context-1',
networkRequestId: 'network-request-1',
comparisonKey: 'A'.repeat(43),
})).toMatchObject({
authContextKind: 'handle',
authContextId: 'auth-context-1',
networkRequestId: 'network-request-1',
});
expect(parseCapabilityParams('browser.authorization.baseline.get', {
id: 'baseline-1',
})).toEqual({ id: 'baseline-1' });
expect(parseCapabilityParams('browser.authorization.baseline.logical.bind', {
id: 'baseline-1',
profileId: 'profile-left',
comparisonKey: 'A'.repeat(43),
})).toEqual({
id: 'baseline-1',
profileId: 'profile-left',
comparisonKey: 'A'.repeat(43),
});
expect(parseCapabilityParams('browser.authorization.baseline.candidates', {
tabId: 12,
frameId: 0,
authContextKind: 'attestation',
authContextId: 'attestation-1',
limit: 50,
})).toMatchObject({
authContextKind: 'attestation',
authContextId: 'attestation-1',
limit: 50,
});
expect(parseCapabilityParams('browser.authorization.baseline.resource.get', {
id: 'baseline-1',
selector: { source: 'wire', location: 'query', path: 'query.orderId' },
})).toEqual({
id: 'baseline-1',
selector: { source: 'wire', location: 'query', path: 'query.orderId' },
});
expect(parseCapabilityParams('browser.authorization.baseline.compile', {
id: 'baseline-1',
selector: { source: 'wire', location: 'query', path: 'query.orderId' },
replacement: {
version: 1,
baselineId: 'baseline-2',
source: 'wire',
location: 'query',
path: 'query.orderId',
valueType: 'string',
byteLength: 2,
valueBase64: 'NDI=',
valueFingerprint: `workspace-hmac-sha256:${'a'.repeat(64)}`,
},
comparisonKey: 'A'.repeat(43),
})).toMatchObject({
id: 'baseline-1',
replacement: { baselineId: 'baseline-2', valueBase64: 'NDI=' },
});
expect(parseCapabilityParams('browser.authorization.baseline.compile', {
id: 'baseline-1',
selector: {
source: 'wire',
location: 'body',
path: 'body.variables.orderId',
},
replacement: {
version: 1,
baselineId: 'baseline-2',
source: 'wire',
location: 'body',
path: 'body.variables.orderId',
valueType: 'number',
byteLength: 2,
valueBase64: 'ODQ=',
valueFingerprint: `workspace-hmac-sha256:${'b'.repeat(64)}`,
},
comparisonKey: 'A'.repeat(43),
})).toMatchObject({
replacement: { valueType: 'number', valueBase64: 'ODQ=' },
});
expect(parseCapabilityParams('browser.authorization.baseline.transform.inspect', {
id: 'baseline-1',
profileId: 'profile-left',
})).toEqual({
id: 'baseline-1',
profileId: 'profile-left',
});
expect(parseCapabilityParams('browser.authorization.baseline.packet.compile', {
id: 'baseline-1',
})).toEqual({ id: 'baseline-1' });
expect(parseCapabilityParams('browser.authorization.baseline.transform.compile', {
id: 'baseline-1',
selector: { source: 'wire', location: 'query', path: 'query.orderId' },
replacement: {
version: 1,
baselineId: 'baseline-2',
source: 'wire',
location: 'query',
path: 'query.orderId',
valueType: 'string',
byteLength: 2,
valueBase64: 'NDI=',
valueFingerprint: `workspace-hmac-sha256:${'a'.repeat(64)}`,
},
comparisonKey: 'A'.repeat(43),
profileId: 'profile-left',
bindingFingerprint: `sha256:${'b'.repeat(64)}`,
})).toMatchObject({
id: 'baseline-1',
profileId: 'profile-left',
bindingFingerprint: `sha256:${'b'.repeat(64)}`,
});
expect(() => parseCapabilityParams('browser.authorization.context.capture', {
tabId: 12,
isolationProofId: 'proof-1',
slotId: 'middle',
})).toThrow();
expect(() => parseCapabilityParams('browser.isolation.container.remove', {
cookieStoreId: 'firefox-default',
})).toThrow();
expect(() => parseCapabilityParams('browser.authorization.context.get', {
id: '',
})).toThrow();
expect(() => parseCapabilityParams('browser.authorization.context.attestation.get', {
id: '',
})).toThrow();
expect(() => parseCapabilityParams('browser.authorization.baseline.capture', {
tabId: 12,
authContextKind: 'handle',
authContextId: 'auth-context-1',
networkRequestId: 'network-request-1',
comparisonKey: 'short',
})).toThrow();
expect(() => parseCapabilityParams('browser.authorization.baseline.candidates', {
tabId: 12,
authContextKind: 'handle',
authContextId: 'auth-context-1',
limit: 201,
})).toThrow();
expect(() => parseCapabilityParams('browser.authorization.baseline.resource.get', {
id: 'baseline-1',
selector: { location: 'body', path: 'body.orderId' },
})).toThrow();
expect(() => parseCapabilityParams('browser.authorization.baseline.compile', {
id: 'baseline-1',
selector: { source: 'wire', location: 'query', path: 'query.orderId' },
replacement: {
version: 1,
baselineId: 'baseline-2',
source: 'wire',
location: 'query',
path: 'query.orderId',
valueType: 'string',
byteLength: 2,
valueBase64: 'not base64',
valueFingerprint: `workspace-hmac-sha256:${'a'.repeat(64)}`,
},
comparisonKey: 'A'.repeat(43),
})).toThrow();
});
it('accepts automatic selected-frame capture and rejects the legacy expression contract', () => {
expect(parseCapabilityParams('browser.callable.create', {
source: 'deep-capture', strategy: 'selected-frame', callFrameId: 'frame-1', name: 'Envelope',