docs(tests): explain asset authorization and byte retention lifecycle

This commit is contained in:
2026-11-12 17:39:05 +08:00
parent 1c549724e8
commit b768c2d6bf
5 changed files with 11 additions and 1 deletions
+2
View File
@@ -32,6 +32,7 @@ test('asset adapter preserves byte identity and headers and validates the scoped
const altered = { ...result, canonical: { ...f.receipt, asset: { ...f.receipt.asset, ...patch } } };
assert.throws(() => f.assets.accept(f.request, altered, f.resource), /asset_receipt_mismatch/);
}
// different 的长度也不同,因此这里证明预发送校验拒绝了不匹配输入;不是单独隔离“等长但摘要变化”的样本。
const changed = await f.assets.upload(f.request, new Blob(['different']), new AbortController().signal);
assert.equal(changed.outcome, 'unresolved'); assert.equal(changed.blocked, true); assert.equal(f.calls.length, 1);
});
@@ -64,6 +65,7 @@ test('multipart browser transport leaves the boundary to fetch and binds the exp
const transport = createFoundryTransport({ accountId: id(5), isCurrentIdentity: () => true, fetch: async (url, init) => { captured = { url, init }; return Response.json({ status: 'applied' }); } });
const body = new FormData(); body.append('image', new Blob(['image']), 'a.png');
await transport({ method: 'POST', path: 'workspaces/example/assets', body, requestId: id(3), resourceId: id(1) });
// fetch 是捕获参数的替身,没有真正编码/发送 multipart;断言要求宿主不手写 Content-Type,保留平台生成 boundary 的入口。
const headers = new Headers(captured.init.headers);
assert.equal(headers.has('content-type'), false); assert.equal(headers.get('X-Expected-Account'), id(5));
assert.equal(headers.get('X-Resource-Id'), id(1)); assert.equal(headers.get('Idempotency-Key'), id(3)); assert.equal(captured.init.body, body);