({ config, credentials, signal })
| 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) |
no test coverage detected