| 1 | import { |
| 2 | BucketAlreadyOwnedByYou, |
| 3 | CreateBucketCommand, |
| 4 | S3Client, |
| 5 | } from '@aws-sdk/client-s3'; |
| 6 | |
| 7 | import { |
| 8 | DATABASE_URL, |
| 9 | hasBackends, |
| 10 | S3_ENDPOINT, |
| 11 | s3Credentials, |
| 12 | } from './harness.js'; |
| 13 | import { migrateTestDatabase } |
| 14 | import path from 'node:path |
| 15 | import { mkdirSync } |
| 16 | import { execFileSync } |
| 17 | |
| 18 | export default async function |
| 19 | if (!hasBackends || |
| 20 | |
| 21 | await migrateTestDatabase(DATABASE_URL |
| 22 | |
| 23 | await new S3Client |
| 24 | endpoint: S3_ENDPOINT, |
| 25 | region: 'auto', |
| 26 | forcePathStyle: true, |
| 27 | credentials: { |
| 28 | accessKeyId: s3Credentials.S3_ACCESS_KEY_ID |
| 29 | secretAccessKey: s3Credentials.S3_SECRET_ACCESS_KEY |
| 30 | }, |
| 31 | }) |
| 32 | .send(new CreateBucketCommand |
| 33 | .catch((error: |
| 34 | if (!(error |
| 35 | }); |
| 36 | |
| 37 | const host = |
| 38 | if (host) { |
| 39 | const dir = |
| 40 | mkdirSync(dir, { |
| 41 | execFileSync( |
| 42 | 'openssl', |
| 43 | [ |
| 44 | 'req', |
| 45 | '-x509', |
| 46 | '-newkey', |
| 47 | 'rsa:2048', |
| 48 | '-nodes', |
| 49 | '-days', |
| 50 | '1', |
| 51 | '-subj', |
| 52 | `/CN=${host}`, |
| 53 | '-addext', |
| 54 | // The IP lets supertest reach the same server at 127.0.0.1 while gh uses the host name. |
| 55 | `subjectAltName=DNS:${host},IP:127.0.0.1` |
| 56 | '-keyout', |
| 57 | path.join(dir |
| 58 | '-out', |
| 59 | path.join(dir |
| 60 | ], |
| 61 | { stdio: 'ignore' |
| 62 | ); |
| 63 | } |
| 64 | } |