|
4 | 4 | * missing from `headers`, or a metadata key both signed as a header and hoisted |
5 | 5 | * into the query, makes the provider reject or strip the upload. |
6 | 6 | */ |
7 | | -import { resetEnvMock, setEnv } from '@sim/testing/mocks/env.mock' |
8 | 7 | import { setUploadsConfig, uploadsConfigMock } from '@sim/testing/mocks/uploads-config.mock' |
9 | | -import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest' |
| 8 | +import { beforeEach, describe, expect, it, vi } from 'vitest' |
10 | 9 |
|
11 | 10 | vi.mock('@/lib/uploads/config', () => uploadsConfigMock) |
12 | 11 |
|
13 | 12 | import { getS3PresignedUploadUrl, resetS3ClientForTesting } from '@/lib/uploads/providers/s3/client' |
14 | 13 |
|
15 | | -setEnv({ AWS_ACCESS_KEY_ID: 'test-access-key', AWS_SECRET_ACCESS_KEY: 'test-secret-key' }) |
16 | | -afterAll(resetEnvMock) |
17 | | - |
18 | 14 | /** Headers the browser sets itself and the uploader never supplies. */ |
19 | 15 | const TRANSPORT_HEADERS = new Set(['host', 'content-length']) |
20 | 16 |
|
@@ -44,7 +40,12 @@ async function presign() { |
44 | 40 | } |
45 | 41 |
|
46 | 42 | describe('getS3PresignedUploadUrl', () => { |
47 | | - beforeEach(() => configure(undefined)) |
| 43 | + beforeEach(() => { |
| 44 | + // The client resolves credentials through the SDK's default chain, which reads process.env. |
| 45 | + vi.stubEnv('AWS_ACCESS_KEY_ID', 'test-access-key') |
| 46 | + vi.stubEnv('AWS_SECRET_ACCESS_KEY', 'test-secret-key') |
| 47 | + configure(undefined) |
| 48 | + }) |
48 | 49 |
|
49 | 50 | it('signs metadata as uploader-sent headers for a custom S3-compatible endpoint', async () => { |
50 | 51 | configure('https://s3.de.io.cloud.ovh.net') |
|
0 commit comments