fix: secure document upload transport
CI (SIAX Cloud) / integration (push) Skipped
CI (SIAX Cloud) / sonar (push) Skipped
masterplan-lock / check (push) Successful in 5s
CI (SIAX Cloud) / sonar (pull_request) Skipped
masterplan-lock / check (pull_request) Successful in 4s
Security Scan (SIAX Cloud) / security (push) Successful in 13s
CI (SIAX Cloud) / security (push) Successful in 24s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 23s
CI (SIAX Cloud) / security (pull_request) Successful in 29s
CI (SIAX Cloud) / integration (pull_request) Successful in 35s
CI (SIAX Cloud) / quality (pull_request) Successful in 1m5s
CI (SIAX Cloud) / quality (push) Successful in 1m13s
CI (SIAX Cloud) / integration (push) Skipped
CI (SIAX Cloud) / sonar (push) Skipped
masterplan-lock / check (push) Successful in 5s
CI (SIAX Cloud) / sonar (pull_request) Skipped
masterplan-lock / check (pull_request) Successful in 4s
Security Scan (SIAX Cloud) / security (push) Successful in 13s
CI (SIAX Cloud) / security (push) Successful in 24s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 23s
CI (SIAX Cloud) / security (pull_request) Successful in 29s
CI (SIAX Cloud) / integration (pull_request) Successful in 35s
CI (SIAX Cloud) / quality (pull_request) Successful in 1m5s
CI (SIAX Cloud) / quality (push) Successful in 1m13s
This commit is contained in:
@@ -31,6 +31,7 @@ describe('DOC0 upload client', () => {
|
||||
const fetchImpl = vi.fn(async (_url: string | URL | Request, init?: RequestInit) => {
|
||||
expect(new Headers(init?.headers).get('x-tenant-id')).toBe('tenant-a');
|
||||
expect(new Headers(init?.headers).get('x-idempotency-key')).toBe('idem-a');
|
||||
expect(init?.redirect).toBe('error');
|
||||
const form = init?.body as FormData;
|
||||
expect(await (form.get('file') as Blob).text()).toBe('source bytes');
|
||||
return new Response(JSON.stringify(receipt), { status: 201 });
|
||||
@@ -73,4 +74,15 @@ describe('DOC0 upload client', () => {
|
||||
await expect(client.upload({ ...input, bytes: new Uint8Array() })).rejects.toThrow(/Invalid/);
|
||||
expect(fetchImpl).not.toHaveBeenCalled();
|
||||
});
|
||||
it('rejects insecure endpoints, embedded credentials and invalid timeouts', () => {
|
||||
const base = { serviceToken: 'test', maxBytes: 100 };
|
||||
for (const baseUrl of ['http://doc0.test', 'https://doc0.test?token=x', 'file:///tmp/doc0', 'not a URL']) {
|
||||
expect(() => new Doc0UploadClient({ ...base, baseUrl })).toThrow(/HTTPS/);
|
||||
}
|
||||
const credentialUrl = new URL('https://doc0.test');
|
||||
credentialUrl.username = 'fixture';
|
||||
credentialUrl.password = 'fixture';
|
||||
expect(() => new Doc0UploadClient({ ...base, baseUrl: credentialUrl.toString() })).toThrow(/HTTPS/);
|
||||
expect(() => new Doc0UploadClient({ ...base, baseUrl: 'https://doc0.test', timeoutMs: 0 })).toThrow(/limits/);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user