MCPcopy
hub / github.com/simstudioai/sim / test

Function test

apps/sim/lib/data-drains/destinations/s3.ts:167–200  ·  view source on GitHub ↗
({ config, credentials, signal })

Source from the content-addressed store, hash-verified

165 credentialsSchema: s3CredentialsSchema,
166
167 async test({ config, credentials, signal }) {
168 await assertEndpointIsPublic(config.endpoint)
169 const client = buildClient(config, credentials)
170 /** Real write probe so write-only IAM policies surface here, not at first run. */
171 const probeKey = `${normalizePrefix(config.prefix)}.sim-drain-write-probe/${generateShortId(12)}`
172 try {
173 await withS3ErrorContext('test-put', () =>
174 client.send(
175 new PutObjectCommand({
176 Bucket: config.bucket,
177 Key: probeKey,
178 Body: Buffer.alloc(0),
179 ContentType: 'application/octet-stream',
180 ServerSideEncryption: 'AES256',
181 }),
182 { abortSignal: signal }
183 )
184 )
185 /** Best-effort cleanup: write was already proven, so a missing s3:DeleteObject must not fail the test. */
186 try {
187 await client.send(new DeleteObjectCommand({ Bucket: config.bucket, Key: probeKey }), {
188 abortSignal: signal,
189 })
190 } catch (cleanupError) {
191 logger.debug('S3 test write probe cleanup failed (non-fatal)', {
192 bucket: config.bucket,
193 key: probeKey,
194 error: cleanupError,
195 })
196 }
197 } finally {
198 client.destroy()
199 }
200 },
201
202 openSession({ config, credentials }) {
203 const client = buildClient(config, credentials)

Callers 4

index.test.tsFile · 0.50
logger.test.tsFile · 0.50

Calls 8

normalizePrefixFunction · 0.90
generateShortIdFunction · 0.90
assertEndpointIsPublicFunction · 0.85
buildClientFunction · 0.85
withS3ErrorContextFunction · 0.85
sendMethod · 0.80
debugMethod · 0.80
destroyMethod · 0.65

Tested by

no test coverage detected