-
Notifications
You must be signed in to change notification settings - Fork 29
/
index.js
107 lines (94 loc) · 3.29 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js'
import { AWSConfig } from '../dist/aws.js'
import { s3TestSuite } from './internal/s3.js'
import { secretsManagerTestSuite } from './internal/secrets-manager.js'
import { kmsTestSuite } from './internal/kms.js'
import { ssmTestSuite } from './internal/ssm.js'
import { kinesisTestSuite } from './internal/kinesis.js'
import { signatureV4TestSuite } from './internal/signature.js'
import { sqsTestSuite } from './internal/sqs.js'
import { eventBridgeTestSuite } from './internal/event-bridge.js'
import { lambdaTestSuite } from './internal/lambda.js'
// Must know:
// * end2end tests such as these rely on the localstack
// docker compose stack to be running. See the docker-compose.yml
// file in the root of the project.
// * The localstack docker compose stack is initialized with
// some data using the scripts found in tests/localstack_init/*.sh.
// These scripts are ran everytime the localstack container starts.
// The following tests rely on the data created by these scripts.
//
// Initialize an AWS configuration set to use the localstack service.
const awsConfig = new AWSConfig({
// Localstack runs on localhost:4566
endpoint: 'http://localhost.localstack.cloud:4566',
// Localstack is setup to use the us-east-1 region
region: 'us-east-1',
// Dummy value to keep the client happy
accessKeyId: 'RUSZHYJUBIXGH4A5AAIX',
// Dummy value to keep the client happy
secretAccessKey: '9g7dpx9QU4XNawNHkMnXUQ6LgTfZIPG6fnIdADDQ',
// Dummy value to keep the client happy
sessionToken: 'sessiontoken',
})
const testData = {
awsConfig: awsConfig,
// S3 tests specific data
s3: {
testBucketName: 'test-jslib-aws',
testObjects: [
{
key: 'bonjour.txt',
body: 'Bonjour le monde!',
},
{
key: 'tschuss.txt',
body: 'Tschuss, welt!',
},
{
key: 'delete.txt',
body: 'Delete me in a test!',
},
],
},
// Secrets Manager tests specific data
secretsManager: {
createdSecretName: `test-created-secret-${randomIntBetween(0, 10000)}`,
deleteSecretName: 'test-delete-secret',
testSecrets: [
{
name: 'test-secret',
secret: 'test-secret-value',
},
],
},
// Systems Manager tests specific data
systemsManager: {
testParameter: {
name: `test-parameter`,
value: `test-parameter-value`,
},
testParameterSecret: {
name: `test-parameter-secret`,
value: `test-parameter-secret-value`,
},
},
}
export const options = {
thresholds: {
// As we're essentially unit testing here, we want to make sure that
// the rate of successful checks is 100%
checks: ['rate>=1'],
}
}
export default async function() {
signatureV4TestSuite()
await s3TestSuite(testData)
await secretsManagerTestSuite(testData)
await kmsTestSuite(testData)
await sqsTestSuite(testData)
await ssmTestSuite(testData)
await kinesisTestSuite(testData)
await eventBridgeTestSuite(testData)
await lambdaTestSuite(testData)
}