-
Notifications
You must be signed in to change notification settings - Fork 189
Expand file tree
/
Copy pathapi-keys-multiple.e2e.test.ts
More file actions
45 lines (39 loc) · 1.25 KB
/
api-keys-multiple.e2e.test.ts
File metadata and controls
45 lines (39 loc) · 1.25 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
import { synthesize } from './helpers/synthesize';
import {
countResourcesByType,
findResourcesByType,
} from './helpers/assertions';
describe('examples/api-keys-multiple', () => {
let result: ReturnType<typeof synthesize>;
beforeAll(() => {
result = synthesize('examples/api-keys-multiple');
});
afterAll(() => {
result.cleanup();
});
it('creates three distinct API key resources', () => {
expect(countResourcesByType(result.template, 'AWS::AppSync::ApiKey')).toBe(
3,
);
});
it('each API key has its own description matching the config', () => {
const keys = findResourcesByType(result.template, 'AWS::AppSync::ApiKey');
const descriptions = keys
.map((k) => k.resource.Properties?.Description as string)
.sort();
expect(descriptions).toEqual([
'Internal testing',
'Mobile app key',
'Web app key',
]);
});
it('each API key has an expiry set', () => {
const keys = findResourcesByType(result.template, 'AWS::AppSync::ApiKey');
keys.forEach((k) => {
// The plugin computes an absolute Unix timestamp for Expires
const expires = k.resource.Properties?.Expires;
expect(expires).toBeDefined();
expect(typeof expires).toBe('number');
});
});
});