-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocalstack.test.ts
More file actions
62 lines (53 loc) · 1.53 KB
/
Copy pathlocalstack.test.ts
File metadata and controls
62 lines (53 loc) · 1.53 KB
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
import {
GetParameterCommand,
PutParameterCommand,
SSMClient,
} from '@aws-sdk/client-ssm';
import { Envilder } from '@envilder/sdk';
import {
LocalstackContainer,
type StartedLocalStackContainer,
} from '@testcontainers/localstack';
import { afterAll, beforeAll, expect, it } from 'vitest';
let localstack: StartedLocalStackContainer;
let ssm: SSMClient;
beforeAll(async () => {
localstack = await new LocalstackContainer('localstack/localstack:stable')
.withEnvironment(
Object.fromEntries(await Envilder.resolveFile('../envilder.json')),
)
.start();
ssm = new SSMClient({
endpoint: localstack.getConnectionUri(),
region: 'us-east-1',
credentials: { accessKeyId: 'test', secretAccessKey: 'test' },
});
}, 180_000);
afterAll(async () => {
await localstack?.stop();
});
it('Should_ReportSsmService_When_LocalStackIsRunning', async () => {
// Act
const response = await fetch(
new URL('/_localstack/health', localstack.getConnectionUri()),
);
const health = await response.json();
// Assert
expect(['available', 'running']).toContain(health.services.ssm);
});
it('Should_RoundTripSecureString_When_LocalStackStartsWithResolvedToken', async () => {
// Arrange
await ssm.send(
new PutParameterCommand({
Name: '/demo/secret',
Value: 'hunter2',
Type: 'SecureString',
}),
);
// Act
const actual = await ssm.send(
new GetParameterCommand({ Name: '/demo/secret', WithDecryption: true }),
);
// Assert
expect(actual.Parameter?.Value).toBe('hunter2');
});