Skip to content

Commit e47cd97

Browse files
committed
test(uploads): give the presigner credentials where the client now reads them
The S3 client resolves credentials through the SDK default chain, which reads process.env, so the presigner test stubs the keys there instead of the env module mock.
1 parent 719cb74 commit e47cd97

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

‎apps/sim/lib/uploads/providers/s3/presigned-upload.test.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@
44
* missing from `headers`, or a metadata key both signed as a header and hoisted
55
* into the query, makes the provider reject or strip the upload.
66
*/
7-
import { resetEnvMock, setEnv } from '@sim/testing/mocks/env.mock'
87
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'
109

1110
vi.mock('@/lib/uploads/config', () => uploadsConfigMock)
1211

1312
import { getS3PresignedUploadUrl, resetS3ClientForTesting } from '@/lib/uploads/providers/s3/client'
1413

15-
setEnv({ AWS_ACCESS_KEY_ID: 'test-access-key', AWS_SECRET_ACCESS_KEY: 'test-secret-key' })
16-
afterAll(resetEnvMock)
17-
1814
/** Headers the browser sets itself and the uploader never supplies. */
1915
const TRANSPORT_HEADERS = new Set(['host', 'content-length'])
2016

@@ -44,7 +40,12 @@ async function presign() {
4440
}
4541

4642
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+
})
4849

4950
it('signs metadata as uploader-sent headers for a custom S3-compatible endpoint', async () => {
5051
configure('https://s3.de.io.cloud.ovh.net')

0 commit comments

Comments
 (0)