Skip to content

Commit 9550be8

Browse files
committed
fix: add acceptance test for s3 objects sanitization
1 parent 789b8a6 commit 9550be8

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

acceptance/specs/s3.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,48 @@ describeAcceptance(
339339
client.destroy()
340340
}
341341
})
342+
343+
it('puts, gets, lists, and deletes an object whose key contains a colon', async () => {
344+
const client = createAcceptanceS3Client()
345+
const bucketName = uniqueBucketName('s3colon')
346+
const key = uniqueObjectKey('board:doc', 'bin')
347+
const payload = Buffer.from('acceptance-s3-colon-key')
348+
349+
try {
350+
await client.send(new CreateBucketCommand({ Bucket: bucketName }))
351+
352+
await client.send(
353+
new PutObjectCommand({
354+
Body: payload,
355+
Bucket: bucketName,
356+
ContentType: 'application/octet-stream',
357+
Key: key,
358+
})
359+
)
360+
361+
const downloaded = await client.send(
362+
new GetObjectCommand({
363+
Bucket: bucketName,
364+
Key: key,
365+
})
366+
)
367+
expect(await downloaded.Body?.transformToString()).toBe(payload.toString())
368+
369+
const listed = await client.send(
370+
new ListObjectsV2Command({
371+
Bucket: bucketName,
372+
Prefix: key.split('/')[0],
373+
})
374+
)
375+
expect(listed.Contents?.map((object) => object.Key)).toContain(key)
376+
377+
const deleted = await client.send(new DeleteObjectCommand({ Bucket: bucketName, Key: key }))
378+
expect(deleted.$metadata.httpStatusCode).toBe(204)
379+
} finally {
380+
await cleanupS3Bucket(client, bucketName)
381+
client.destroy()
382+
}
383+
})
342384
}
343385
)
344386

0 commit comments

Comments
 (0)