@mapbox/cloudfriend 9.2.0 → 9.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/changelog.md +4 -0
  2. package/coverage/clover.xml +598 -0
  3. package/coverage/coverage-final.json +32 -0
  4. package/coverage/lcov-report/base.css +224 -0
  5. package/coverage/lcov-report/block-navigation.js +87 -0
  6. package/coverage/lcov-report/cloudfriend/bin/build-template.js.html +130 -0
  7. package/coverage/lcov-report/cloudfriend/bin/index.html +131 -0
  8. package/coverage/lcov-report/cloudfriend/bin/validate-template.js.html +142 -0
  9. package/coverage/lcov-report/cloudfriend/index.html +116 -0
  10. package/coverage/lcov-report/cloudfriend/index.js.html +307 -0
  11. package/coverage/lcov-report/cloudfriend/lib/build.js.html +217 -0
  12. package/coverage/lcov-report/cloudfriend/lib/conditions.js.html +430 -0
  13. package/coverage/lcov-report/cloudfriend/lib/index.html +206 -0
  14. package/coverage/lcov-report/cloudfriend/lib/intrinsic.js.html +979 -0
  15. package/coverage/lcov-report/cloudfriend/lib/merge.js.html +478 -0
  16. package/coverage/lcov-report/cloudfriend/lib/pseudo.js.html +370 -0
  17. package/coverage/lcov-report/cloudfriend/lib/rules.js.html +349 -0
  18. package/coverage/lcov-report/cloudfriend/lib/shortcuts/cross-account-role.js.html +244 -0
  19. package/coverage/lcov-report/cloudfriend/lib/shortcuts/event-lambda.js.html +367 -0
  20. package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-database.js.html +286 -0
  21. package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-json-table.js.html +235 -0
  22. package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-orc-table.js.html +226 -0
  23. package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-parquet-table.js.html +268 -0
  24. package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-presto-view.js.html +358 -0
  25. package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-spark-view.js.html +241 -0
  26. package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-table.js.html +481 -0
  27. package/coverage/lcov-report/cloudfriend/lib/shortcuts/hookshot.js.html +1504 -0
  28. package/coverage/lcov-report/cloudfriend/lib/shortcuts/index.html +416 -0
  29. package/coverage/lcov-report/cloudfriend/lib/shortcuts/index.js.html +154 -0
  30. package/coverage/lcov-report/cloudfriend/lib/shortcuts/kinesis-firehose-base.js.html +418 -0
  31. package/coverage/lcov-report/cloudfriend/lib/shortcuts/lambda.js.html +832 -0
  32. package/coverage/lcov-report/cloudfriend/lib/shortcuts/log-subscription-lambda.js.html +310 -0
  33. package/coverage/lcov-report/cloudfriend/lib/shortcuts/queue-lambda.js.html +364 -0
  34. package/coverage/lcov-report/cloudfriend/lib/shortcuts/queue.js.html +619 -0
  35. package/coverage/lcov-report/cloudfriend/lib/shortcuts/role.js.html +382 -0
  36. package/coverage/lcov-report/cloudfriend/lib/shortcuts/s3-kinesis-firehose.js.html +568 -0
  37. package/coverage/lcov-report/cloudfriend/lib/shortcuts/scheduled-lambda.js.html +490 -0
  38. package/coverage/lcov-report/cloudfriend/lib/shortcuts/service-role.js.html +307 -0
  39. package/coverage/lcov-report/cloudfriend/lib/shortcuts/stream-lambda.js.html +493 -0
  40. package/coverage/lcov-report/cloudfriend/lib/validate.js.html +154 -0
  41. package/coverage/lcov-report/favicon.png +0 -0
  42. package/coverage/lcov-report/index.html +161 -0
  43. package/coverage/lcov-report/prettify.css +1 -0
  44. package/coverage/lcov-report/prettify.js +2 -0
  45. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  46. package/coverage/lcov-report/sorter.js +210 -0
  47. package/coverage/lcov.info +1240 -0
  48. package/jest.config.js +14 -0
  49. package/package.json +15 -13
  50. package/readme.md +1 -1
  51. package/test/bin.test.js +18 -14
  52. package/test/fixtures/shortcuts/cross-account-role-defaults.json +1 -1
  53. package/test/fixtures/shortcuts/cross-account-role-no-defaults.json +1 -1
  54. package/test/fixtures/shortcuts/event-lambda-defaults.json +1 -1
  55. package/test/fixtures/shortcuts/event-lambda-full.json +1 -1
  56. package/test/fixtures/shortcuts/firehose-defaults.json +1 -1
  57. package/test/fixtures/shortcuts/firehose-with-stream.json +1 -1
  58. package/test/fixtures/shortcuts/glue-database-defaults.json +1 -1
  59. package/test/fixtures/shortcuts/glue-database-no-defaults.json +1 -1
  60. package/test/fixtures/shortcuts/glue-json-table-defaults.json +1 -1
  61. package/test/fixtures/shortcuts/glue-json-table-no-defaults.json +1 -1
  62. package/test/fixtures/shortcuts/glue-orc-table-defaults.json +1 -1
  63. package/test/fixtures/shortcuts/glue-orc-table-no-defaults.json +1 -1
  64. package/test/fixtures/shortcuts/glue-parquet-table-defaults.json +1 -1
  65. package/test/fixtures/shortcuts/glue-parquet-table-no-defaults.json +1 -1
  66. package/test/fixtures/shortcuts/glue-table-defaults.json +1 -1
  67. package/test/fixtures/shortcuts/glue-table-no-defaults.json +1 -1
  68. package/test/fixtures/shortcuts/glue-view-defaults.json +1 -1
  69. package/test/fixtures/shortcuts/glue-view-no-defaults.json +1 -1
  70. package/test/fixtures/shortcuts/hookshot-github-secret-ref.json +1 -1
  71. package/test/fixtures/shortcuts/hookshot-github-secret-string.json +1 -1
  72. package/test/fixtures/shortcuts/hookshot-github.json +1 -1
  73. package/test/fixtures/shortcuts/hookshot-passthrough-access-log-format.json +1 -1
  74. package/test/fixtures/shortcuts/hookshot-passthrough-alarms.json +1 -1
  75. package/test/fixtures/shortcuts/hookshot-passthrough-enhanced-logging.json +1 -1
  76. package/test/fixtures/shortcuts/hookshot-passthrough-full-blown-logging.json +1 -1
  77. package/test/fixtures/shortcuts/hookshot-passthrough-logging.json +1 -1
  78. package/test/fixtures/shortcuts/hookshot-passthrough.json +1 -1
  79. package/test/fixtures/shortcuts/lambda-defaults.json +1 -1
  80. package/test/fixtures/shortcuts/lambda-docker.json +1 -1
  81. package/test/fixtures/shortcuts/lambda-full.json +1 -1
  82. package/test/fixtures/shortcuts/lambda-provided-role.json +1 -1
  83. package/test/fixtures/shortcuts/lambda-zipfile.json +1 -1
  84. package/test/fixtures/shortcuts/log-subscription-lambda-defaults.json +1 -1
  85. package/test/fixtures/shortcuts/log-subscription-lambda-no-defaults.json +1 -1
  86. package/test/fixtures/shortcuts/queue-defaults.json +1 -1
  87. package/test/fixtures/shortcuts/queue-external-topic-ref.json +1 -1
  88. package/test/fixtures/shortcuts/queue-external-topic.json +1 -1
  89. package/test/fixtures/shortcuts/queue-fifo-queuename.json +1 -1
  90. package/test/fixtures/shortcuts/queue-fifo.json +1 -1
  91. package/test/fixtures/shortcuts/queue-full.json +1 -1
  92. package/test/fixtures/shortcuts/queue-lambda-zero.json +1 -1
  93. package/test/fixtures/shortcuts/queue-lambda.json +1 -1
  94. package/test/fixtures/shortcuts/role-defaults.json +1 -1
  95. package/test/fixtures/shortcuts/role-no-defaults.json +1 -1
  96. package/test/fixtures/shortcuts/scheduled-lambda-defaults.json +1 -1
  97. package/test/fixtures/shortcuts/scheduled-lambda-full.json +1 -1
  98. package/test/fixtures/shortcuts/service-role-defaults.json +1 -1
  99. package/test/fixtures/shortcuts/service-role-no-defaults.json +1 -1
  100. package/test/fixtures/shortcuts/service-role-no-url-suffix.json +1 -1
  101. package/test/fixtures/shortcuts/service-role-url-suffix-with-replacement.json +1 -1
  102. package/test/fixtures/shortcuts/service-role-url-suffix.json +1 -1
  103. package/test/fixtures/shortcuts/stream-lambda-defaults.json +1 -1
  104. package/test/fixtures/shortcuts/stream-lambda-no-defaults.json +1 -1
  105. package/test/index.test.js +383 -235
  106. package/test/shortcuts.test.js +1224 -1475
  107. package/.nyc_output/2b544c0b-2830-4ad0-97cd-8e661710b0bb.json +0 -1
  108. package/.nyc_output/65e58b48-bf1c-412d-8dd4-d7b564b12d76.json +0 -1
  109. package/.nyc_output/processinfo/2b544c0b-2830-4ad0-97cd-8e661710b0bb.json +0 -1
  110. package/.nyc_output/processinfo/65e58b48-bf1c-412d-8dd4-d7b564b12d76.json +0 -1
  111. package/.nyc_output/processinfo/index.json +0 -1
@@ -3,7 +3,6 @@
3
3
  const cp = require('child_process');
4
4
  const path = require('path');
5
5
  const fs = require('fs');
6
- const test = require('tape');
7
6
  const cf = require('..');
8
7
  const fixtures = require('./fixtures/shortcuts');
9
8
  const util = require('util');
@@ -13,7 +12,7 @@ const update = !!process.env.UPDATE;
13
12
 
14
13
  const noUndefined = (template) => JSON.parse(JSON.stringify(template));
15
14
 
16
- test('[shortcuts] fixture validation', async (assert) => {
15
+ describe('[shortcuts] fixture validation', () => {
17
16
  // Runs cfn-lint, ignoring "warnings". Install via pip or Homebrew to run these
18
17
  // tests locally.
19
18
  const cfnLint = (filepath) => new Promise((resolve, reject) => {
@@ -27,36 +26,25 @@ test('[shortcuts] fixture validation', async (assert) => {
27
26
  .readdirSync(path.join(__dirname, 'fixtures', 'shortcuts'))
28
27
  .filter((filename) => path.extname(filename) === '.json');
29
28
 
30
- while (toValidate.length) {
31
- const filename = toValidate.shift();
29
+ test.each(toValidate)('%s fixture passes validation', async (filename) => {
32
30
  await Promise.all([
33
- cfnLint(path.join(__dirname, 'fixtures', 'shortcuts', filename))
34
- .then(() => assert.pass(`${filename} fixture passed validation`))
35
- .catch((err) => {
36
- assert.fail(`${filename} fixture fails validation`);
37
- console.log(err.message);
38
- }),
31
+ cfnLint(path.join(__dirname, 'fixtures', 'shortcuts', filename)),
39
32
  sleep(1000)
40
33
  ]);
41
- }
42
-
43
- assert.end();
34
+ });
44
35
  });
45
36
 
46
- test('[shortcuts] lambda', (assert) => {
47
- assert.throws(
48
- () => new cf.shortcuts.Lambda(),
49
- 'Options required',
50
- 'throws without options'
51
- );
52
- assert.throws(
53
- () => new cf.shortcuts.Lambda({}),
54
- /You must provide a LogicalName, and Code/,
55
- 'throws without required parameters'
56
- );
37
+ describe('[shortcuts] lambda', () => {
38
+ test('throws without options', () => {
39
+ expect(() => new cf.shortcuts.Lambda()).toThrow('Options required');
40
+ });
41
+
42
+ test('throws without required parameters', () => {
43
+ expect(() => new cf.shortcuts.Lambda({})).toThrow(/You must provide a LogicalName, and Code/);
44
+ });
57
45
 
58
- assert.throws(
59
- () => new cf.shortcuts.Lambda({
46
+ test('throws for RoleArn and Statements both provided', () => {
47
+ expect(() => new cf.shortcuts.Lambda({
60
48
  LogicalName: 'MyLambda',
61
49
  Code: {
62
50
  S3Bucket: 'my-code-bucket',
@@ -68,469 +56,400 @@ test('[shortcuts] lambda', (assert) => {
68
56
  Action: 's3:GetObject',
69
57
  Resource: 'arn:aws:s3:::my-bucket/*'
70
58
  }]
71
- }),
72
- /You cannot specify both Statements and a RoleArn/,
73
- 'throws for RoleArn and Statements both provided'
74
- );
75
-
76
- let lambda = new cf.shortcuts.Lambda({
77
- LogicalName: 'MyLambda',
78
- Code: {
79
- S3Bucket: 'my-code-bucket',
80
- S3Key: 'path/to/code.zip'
81
- }
59
+ })).toThrow(/You cannot specify both Statements and a RoleArn/);
82
60
  });
83
61
 
84
- let template = cf.merge(lambda);
85
- if (update) fixtures.update('lambda-defaults', template);
86
- assert.deepEqual(
87
- noUndefined(template),
88
- fixtures.get('lambda-defaults'),
89
- 'expected resources generated using all default values'
90
- );
62
+ test('expected resources generated using all default values', () => {
63
+ const lambda = new cf.shortcuts.Lambda({
64
+ LogicalName: 'MyLambda',
65
+ Code: {
66
+ S3Bucket: 'my-code-bucket',
67
+ S3Key: 'path/to/code.zip'
68
+ }
69
+ });
91
70
 
92
- const lambdaWithRetain = new cf.shortcuts.Lambda({
93
- LogicalName: 'MyLambda',
94
- Code: { S3Bucket: 'my-code-bucket', S3Key: 'path/to/code.zip' },
95
- LogPolicyDeletionPolicy: 'Retain'
71
+ const template = cf.merge(lambda);
72
+ if (update) fixtures.update('lambda-defaults', template);
73
+ expect(noUndefined(template)).toEqual(fixtures.get('lambda-defaults'));
96
74
  });
97
- const templateWithRetain = cf.merge(lambdaWithRetain);
98
- assert.equal(
99
- templateWithRetain.Resources.MyLambdaLogPolicy.DeletionPolicy,
100
- 'Retain',
101
- 'LogPolicyDeletionPolicy=Retain sets DeletionPolicy on IAM Policy resource'
102
- );
103
75
 
104
- lambda = new cf.shortcuts.Lambda({
105
- LogicalName: 'MyLambda',
106
- Code: {
107
- ImageUri: 'MyImage'
108
- }
76
+ test('LogPolicyDeletionPolicy=Retain sets DeletionPolicy on IAM Policy resource', () => {
77
+ const lambdaWithRetain = new cf.shortcuts.Lambda({
78
+ LogicalName: 'MyLambda',
79
+ Code: { S3Bucket: 'my-code-bucket', S3Key: 'path/to/code.zip' },
80
+ LogPolicyDeletionPolicy: 'Retain'
81
+ });
82
+ const templateWithRetain = cf.merge(lambdaWithRetain);
83
+ expect(templateWithRetain.Resources.MyLambdaLogPolicy.DeletionPolicy).toBe('Retain');
109
84
  });
110
85
 
111
- template = cf.merge(lambda);
112
- if (update) fixtures.update('lambda-docker', template);
113
- assert.deepEqual(
114
- noUndefined(template),
115
- fixtures.get('lambda-docker'),
116
- 'expected resources generated using all default values and a docker image'
117
- );
86
+ test('expected resources generated using all default values and a docker image', () => {
87
+ const lambda = new cf.shortcuts.Lambda({
88
+ LogicalName: 'MyLambda',
89
+ Code: {
90
+ ImageUri: 'MyImage'
91
+ }
92
+ });
118
93
 
119
- lambda = new cf.shortcuts.Lambda({
120
- LogicalName: 'MyLambda',
121
- Code: {
122
- ZipFile: 'fake code'
123
- }
94
+ const template = cf.merge(lambda);
95
+ if (update) fixtures.update('lambda-docker', template);
96
+ expect(noUndefined(template)).toEqual(fixtures.get('lambda-docker'));
124
97
  });
125
98
 
126
- template = cf.merge(lambda);
127
- if (update) fixtures.update('lambda-zipfile', template);
128
- assert.deepEqual(
129
- noUndefined(template),
130
- fixtures.get('lambda-zipfile'),
131
- 'expected resources generated using all default values and inline code'
132
- );
99
+ test('expected resources generated using all default values and inline code', () => {
100
+ const lambda = new cf.shortcuts.Lambda({
101
+ LogicalName: 'MyLambda',
102
+ Code: {
103
+ ZipFile: 'fake code'
104
+ }
105
+ });
133
106
 
134
- lambda = new cf.shortcuts.Lambda({
135
- LogicalName: 'MyLambda',
136
- Code: {
137
- S3Bucket: 'my-code-bucket',
138
- S3Key: 'path/to/code.zip'
139
- },
140
- RoleArn: cf.getAtt('CustomLambdaRole', 'Arn')
141
- });
142
-
143
- template = cf.merge(lambda, {
144
- Resources: {
145
- 'CustomLambdaRole': {
146
- Type: 'AWS::IAM::Role',
147
- Properties: {
148
- AssumeRolePolicyDocument: {}
107
+ const template = cf.merge(lambda);
108
+ if (update) fixtures.update('lambda-zipfile', template);
109
+ expect(noUndefined(template)).toEqual(fixtures.get('lambda-zipfile'));
110
+ });
111
+
112
+ test('expected resources generated if RoleArn provided', () => {
113
+ const lambda = new cf.shortcuts.Lambda({
114
+ LogicalName: 'MyLambda',
115
+ Code: {
116
+ S3Bucket: 'my-code-bucket',
117
+ S3Key: 'path/to/code.zip'
118
+ },
119
+ RoleArn: cf.getAtt('CustomLambdaRole', 'Arn')
120
+ });
121
+
122
+ const template = cf.merge(lambda, {
123
+ Resources: {
124
+ 'CustomLambdaRole': {
125
+ Type: 'AWS::IAM::Role',
126
+ Properties: {
127
+ AssumeRolePolicyDocument: {}
128
+ }
149
129
  }
150
130
  }
151
- }
131
+ });
132
+ if (update) fixtures.update('lambda-provided-role', template);
133
+ expect(noUndefined(template)).toEqual(fixtures.get('lambda-provided-role'));
152
134
  });
153
- if (update) fixtures.update('lambda-provided-role', template);
154
- assert.deepEqual(
155
- noUndefined(template),
156
- fixtures.get('lambda-provided-role'),
157
- 'expected resources generated if RoleArn provided'
158
- );
159
135
 
160
- lambda = new cf.shortcuts.Lambda({
161
- LogicalName: 'MyLambda',
162
- Code: {
163
- S3Bucket: 'my-code-bucket',
164
- S3Key: 'path/to/code.zip'
165
- },
166
- DeadLetterConfig: {
167
- TargetArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake'
168
- },
169
- Description: 'my description',
170
- Environment: { Variables: { MyCoolEnv: 'a' } },
171
- FunctionName: 'my-function',
172
- Handler: 'index.something',
173
- KmsKeyArn: 'arn:aws:kms:us-east-1:123456789012:key/fake',
174
- Layers: ['arn:aws:lambda:us-east-2:590474943231:layer:AWS-Parameters-and-Secrets-Lambda-Extension:4'],
175
- MemorySize: 512,
176
- ReservedConcurrentExecutions: 10,
177
- Runtime: 'nodejs22.x',
178
- Tags: [{ Key: 'a', Value: 'b' }],
179
- Timeout: 30,
180
- TracingConfig: { Mode: 'Active' },
181
- VpcConfig: {
182
- SecurityGroupIds: ['sg-12345678'],
183
- SubnetIds: ['fake']
184
- },
185
- Condition: 'Always',
186
- DependsOn: 'AnotherThing',
187
- Statement: [
188
- {
189
- Effect: 'Allow',
190
- Action: 's3:GetObject',
191
- Resource: 'arn:aws:s3:::fake/data'
192
- }
193
- ],
194
- AlarmName: 'my-alarm',
195
- AlarmDescription: 'some alarm',
196
- AlarmActions: ['devnull@mapbox.com'],
197
- Period: 120,
198
- EvaluationPeriods: 2,
199
- Statistic: 'Minimum',
200
- Threshold: 10,
201
- ComparisonOperator: 'LessThanThreshold',
202
- TreatMissingData: 'breaching',
203
- EvaluateLowSampleCountPercentile: 'ignore',
204
- ExtendedStatistics: 'p100',
205
- OKActions: ['devnull@mapbox.com'],
206
- LogRetentionInDays: 30
207
- });
208
-
209
- template = cf.merge(
210
- { Conditions: { Always: cf.equals('1', '1') } },
211
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
212
- lambda
213
- );
214
- if (update) fixtures.update('lambda-full', template);
215
- assert.deepEqual(
216
- noUndefined(template),
217
- fixtures.get('lambda-full'),
218
- 'expected resources generated using no default values'
219
- );
136
+ test('expected resources generated using no default values', () => {
137
+ const lambda = new cf.shortcuts.Lambda({
138
+ LogicalName: 'MyLambda',
139
+ Code: {
140
+ S3Bucket: 'my-code-bucket',
141
+ S3Key: 'path/to/code.zip'
142
+ },
143
+ DeadLetterConfig: {
144
+ TargetArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake'
145
+ },
146
+ Description: 'my description',
147
+ Environment: { Variables: { MyCoolEnv: 'a' } },
148
+ FunctionName: 'my-function',
149
+ Handler: 'index.something',
150
+ KmsKeyArn: 'arn:aws:kms:us-east-1:123456789012:key/fake',
151
+ Layers: ['arn:aws:lambda:us-east-2:590474943231:layer:AWS-Parameters-and-Secrets-Lambda-Extension:4'],
152
+ MemorySize: 512,
153
+ ReservedConcurrentExecutions: 10,
154
+ Runtime: 'nodejs22.x',
155
+ Tags: [{ Key: 'a', Value: 'b' }],
156
+ Timeout: 30,
157
+ TracingConfig: { Mode: 'Active' },
158
+ VpcConfig: {
159
+ SecurityGroupIds: ['sg-12345678'],
160
+ SubnetIds: ['fake']
161
+ },
162
+ Condition: 'Always',
163
+ DependsOn: 'AnotherThing',
164
+ Statement: [
165
+ {
166
+ Effect: 'Allow',
167
+ Action: 's3:GetObject',
168
+ Resource: 'arn:aws:s3:::fake/data'
169
+ }
170
+ ],
171
+ AlarmName: 'my-alarm',
172
+ AlarmDescription: 'some alarm',
173
+ AlarmActions: ['devnull@mapbox.com'],
174
+ Period: 120,
175
+ EvaluationPeriods: 2,
176
+ Statistic: 'Minimum',
177
+ Threshold: 10,
178
+ ComparisonOperator: 'LessThanThreshold',
179
+ TreatMissingData: 'breaching',
180
+ EvaluateLowSampleCountPercentile: 'ignore',
181
+ ExtendedStatistics: 'p100',
182
+ OKActions: ['devnull@mapbox.com'],
183
+ LogRetentionInDays: 30
184
+ });
220
185
 
221
- lambda = new cf.shortcuts.Lambda({
222
- LogicalName: 'MyLambda',
223
- Code: {
224
- S3Bucket: 'my-code-bucket',
225
- S3Key: 'path/to/code.zip'
226
- },
227
- LogPolicyName: 'CustomLogPolicyName'
186
+ const template = cf.merge(
187
+ { Conditions: { Always: cf.equals('1', '1') } },
188
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
189
+ lambda
190
+ );
191
+ if (update) fixtures.update('lambda-full', template);
192
+ expect(noUndefined(template)).toEqual(fixtures.get('lambda-full'));
228
193
  });
229
194
 
230
- template = cf.merge(lambda);
231
- assert.equal(
232
- template.Resources.MyLambdaLogPolicy.Properties.PolicyName,
233
- 'CustomLogPolicyName',
234
- 'LogPolicyName parameter correctly overrides the default policy name'
235
- );
195
+ test('LogPolicyName parameter correctly overrides the default policy name', () => {
196
+ const lambda = new cf.shortcuts.Lambda({
197
+ LogicalName: 'MyLambda',
198
+ Code: {
199
+ S3Bucket: 'my-code-bucket',
200
+ S3Key: 'path/to/code.zip'
201
+ },
202
+ LogPolicyName: 'CustomLogPolicyName'
203
+ });
236
204
 
237
- assert.end();
205
+ const template = cf.merge(lambda);
206
+ expect(template.Resources.MyLambdaLogPolicy.Properties.PolicyName).toBe('CustomLogPolicyName');
207
+ });
238
208
  });
239
209
 
240
- test('[shortcuts] queue-lambda', (assert) => {
241
- assert.throws(
242
- () => new cf.shortcuts.QueueLambda(),
243
- 'Options required',
244
- 'throws without options'
245
- );
246
- assert.throws(
247
- () => new cf.shortcuts.QueueLambda({}),
248
- /You must provide a LogicalName, and Code/,
249
- 'throws without basic lambda required parameters'
250
- );
210
+ describe('[shortcuts] queue-lambda', () => {
211
+ test('throws without options', () => {
212
+ expect(() => new cf.shortcuts.QueueLambda()).toThrow('Options required');
213
+ });
251
214
 
252
- assert.throws(
253
- () =>
254
- new cf.shortcuts.QueueLambda({
255
- LogicalName: 'MyLambda',
256
- Code: {
257
- S3Bucket: 'my-code-bucket',
258
- S3Key: 'path/to/code.zip'
259
- }
260
- }),
261
- /You must provide an EventSourceArn and ReservedConcurrentExecutions/,
262
- 'throws without queue-lambda required parameters'
263
- );
215
+ test('throws without basic lambda required parameters', () => {
216
+ expect(() => new cf.shortcuts.QueueLambda({})).toThrow(/You must provide a LogicalName, and Code/);
217
+ });
264
218
 
265
- assert.throws(
266
- () =>
267
- new cf.shortcuts.QueueLambda({
268
- LogicalName: 'MyLambda',
269
- Code: {
270
- S3Bucket: 'my-code-bucket',
271
- S3Key: 'path/to/code.zip'
272
- },
273
- EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake',
274
- ReservedConcurrentExecutions: -1
275
- }),
276
- /ReservedConcurrentExecutions must be greater than or equal to 0/,
277
- 'throws when ReservedConcurrentExecutions is a negative number'
278
- );
219
+ test('throws without queue-lambda required parameters', () => {
220
+ expect(() => new cf.shortcuts.QueueLambda({
221
+ LogicalName: 'MyLambda',
222
+ Code: {
223
+ S3Bucket: 'my-code-bucket',
224
+ S3Key: 'path/to/code.zip'
225
+ }
226
+ })).toThrow(/You must provide an EventSourceArn and ReservedConcurrentExecutions/);
227
+ });
279
228
 
280
- const zeroLambda = new cf.shortcuts.QueueLambda({
281
- LogicalName: 'MyLambda',
282
- Code: {
283
- S3Bucket: 'my-code-bucket',
284
- S3Key: 'path/to/code.zip'
285
- },
286
- EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake',
287
- ReservedConcurrentExecutions: 0
288
- });
289
- const zeroTemplate = cf.merge(zeroLambda);
290
- if (update) fixtures.update('queue-lambda-zero', zeroTemplate);
291
- assert.deepEqual(
292
- noUndefined(zeroTemplate),
293
- fixtures.get('queue-lambda-zero'),
294
- 'expected resources generated'
295
- );
229
+ test('throws when ReservedConcurrentExecutions is a negative number', () => {
230
+ expect(() => new cf.shortcuts.QueueLambda({
231
+ LogicalName: 'MyLambda',
232
+ Code: {
233
+ S3Bucket: 'my-code-bucket',
234
+ S3Key: 'path/to/code.zip'
235
+ },
236
+ EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake',
237
+ ReservedConcurrentExecutions: -1
238
+ })).toThrow(/ReservedConcurrentExecutions must be greater than or equal to 0/);
239
+ });
296
240
 
297
- const lambda = new cf.shortcuts.QueueLambda({
298
- LogicalName: 'MyLambda',
299
- Code: {
300
- S3Bucket: 'my-code-bucket',
301
- S3Key: 'path/to/code.zip'
302
- },
303
- EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake',
304
- ReservedConcurrentExecutions: 10
305
- });
306
-
307
- const template = cf.merge(lambda);
308
- if (update) fixtures.update('queue-lambda', template);
309
- assert.deepEqual(
310
- noUndefined(template),
311
- fixtures.get('queue-lambda'),
312
- 'expected resources generated'
313
- );
241
+ test('expected resources generated with zero concurrency', () => {
242
+ const zeroLambda = new cf.shortcuts.QueueLambda({
243
+ LogicalName: 'MyLambda',
244
+ Code: {
245
+ S3Bucket: 'my-code-bucket',
246
+ S3Key: 'path/to/code.zip'
247
+ },
248
+ EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake',
249
+ ReservedConcurrentExecutions: 0
250
+ });
251
+ const zeroTemplate = cf.merge(zeroLambda);
252
+ if (update) fixtures.update('queue-lambda-zero', zeroTemplate);
253
+ expect(noUndefined(zeroTemplate)).toEqual(fixtures.get('queue-lambda-zero'));
254
+ });
255
+
256
+ test('expected resources generated', () => {
257
+ const lambda = new cf.shortcuts.QueueLambda({
258
+ LogicalName: 'MyLambda',
259
+ Code: {
260
+ S3Bucket: 'my-code-bucket',
261
+ S3Key: 'path/to/code.zip'
262
+ },
263
+ EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake',
264
+ ReservedConcurrentExecutions: 10
265
+ });
314
266
 
315
- assert.end();
267
+ const template = cf.merge(lambda);
268
+ if (update) fixtures.update('queue-lambda', template);
269
+ expect(noUndefined(template)).toEqual(fixtures.get('queue-lambda'));
270
+ });
316
271
  });
317
272
 
318
- test('[shortcuts] scheduled-lambda', (assert) => {
319
- assert.throws(
320
- () => new cf.shortcuts.ScheduledLambda(),
321
- 'Options required',
322
- 'throws without options'
323
- );
324
- assert.throws(
325
- () => new cf.shortcuts.ScheduledLambda({}),
326
- /You must provide a LogicalName, and Code/,
327
- 'throws without basic lambda required parameters'
328
- );
273
+ describe('[shortcuts] scheduled-lambda', () => {
274
+ test('throws without options', () => {
275
+ expect(() => new cf.shortcuts.ScheduledLambda()).toThrow('Options required');
276
+ });
329
277
 
330
- assert.throws(
331
- () =>
332
- new cf.shortcuts.ScheduledLambda({
333
- LogicalName: 'MyLambda',
334
- Code: {
335
- S3Bucket: 'my-code-bucket',
336
- S3Key: 'path/to/code.zip'
337
- }
338
- }),
339
- /You must provide a ScheduleExpression/,
340
- 'throws without scheduled-lambda required parameters'
341
- );
278
+ test('throws without basic lambda required parameters', () => {
279
+ expect(() => new cf.shortcuts.ScheduledLambda({})).toThrow(/You must provide a LogicalName, and Code/);
280
+ });
342
281
 
343
- let lambda = new cf.shortcuts.ScheduledLambda({
344
- LogicalName: 'MyLambda',
345
- Code: {
346
- S3Bucket: 'my-code-bucket',
347
- S3Key: 'path/to/code.zip'
348
- },
349
- ScheduleExpression: 'rate(1 hour)'
350
- });
351
-
352
- let template = cf.merge(lambda);
353
- if (update) fixtures.update('scheduled-lambda-defaults', template);
354
- assert.deepEqual(
355
- noUndefined(template),
356
- fixtures.get('scheduled-lambda-defaults'),
357
- 'expected resources generated with defaults'
358
- );
282
+ test('throws without scheduled-lambda required parameters', () => {
283
+ expect(() => new cf.shortcuts.ScheduledLambda({
284
+ LogicalName: 'MyLambda',
285
+ Code: {
286
+ S3Bucket: 'my-code-bucket',
287
+ S3Key: 'path/to/code.zip'
288
+ }
289
+ })).toThrow(/You must provide a ScheduleExpression/);
290
+ });
359
291
 
360
- lambda = new cf.shortcuts.ScheduledLambda({
361
- LogicalName: 'MyLambda',
362
- Code: {
363
- S3Bucket: 'my-code-bucket',
364
- S3Key: 'path/to/code.zip'
365
- },
366
- ScheduleRoleArn: 'arn:aws:iam::012345678901:role/MyCoolRole',
367
- ScheduleGroupName: 'my-cool-stack',
368
- ScheduleExpression: 'rate(1 hour)',
369
- State: 'DISABLED'
370
- });
371
-
372
- template = cf.merge(lambda);
373
- if (update) fixtures.update('scheduled-lambda-full', template);
374
- assert.deepEqual(
375
- noUndefined(template),
376
- fixtures.get('scheduled-lambda-full'),
377
- 'expected resources generated without defaults'
378
- );
292
+ test('expected resources generated with defaults', () => {
293
+ const lambda = new cf.shortcuts.ScheduledLambda({
294
+ LogicalName: 'MyLambda',
295
+ Code: {
296
+ S3Bucket: 'my-code-bucket',
297
+ S3Key: 'path/to/code.zip'
298
+ },
299
+ ScheduleExpression: 'rate(1 hour)'
300
+ });
379
301
 
380
- assert.end();
302
+ const template = cf.merge(lambda);
303
+ if (update) fixtures.update('scheduled-lambda-defaults', template);
304
+ expect(noUndefined(template)).toEqual(fixtures.get('scheduled-lambda-defaults'));
305
+ });
306
+
307
+ test('expected resources generated without defaults', () => {
308
+ const lambda = new cf.shortcuts.ScheduledLambda({
309
+ LogicalName: 'MyLambda',
310
+ Code: {
311
+ S3Bucket: 'my-code-bucket',
312
+ S3Key: 'path/to/code.zip'
313
+ },
314
+ ScheduleRoleArn: 'arn:aws:iam::012345678901:role/MyCoolRole',
315
+ ScheduleGroupName: 'my-cool-stack',
316
+ ScheduleExpression: 'rate(1 hour)',
317
+ State: 'DISABLED'
318
+ });
319
+
320
+ const template = cf.merge(lambda);
321
+ if (update) fixtures.update('scheduled-lambda-full', template);
322
+ expect(noUndefined(template)).toEqual(fixtures.get('scheduled-lambda-full'));
323
+ });
381
324
  });
382
325
 
383
- test('[shortcuts] event-lambda', (assert) => {
384
- assert.throws(
385
- () => new cf.shortcuts.EventLambda(),
386
- 'Options required',
387
- 'throws without options'
388
- );
389
- assert.throws(
390
- () => new cf.shortcuts.EventLambda({}),
391
- /You must provide a LogicalName, and Code/,
392
- 'throws without basic lambda required parameters'
393
- );
326
+ describe('[shortcuts] event-lambda', () => {
327
+ test('throws without options', () => {
328
+ expect(() => new cf.shortcuts.EventLambda()).toThrow('Options required');
329
+ });
394
330
 
395
- assert.throws(
396
- () =>
397
- new cf.shortcuts.EventLambda({
398
- LogicalName: 'MyLambda',
399
- Code: {
400
- S3Bucket: 'my-code-bucket',
401
- S3Key: 'path/to/code.zip'
402
- }
403
- }),
404
- /You must provide an EventPattern/,
405
- 'throws without event-lambda required parameters'
406
- );
331
+ test('throws without basic lambda required parameters', () => {
332
+ expect(() => new cf.shortcuts.EventLambda({})).toThrow(/You must provide a LogicalName, and Code/);
333
+ });
407
334
 
408
- let lambda = new cf.shortcuts.EventLambda({
409
- LogicalName: 'MyLambda',
410
- Code: {
411
- S3Bucket: 'my-code-bucket',
412
- S3Key: 'path/to/code.zip'
413
- },
414
- EventPattern: {
415
- source: ['aws.ec2'],
416
- 'detail-type': ['EC2 Instance State-change Notification'],
417
- detail: {
418
- state: ['running']
335
+ test('throws without event-lambda required parameters', () => {
336
+ expect(() => new cf.shortcuts.EventLambda({
337
+ LogicalName: 'MyLambda',
338
+ Code: {
339
+ S3Bucket: 'my-code-bucket',
340
+ S3Key: 'path/to/code.zip'
419
341
  }
420
- }
342
+ })).toThrow(/You must provide an EventPattern/);
421
343
  });
422
344
 
423
- let template = cf.merge(lambda);
424
- if (update) fixtures.update('event-lambda-defaults', template);
425
- assert.deepEqual(
426
- noUndefined(template),
427
- fixtures.get('event-lambda-defaults'),
428
- 'expected resources generated with defaults'
429
- );
430
-
431
- lambda = new cf.shortcuts.EventLambda({
432
- LogicalName: 'MyLambda',
433
- Code: {
434
- S3Bucket: 'my-code-bucket',
435
- S3Key: 'path/to/code.zip'
436
- },
437
- EventPattern: {
438
- source: ['aws.ec2'],
439
- 'detail-type': ['EC2 Instance State-change Notification'],
440
- detail: {
441
- state: ['running']
345
+ test('expected resources generated with defaults', () => {
346
+ const lambda = new cf.shortcuts.EventLambda({
347
+ LogicalName: 'MyLambda',
348
+ Code: {
349
+ S3Bucket: 'my-code-bucket',
350
+ S3Key: 'path/to/code.zip'
351
+ },
352
+ EventPattern: {
353
+ source: ['aws.ec2'],
354
+ 'detail-type': ['EC2 Instance State-change Notification'],
355
+ detail: {
356
+ state: ['running']
357
+ }
442
358
  }
443
- },
444
- State: 'DISABLED'
359
+ });
360
+
361
+ const template = cf.merge(lambda);
362
+ if (update) fixtures.update('event-lambda-defaults', template);
363
+ expect(noUndefined(template)).toEqual(fixtures.get('event-lambda-defaults'));
445
364
  });
446
365
 
447
- template = cf.merge(lambda);
448
- if (update) fixtures.update('event-lambda-full', template);
449
- assert.deepEqual(
450
- noUndefined(template),
451
- fixtures.get('event-lambda-full'),
452
- 'expected resources generated without defaults'
453
- );
366
+ test('expected resources generated without defaults', () => {
367
+ const lambda = new cf.shortcuts.EventLambda({
368
+ LogicalName: 'MyLambda',
369
+ Code: {
370
+ S3Bucket: 'my-code-bucket',
371
+ S3Key: 'path/to/code.zip'
372
+ },
373
+ EventPattern: {
374
+ source: ['aws.ec2'],
375
+ 'detail-type': ['EC2 Instance State-change Notification'],
376
+ detail: {
377
+ state: ['running']
378
+ }
379
+ },
380
+ State: 'DISABLED'
381
+ });
454
382
 
455
- assert.end();
383
+ const template = cf.merge(lambda);
384
+ if (update) fixtures.update('event-lambda-full', template);
385
+ expect(noUndefined(template)).toEqual(fixtures.get('event-lambda-full'));
386
+ });
456
387
  });
457
388
 
458
- test('[shortcuts] stream-lambda', (assert) => {
459
- assert.throws(
460
- () => new cf.shortcuts.StreamLambda(),
461
- 'Options required',
462
- 'throws without options'
463
- );
464
- assert.throws(
465
- () => new cf.shortcuts.StreamLambda({}),
466
- /You must provide a LogicalName, and Code/,
467
- 'throws without basic lambda required parameters'
468
- );
389
+ describe('[shortcuts] stream-lambda', () => {
390
+ test('throws without options', () => {
391
+ expect(() => new cf.shortcuts.StreamLambda()).toThrow('Options required');
392
+ });
469
393
 
470
- assert.throws(
471
- () =>
472
- new cf.shortcuts.StreamLambda({
473
- LogicalName: 'MyLambda',
474
- Code: {
475
- S3Bucket: 'my-code-bucket',
476
- S3Key: 'path/to/code.zip'
477
- }
478
- }),
479
- /You must provide an EventSourceArn/,
480
- 'throws without stream-lambda required parameters'
481
- );
394
+ test('throws without basic lambda required parameters', () => {
395
+ expect(() => new cf.shortcuts.StreamLambda({})).toThrow(/You must provide a LogicalName, and Code/);
396
+ });
482
397
 
483
- let lambda = new cf.shortcuts.StreamLambda({
484
- LogicalName: 'MyLambda',
485
- Code: {
486
- S3Bucket: 'my-code-bucket',
487
- S3Key: 'path/to/code.zip'
488
- },
489
- EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake'
490
- });
491
-
492
- let template = cf.merge(lambda);
493
- if (update) fixtures.update('stream-lambda-defaults', template);
494
- assert.deepEqual(
495
- noUndefined(template),
496
- fixtures.get('stream-lambda-defaults'),
497
- 'expected resources generated via defaults'
498
- );
398
+ test('throws without stream-lambda required parameters', () => {
399
+ expect(() => new cf.shortcuts.StreamLambda({
400
+ LogicalName: 'MyLambda',
401
+ Code: {
402
+ S3Bucket: 'my-code-bucket',
403
+ S3Key: 'path/to/code.zip'
404
+ }
405
+ })).toThrow(/You must provide an EventSourceArn/);
406
+ });
499
407
 
500
- lambda = new cf.shortcuts.StreamLambda({
501
- LogicalName: 'MyLambda',
502
- Code: {
503
- S3Bucket: 'my-code-bucket',
504
- S3Key: 'path/to/code.zip'
505
- },
506
- EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake',
507
- FilterCriteria: {
508
- Filters: [
509
- {
510
- Pattern: JSON.stringify({ eventName: ['INSERT', 'MODIFY'] })
511
- }
512
- ]
513
- },
514
- BatchSize: 10000,
515
- MaximumBatchingWindowInSeconds: 300,
516
- Enabled: false,
517
- StartingPosition: 'TRIM_HORIZON'
518
- });
519
-
520
- template = cf.merge(lambda);
521
- if (update) fixtures.update('stream-lambda-no-defaults', template);
522
- assert.deepEqual(
523
- noUndefined(template),
524
- fixtures.get('stream-lambda-no-defaults'),
525
- 'expected resources generated without defaults'
526
- );
408
+ test('expected resources generated via defaults', () => {
409
+ const lambda = new cf.shortcuts.StreamLambda({
410
+ LogicalName: 'MyLambda',
411
+ Code: {
412
+ S3Bucket: 'my-code-bucket',
413
+ S3Key: 'path/to/code.zip'
414
+ },
415
+ EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake'
416
+ });
417
+
418
+ const template = cf.merge(lambda);
419
+ if (update) fixtures.update('stream-lambda-defaults', template);
420
+ expect(noUndefined(template)).toEqual(fixtures.get('stream-lambda-defaults'));
421
+ });
527
422
 
528
- assert.end();
423
+ test('expected resources generated without defaults', () => {
424
+ const lambda = new cf.shortcuts.StreamLambda({
425
+ LogicalName: 'MyLambda',
426
+ Code: {
427
+ S3Bucket: 'my-code-bucket',
428
+ S3Key: 'path/to/code.zip'
429
+ },
430
+ EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake',
431
+ FilterCriteria: {
432
+ Filters: [
433
+ {
434
+ Pattern: JSON.stringify({ eventName: ['INSERT', 'MODIFY'] })
435
+ }
436
+ ]
437
+ },
438
+ BatchSize: 10000,
439
+ MaximumBatchingWindowInSeconds: 300,
440
+ Enabled: false,
441
+ StartingPosition: 'TRIM_HORIZON'
442
+ });
443
+
444
+ const template = cf.merge(lambda);
445
+ if (update) fixtures.update('stream-lambda-no-defaults', template);
446
+ expect(noUndefined(template)).toEqual(fixtures.get('stream-lambda-no-defaults'));
447
+ });
529
448
  });
530
449
 
531
- test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
532
- assert.throws(
533
- () => new cf.shortcuts.StreamLambda({
450
+ describe('[shortcuts] StreamLambda FilterCriteria', () => {
451
+ test('FilterCriteria must be a JSON-like object', () => {
452
+ expect(() => new cf.shortcuts.StreamLambda({
534
453
  LogicalName: 'MyLambda',
535
454
  Code: {
536
455
  S3Bucket: 'my-code-bucket',
@@ -538,11 +457,11 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
538
457
  },
539
458
  EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake',
540
459
  FilterCriteria: ['test']
541
- }),
542
- '`FilterCriteria` must be a JSON-like object',
543
- );
544
- assert.throws(
545
- () => new cf.shortcuts.StreamLambda({
460
+ })).toThrow();
461
+ });
462
+
463
+ test('FilterCriteria must contain property Filter of type array', () => {
464
+ expect(() => new cf.shortcuts.StreamLambda({
546
465
  LogicalName: 'MyLambda',
547
466
  Code: {
548
467
  S3Bucket: 'my-code-bucket',
@@ -550,11 +469,11 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
550
469
  },
551
470
  EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake',
552
471
  FilterCriteria: {}
553
- }),
554
- '`FilterCriteria` must contain property `Filter` of type array',
555
- );
556
- assert.throws(
557
- () => new cf.shortcuts.StreamLambda({
472
+ })).toThrow();
473
+ });
474
+
475
+ test('FilterCriteria.Filter must be an array', () => {
476
+ expect(() => new cf.shortcuts.StreamLambda({
558
477
  LogicalName: 'MyLambda',
559
478
  Code: {
560
479
  S3Bucket: 'my-code-bucket',
@@ -564,11 +483,11 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
564
483
  FilterCriteria: {
565
484
  Filter: 613
566
485
  }
567
- }),
568
- '`FilterCriteria` must contain property `Filter` of type array',
569
- );
570
- assert.throws(
571
- () => new cf.shortcuts.StreamLambda({
486
+ })).toThrow();
487
+ });
488
+
489
+ test('FilterCriteria.Filter objects must have Pattern property', () => {
490
+ expect(() => new cf.shortcuts.StreamLambda({
572
491
  LogicalName: 'MyLambda',
573
492
  Code: {
574
493
  S3Bucket: 'my-code-bucket',
@@ -585,11 +504,11 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
585
504
  }
586
505
  ]
587
506
  }
588
- }),
589
- 'An object in `FilterCriteria.Filter` was missing the required property `Pattern`',
590
- );
591
- assert.throws(
592
- () => new cf.shortcuts.StreamLambda({
507
+ })).toThrow();
508
+ });
509
+
510
+ test('FilterCriteria.Filter Pattern must be JSON parseable string', () => {
511
+ expect(() => new cf.shortcuts.StreamLambda({
593
512
  LogicalName: 'MyLambda',
594
513
  Code: {
595
514
  S3Bucket: 'my-code-bucket',
@@ -606,930 +525,798 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
606
525
  }
607
526
  ]
608
527
  }
609
- }),
610
- 'An object in `FilterCriteria.Filter` contains a `Pattern` property that is not a JSON parseable string',
611
- );
612
- assert.end();
528
+ })).toThrow();
529
+ });
613
530
  });
614
531
 
615
- test('[shortcuts] log-subscription-lambda', (assert) => {
616
- assert.throws(
617
- () => new cf.shortcuts.LogSubscriptionLambda(),
618
- 'Options required',
619
- 'throws without options'
620
- );
621
- assert.throws(
622
- () => new cf.shortcuts.LogSubscriptionLambda({}),
623
- /You must provide a LogicalName, and Code/,
624
- 'throws without basic lambda required parameters'
625
- );
532
+ describe('[shortcuts] log-subscription-lambda', () => {
533
+ test('throws without options', () => {
534
+ expect(() => new cf.shortcuts.LogSubscriptionLambda()).toThrow('Options required');
535
+ });
626
536
 
627
- assert.throws(
628
- () =>
629
- new cf.shortcuts.LogSubscriptionLambda({
630
- LogicalName: 'MyLambda',
631
- Code: {
632
- S3Bucket: 'my-code-bucket',
633
- S3Key: 'path/to/code.zip'
634
- }
635
- }),
636
- /You must provide a LogGroupName/,
637
- 'throws without log-subscription-lambda required parameters'
638
- );
537
+ test('throws without basic lambda required parameters', () => {
538
+ expect(() => new cf.shortcuts.LogSubscriptionLambda({})).toThrow(/You must provide a LogicalName, and Code/);
539
+ });
639
540
 
640
- let lambda = new cf.shortcuts.LogSubscriptionLambda({
641
- LogicalName: 'MyLambda',
642
- Code: {
643
- S3Bucket: 'my-code-bucket',
644
- S3Key: 'path/to/code.zip'
645
- },
646
- LogGroupName: 'my-log-group'
647
- });
648
-
649
- let template = cf.merge(lambda);
650
- if (update) fixtures.update('log-subscription-lambda-defaults', template);
651
- assert.deepEqual(
652
- noUndefined(template),
653
- fixtures.get('log-subscription-lambda-defaults'),
654
- 'expected resources generated via defaults'
655
- );
541
+ test('throws without log-subscription-lambda required parameters', () => {
542
+ expect(() => new cf.shortcuts.LogSubscriptionLambda({
543
+ LogicalName: 'MyLambda',
544
+ Code: {
545
+ S3Bucket: 'my-code-bucket',
546
+ S3Key: 'path/to/code.zip'
547
+ }
548
+ })).toThrow(/You must provide a LogGroupName/);
549
+ });
656
550
 
657
- lambda = new cf.shortcuts.LogSubscriptionLambda({
658
- LogicalName: 'MyLambda',
659
- Code: {
660
- S3Bucket: 'my-code-bucket',
661
- S3Key: 'path/to/code.zip'
662
- },
663
- FilterPattern: '{ $.errorCode = 400 }',
664
- LogGroupName: 'my-log-group'
665
- });
666
-
667
- template = cf.merge(lambda);
668
- if (update) fixtures.update('log-subscription-lambda-no-defaults', template);
669
- assert.deepEqual(
670
- noUndefined(template),
671
- fixtures.get('log-subscription-lambda-no-defaults'),
672
- 'expected resources generated without defaults'
673
- );
551
+ test('expected resources generated via defaults', () => {
552
+ const lambda = new cf.shortcuts.LogSubscriptionLambda({
553
+ LogicalName: 'MyLambda',
554
+ Code: {
555
+ S3Bucket: 'my-code-bucket',
556
+ S3Key: 'path/to/code.zip'
557
+ },
558
+ LogGroupName: 'my-log-group'
559
+ });
674
560
 
675
- assert.end();
561
+ const template = cf.merge(lambda);
562
+ if (update) fixtures.update('log-subscription-lambda-defaults', template);
563
+ expect(noUndefined(template)).toEqual(fixtures.get('log-subscription-lambda-defaults'));
564
+ });
565
+
566
+ test('expected resources generated without defaults', () => {
567
+ const lambda = new cf.shortcuts.LogSubscriptionLambda({
568
+ LogicalName: 'MyLambda',
569
+ Code: {
570
+ S3Bucket: 'my-code-bucket',
571
+ S3Key: 'path/to/code.zip'
572
+ },
573
+ FilterPattern: '{ $.errorCode = 400 }',
574
+ LogGroupName: 'my-log-group'
575
+ });
576
+
577
+ const template = cf.merge(lambda);
578
+ if (update) fixtures.update('log-subscription-lambda-no-defaults', template);
579
+ expect(noUndefined(template)).toEqual(fixtures.get('log-subscription-lambda-no-defaults'));
580
+ });
676
581
  });
677
582
 
678
- test('[shortcuts] queue', (assert) => {
679
- assert.throws(
680
- () => new cf.shortcuts.Queue(),
681
- 'Options required',
682
- 'throws without options'
683
- );
684
- assert.throws(
685
- () => new cf.shortcuts.Queue({}),
686
- /You must provide a LogicalName/,
687
- 'throws without required parameters'
688
- );
583
+ describe('[shortcuts] queue', () => {
584
+ test('throws without options', () => {
585
+ expect(() => new cf.shortcuts.Queue()).toThrow('Options required');
586
+ });
689
587
 
690
- let queue = new cf.shortcuts.Queue({
691
- LogicalName: 'MyQueue'
588
+ test('throws without required parameters', () => {
589
+ expect(() => new cf.shortcuts.Queue({})).toThrow(/You must provide a LogicalName/);
692
590
  });
693
591
 
694
- let template = cf.merge(queue);
695
- if (update) fixtures.update('queue-defaults', template);
696
- assert.deepEqual(
697
- noUndefined(template),
698
- fixtures.get('queue-defaults'),
699
- 'expected resources generated for full defaults'
700
- );
592
+ test('expected resources generated for full defaults', () => {
593
+ const queue = new cf.shortcuts.Queue({
594
+ LogicalName: 'MyQueue'
595
+ });
701
596
 
702
- queue = new cf.shortcuts.Queue({
703
- LogicalName: 'MyQueue',
704
- VisibilityTimeout: 60,
705
- maxReceiveCount: 100,
706
- DelaySeconds: 60,
707
- KmsMasterKeyId: 'alias/my-key',
708
- KmsDataKeyReusePeriondSeconds: 86400,
709
- MaximumMessageSize: 1024,
710
- MessageRetentionPeriod: 60,
711
- QueueName: 'my-queue',
712
- ReceiveMessageWaitTimeSeconds: 20,
713
- Condition: 'Always',
714
- DependsOn: 'AnotherThing',
715
- TopicName: 'my-topic',
716
- DisplayName: 'topic-display-name',
717
- DeadLetterVisibilityTimeout: 60
718
- });
719
-
720
- template = cf.merge(
721
- { Conditions: { Always: cf.equals('1', '1') } },
722
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
723
- queue
724
- );
725
- if (update) fixtures.update('queue-full', template);
726
- assert.deepEqual(
727
- noUndefined(template),
728
- fixtures.get('queue-full'),
729
- 'expected resources generated no defaults'
730
- );
597
+ const template = cf.merge(queue);
598
+ if (update) fixtures.update('queue-defaults', template);
599
+ expect(noUndefined(template)).toEqual(fixtures.get('queue-defaults'));
600
+ });
731
601
 
732
- queue = new cf.shortcuts.Queue({
733
- LogicalName: 'MyQueue',
734
- ExistingTopicArn: 'arn:aws:sns:us-east-1:111122223333:MyTopic'
602
+ test('expected resources generated no defaults', () => {
603
+ const queue = new cf.shortcuts.Queue({
604
+ LogicalName: 'MyQueue',
605
+ VisibilityTimeout: 60,
606
+ maxReceiveCount: 100,
607
+ DelaySeconds: 60,
608
+ KmsMasterKeyId: 'alias/my-key',
609
+ KmsDataKeyReusePeriondSeconds: 86400,
610
+ MaximumMessageSize: 1024,
611
+ MessageRetentionPeriod: 60,
612
+ QueueName: 'my-queue',
613
+ ReceiveMessageWaitTimeSeconds: 20,
614
+ Condition: 'Always',
615
+ DependsOn: 'AnotherThing',
616
+ TopicName: 'my-topic',
617
+ DisplayName: 'topic-display-name',
618
+ DeadLetterVisibilityTimeout: 60
619
+ });
620
+
621
+ const template = cf.merge(
622
+ { Conditions: { Always: cf.equals('1', '1') } },
623
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
624
+ queue
625
+ );
626
+ if (update) fixtures.update('queue-full', template);
627
+ expect(noUndefined(template)).toEqual(fixtures.get('queue-full'));
735
628
  });
736
- template = cf.merge(queue);
737
- if (update) fixtures.update('queue-external-topic', template);
738
- assert.deepEqual(
739
- noUndefined(template),
740
- fixtures.get('queue-external-topic'),
741
- 'expected resources generated for external topic'
742
- );
743
629
 
744
- queue = new cf.shortcuts.Queue({
745
- LogicalName: 'MyQueue',
746
- ExistingTopicArn: { Ref: 'TopicForOtherThing' }
630
+ test('expected resources generated for external topic', () => {
631
+ const queue = new cf.shortcuts.Queue({
632
+ LogicalName: 'MyQueue',
633
+ ExistingTopicArn: 'arn:aws:sns:us-east-1:111122223333:MyTopic'
634
+ });
635
+ const template = cf.merge(queue);
636
+ if (update) fixtures.update('queue-external-topic', template);
637
+ expect(noUndefined(template)).toEqual(fixtures.get('queue-external-topic'));
747
638
  });
748
- template = cf.merge(
749
- { Resources: { TopicForOtherThing: { Type: 'AWS::SNS::Topic' } } },
750
- queue
751
- );
752
- if (update) fixtures.update('queue-external-topic-ref', template);
753
- assert.deepEqual(
754
- noUndefined(template),
755
- fixtures.get('queue-external-topic-ref'),
756
- 'expected resources generated for external topic identified by ref'
757
- );
758
639
 
759
- queue = new cf.shortcuts.Queue({
760
- LogicalName: 'MyFifoQueue',
761
- FifoQueue: true
640
+ test('expected resources generated for external topic identified by ref', () => {
641
+ const queue = new cf.shortcuts.Queue({
642
+ LogicalName: 'MyQueue',
643
+ ExistingTopicArn: { Ref: 'TopicForOtherThing' }
644
+ });
645
+ const template = cf.merge(
646
+ { Resources: { TopicForOtherThing: { Type: 'AWS::SNS::Topic' } } },
647
+ queue
648
+ );
649
+ if (update) fixtures.update('queue-external-topic-ref', template);
650
+ expect(noUndefined(template)).toEqual(fixtures.get('queue-external-topic-ref'));
762
651
  });
763
- template = cf.merge(queue);
764
- if (update) fixtures.update('queue-fifo', template);
765
- assert.deepEqual(
766
- noUndefined(template),
767
- fixtures.get('queue-fifo'),
768
- 'expected resources generated for FIFO queue'
769
- );
770
652
 
771
- queue = new cf.shortcuts.Queue({
772
- LogicalName: 'MyFifoQueue',
773
- QueueName: 'custom-and-fancy',
774
- FifoQueue: true
775
- });
776
- template = cf.merge(queue);
777
- if (update) fixtures.update('queue-fifo-queuename', template);
778
- assert.deepEqual(
779
- noUndefined(template),
780
- fixtures.get('queue-fifo-queuename'),
781
- 'expected resources generated for FIFO queue with specified QueueName'
782
- );
653
+ test('expected resources generated for FIFO queue', () => {
654
+ const queue = new cf.shortcuts.Queue({
655
+ LogicalName: 'MyFifoQueue',
656
+ FifoQueue: true
657
+ });
658
+ const template = cf.merge(queue);
659
+ if (update) fixtures.update('queue-fifo', template);
660
+ expect(noUndefined(template)).toEqual(fixtures.get('queue-fifo'));
661
+ });
783
662
 
784
- queue = new cf.shortcuts.Queue({
785
- LogicalName: 'MyFifoFalseQueue',
786
- FifoQueue: false
663
+ test('expected resources generated for FIFO queue with specified QueueName', () => {
664
+ const queue = new cf.shortcuts.Queue({
665
+ LogicalName: 'MyFifoQueue',
666
+ QueueName: 'custom-and-fancy',
667
+ FifoQueue: true
668
+ });
669
+ const template = cf.merge(queue);
670
+ if (update) fixtures.update('queue-fifo-queuename', template);
671
+ expect(noUndefined(template)).toEqual(fixtures.get('queue-fifo-queuename'));
787
672
  });
788
- template = cf.merge(queue);
789
- assert.equal(
790
- template.Resources.MyFifoFalseQueue.Properties.FifoQueue,
791
- undefined,
792
- 'the FifoQueue value false is converted to undefined, to pass CFN validation'
793
- );
794
673
 
795
- assert.end();
674
+ test('the FifoQueue value false is converted to undefined, to pass CFN validation', () => {
675
+ const queue = new cf.shortcuts.Queue({
676
+ LogicalName: 'MyFifoFalseQueue',
677
+ FifoQueue: false
678
+ });
679
+ const template = cf.merge(queue);
680
+ expect(template.Resources.MyFifoFalseQueue.Properties.FifoQueue).toBeUndefined();
681
+ });
796
682
  });
797
683
 
798
- test('[shortcuts] s3 kinesis firehose', (assert) => {
799
- assert.throws(
800
- () => new cf.shortcuts.S3KinesisFirehose(),
801
- 'Options required',
802
- 'throws without options'
803
- );
804
- assert.throws(
805
- () => new cf.shortcuts.S3KinesisFirehose({}),
806
- /You must provide a LogicalName/,
807
- 'throws without required LogicalName parameter'
808
- );
684
+ describe('[shortcuts] s3 kinesis firehose', () => {
685
+ test('throws without options', () => {
686
+ expect(() => new cf.shortcuts.S3KinesisFirehose()).toThrow('Options required');
687
+ });
809
688
 
810
- assert.throws(
811
- () => new cf.shortcuts.S3KinesisFirehose({
812
- LogicalName: 'MyKinesisFirehose'
813
- }),
814
- /You must provide a DestinationBucket/,
815
- 'throws without required DestinationBucket parameter'
816
- );
689
+ test('throws without required LogicalName parameter', () => {
690
+ expect(() => new cf.shortcuts.S3KinesisFirehose({})).toThrow(/You must provide a LogicalName/);
691
+ });
817
692
 
818
- let firehose = new cf.shortcuts.S3KinesisFirehose({
819
- LogicalName: 'MyKinesisFirehose',
820
- DestinationBucket: 'mah-bukkit'
693
+ test('throws without required DestinationBucket parameter', () => {
694
+ expect(() => new cf.shortcuts.S3KinesisFirehose({
695
+ LogicalName: 'MyKinesisFirehose'
696
+ })).toThrow(/You must provide a DestinationBucket/);
821
697
  });
822
698
 
823
- let template = cf.merge(firehose);
824
- if (update) fixtures.update('firehose-defaults', template);
825
- assert.deepEqual(
826
- noUndefined(template),
827
- fixtures.get('firehose-defaults'),
828
- 'expected resources generated for full defaults'
829
- );
699
+ test('expected resources generated for full defaults', () => {
700
+ const firehose = new cf.shortcuts.S3KinesisFirehose({
701
+ LogicalName: 'MyKinesisFirehose',
702
+ DestinationBucket: 'mah-bukkit'
703
+ });
830
704
 
831
- firehose = new cf.shortcuts.S3KinesisFirehose({
832
- LogicalName: 'MyKinesisFirehose',
833
- DestinationBucket: 'mah-bukkit',
834
- KinesisStreamARN: 'arn:aws:kinesis:us-east-1:111122223333:stream/my-stream'
705
+ const template = cf.merge(firehose);
706
+ if (update) fixtures.update('firehose-defaults', template);
707
+ expect(noUndefined(template)).toEqual(fixtures.get('firehose-defaults'));
835
708
  });
836
709
 
837
- template = cf.merge(
838
- { Conditions: { Always: cf.equals('1', '1') } },
839
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
840
- firehose
841
- );
842
- if (update) fixtures.update('firehose-with-stream', template);
843
- assert.deepEqual(
844
- noUndefined(template),
845
- fixtures.get('firehose-with-stream'),
846
- 'expected resources generated with stream'
847
- );
710
+ test('expected resources generated with stream', () => {
711
+ const firehose = new cf.shortcuts.S3KinesisFirehose({
712
+ LogicalName: 'MyKinesisFirehose',
713
+ DestinationBucket: 'mah-bukkit',
714
+ KinesisStreamARN: 'arn:aws:kinesis:us-east-1:111122223333:stream/my-stream'
715
+ });
848
716
 
849
- assert.end();
717
+ const template = cf.merge(
718
+ { Conditions: { Always: cf.equals('1', '1') } },
719
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
720
+ firehose
721
+ );
722
+ if (update) fixtures.update('firehose-with-stream', template);
723
+ expect(noUndefined(template)).toEqual(fixtures.get('firehose-with-stream'));
724
+ });
850
725
  });
851
726
 
852
- test('[shortcuts] role', (assert) => {
853
- assert.throws(
854
- () => new cf.shortcuts.Role(),
855
- 'Options required',
856
- 'throws without options'
857
- );
858
- assert.throws(
859
- () => new cf.shortcuts.Role({}),
860
- /You must provide a LogicalName and AssumeRolePrincipals/,
861
- 'throws without required parameters'
862
- );
727
+ describe('[shortcuts] role', () => {
728
+ test('throws without options', () => {
729
+ expect(() => new cf.shortcuts.Role()).toThrow('Options required');
730
+ });
863
731
 
864
- let role = new cf.shortcuts.Role({
865
- LogicalName: 'MyRole',
866
- AssumeRolePrincipals: [{ Service: 'ec2.amazonaws.com' }]
732
+ test('throws without required parameters', () => {
733
+ expect(() => new cf.shortcuts.Role({})).toThrow(/You must provide a LogicalName and AssumeRolePrincipals/);
867
734
  });
868
735
 
869
- let template = cf.merge(role);
870
- if (update) fixtures.update('role-defaults', template);
871
- assert.deepEqual(
872
- noUndefined(template),
873
- fixtures.get('role-defaults'),
874
- 'expected resources generated with defaults'
875
- );
736
+ test('expected resources generated with defaults', () => {
737
+ const role = new cf.shortcuts.Role({
738
+ LogicalName: 'MyRole',
739
+ AssumeRolePrincipals: [{ Service: 'ec2.amazonaws.com' }]
740
+ });
876
741
 
877
- role = new cf.shortcuts.Role({
878
- LogicalName: 'MyRole',
879
- AssumeRolePrincipals: [{ Service: 'ec2.amazonaws.com' }],
880
- Statement: [
881
- {
882
- Effect: 'Allow',
883
- Action: 's3:GetObject',
884
- Resource: 'arn:aws:s3:::fake/data'
885
- }
886
- ],
887
- ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
888
- MaxSessionDuration: 3600,
889
- Path: '/fake/',
890
- RoleName: 'my-role',
891
- Tags: [{ Key: 'pipeline-name', Value: 'test' }],
892
- Condition: 'Always',
893
- DependsOn: 'AnotherThing'
894
- });
895
-
896
- template = cf.merge(
897
- { Conditions: { Always: cf.equals('1', '1') } },
898
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
899
- role
900
- );
901
- if (update) fixtures.update('role-no-defaults', template);
902
- assert.deepEqual(
903
- noUndefined(template),
904
- fixtures.get('role-no-defaults'),
905
- 'expected resources generated without defaults'
906
- );
742
+ const template = cf.merge(role);
743
+ if (update) fixtures.update('role-defaults', template);
744
+ expect(noUndefined(template)).toEqual(fixtures.get('role-defaults'));
745
+ });
907
746
 
908
- assert.end();
747
+ test('expected resources generated without defaults', () => {
748
+ const role = new cf.shortcuts.Role({
749
+ LogicalName: 'MyRole',
750
+ AssumeRolePrincipals: [{ Service: 'ec2.amazonaws.com' }],
751
+ Statement: [
752
+ {
753
+ Effect: 'Allow',
754
+ Action: 's3:GetObject',
755
+ Resource: 'arn:aws:s3:::fake/data'
756
+ }
757
+ ],
758
+ ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
759
+ MaxSessionDuration: 3600,
760
+ Path: '/fake/',
761
+ RoleName: 'my-role',
762
+ Tags: [{ Key: 'pipeline-name', Value: 'test' }],
763
+ Condition: 'Always',
764
+ DependsOn: 'AnotherThing'
765
+ });
766
+
767
+ const template = cf.merge(
768
+ { Conditions: { Always: cf.equals('1', '1') } },
769
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
770
+ role
771
+ );
772
+ if (update) fixtures.update('role-no-defaults', template);
773
+ expect(noUndefined(template)).toEqual(fixtures.get('role-no-defaults'));
774
+ });
909
775
  });
910
776
 
911
- test('[shortcuts] cross-account role', (assert) => {
912
- assert.throws(
913
- () => new cf.shortcuts.CrossAccountRole(),
914
- 'Options required',
915
- 'throws without options'
916
- );
917
- assert.throws(
918
- () => new cf.shortcuts.CrossAccountRole({}),
919
- /You must provide a LogicalName and Accounts/,
920
- 'throws without required parameters'
921
- );
777
+ describe('[shortcuts] cross-account role', () => {
778
+ test('throws without options', () => {
779
+ expect(() => new cf.shortcuts.CrossAccountRole()).toThrow('Options required');
780
+ });
922
781
 
923
- let role = new cf.shortcuts.CrossAccountRole({
924
- LogicalName: 'MyRole',
925
- Accounts: [
926
- '123456789012',
927
- 'arn:aws:iam::123456789012:root',
928
- { 'Fn::Sub': 'arn:aws:iam::${AWS::AccountId}:root' }
929
- ]
930
- });
931
-
932
- let template = cf.merge(role);
933
- if (update) fixtures.update('cross-account-role-defaults', template);
934
- assert.deepEqual(
935
- noUndefined(template),
936
- fixtures.get('cross-account-role-defaults'),
937
- 'expected resources generated with defaults'
938
- );
782
+ test('throws without required parameters', () => {
783
+ expect(() => new cf.shortcuts.CrossAccountRole({})).toThrow(/You must provide a LogicalName and Accounts/);
784
+ });
939
785
 
940
- role = new cf.shortcuts.CrossAccountRole({
941
- LogicalName: 'MyRole',
942
- Accounts: [
943
- '123456789012',
944
- 'arn:aws:iam::123456789012:root',
945
- { 'Fn::Sub': 'arn:aws:iam::${AWS::AccountId}:root' }
946
- ],
947
- Statement: [
948
- {
949
- Effect: 'Allow',
950
- Action: 's3:GetObject',
951
- Resource: 'arn:aws:s3:::fake/data'
952
- }
953
- ],
954
- ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
955
- MaxSessionDuration: 3600,
956
- Path: '/fake/',
957
- RoleName: 'my-role',
958
- Condition: 'Always',
959
- DependsOn: 'AnotherThing'
960
- });
961
-
962
- template = cf.merge(
963
- { Conditions: { Always: cf.equals('1', '1') } },
964
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
965
- role
966
- );
967
- if (update) fixtures.update('cross-account-role-no-defaults', template);
968
- assert.deepEqual(
969
- noUndefined(template),
970
- fixtures.get('cross-account-role-no-defaults'),
971
- 'expected resources generated without defaults'
972
- );
786
+ test('expected resources generated with defaults', () => {
787
+ const role = new cf.shortcuts.CrossAccountRole({
788
+ LogicalName: 'MyRole',
789
+ Accounts: [
790
+ '123456789012',
791
+ 'arn:aws:iam::123456789012:root',
792
+ { 'Fn::Sub': 'arn:aws:iam::${AWS::AccountId}:root' }
793
+ ]
794
+ });
795
+
796
+ const template = cf.merge(role);
797
+ if (update) fixtures.update('cross-account-role-defaults', template);
798
+ expect(noUndefined(template)).toEqual(fixtures.get('cross-account-role-defaults'));
799
+ });
800
+
801
+ test('expected resources generated without defaults', () => {
802
+ const role = new cf.shortcuts.CrossAccountRole({
803
+ LogicalName: 'MyRole',
804
+ Accounts: [
805
+ '123456789012',
806
+ 'arn:aws:iam::123456789012:root',
807
+ { 'Fn::Sub': 'arn:aws:iam::${AWS::AccountId}:root' }
808
+ ],
809
+ Statement: [
810
+ {
811
+ Effect: 'Allow',
812
+ Action: 's3:GetObject',
813
+ Resource: 'arn:aws:s3:::fake/data'
814
+ }
815
+ ],
816
+ ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
817
+ MaxSessionDuration: 3600,
818
+ Path: '/fake/',
819
+ RoleName: 'my-role',
820
+ Condition: 'Always',
821
+ DependsOn: 'AnotherThing'
822
+ });
973
823
 
974
- assert.end();
824
+ const template = cf.merge(
825
+ { Conditions: { Always: cf.equals('1', '1') } },
826
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
827
+ role
828
+ );
829
+ if (update) fixtures.update('cross-account-role-no-defaults', template);
830
+ expect(noUndefined(template)).toEqual(fixtures.get('cross-account-role-no-defaults'));
831
+ });
975
832
  });
976
833
 
977
- test('[shortcuts] service role', (assert) => {
978
- assert.throws(
979
- () => new cf.shortcuts.ServiceRole(),
980
- 'Options required',
981
- 'throws without options'
982
- );
983
- assert.throws(
984
- () => new cf.shortcuts.ServiceRole({}),
985
- /You must provide a LogicalName and Service/,
986
- 'throws without required parameters'
987
- );
834
+ describe('[shortcuts] service role', () => {
835
+ test('throws without options', () => {
836
+ expect(() => new cf.shortcuts.ServiceRole()).toThrow('Options required');
837
+ });
988
838
 
989
- let role = new cf.shortcuts.ServiceRole({
990
- LogicalName: 'MyRole',
991
- Service: 'lambda'
839
+ test('throws without required parameters', () => {
840
+ expect(() => new cf.shortcuts.ServiceRole({})).toThrow(/You must provide a LogicalName and Service/);
992
841
  });
993
842
 
994
- let template = cf.merge(role);
995
- if (update) fixtures.update('service-role-defaults', template);
996
- assert.deepEqual(
997
- noUndefined(template),
998
- fixtures.get('service-role-defaults'),
999
- 'expected resources generated with defaults'
1000
- );
843
+ test('expected resources generated with defaults', () => {
844
+ const role = new cf.shortcuts.ServiceRole({
845
+ LogicalName: 'MyRole',
846
+ Service: 'lambda'
847
+ });
1001
848
 
1002
- role = new cf.shortcuts.ServiceRole({
1003
- LogicalName: 'MyRole',
1004
- Service: 'lambda.amazonaws.com'
849
+ const template = cf.merge(role);
850
+ if (update) fixtures.update('service-role-defaults', template);
851
+ expect(noUndefined(template)).toEqual(fixtures.get('service-role-defaults'));
1005
852
  });
1006
853
 
1007
- template = cf.merge(role);
1008
- if (update) fixtures.update('service-role-no-url-suffix', template);
1009
- assert.deepEqual(
1010
- noUndefined(template),
1011
- fixtures.get('service-role-no-url-suffix'),
1012
- 'expected resources generated, service for which AWS::URLSuffix is invalid'
1013
- );
854
+ test('expected resources generated, service for which AWS::URLSuffix is invalid', () => {
855
+ const role = new cf.shortcuts.ServiceRole({
856
+ LogicalName: 'MyRole',
857
+ Service: 'lambda.amazonaws.com'
858
+ });
1014
859
 
1015
- role = new cf.shortcuts.ServiceRole({
1016
- LogicalName: 'MyRole',
1017
- Service: 'ec2'
860
+ const template = cf.merge(role);
861
+ if (update) fixtures.update('service-role-no-url-suffix', template);
862
+ expect(noUndefined(template)).toEqual(fixtures.get('service-role-no-url-suffix'));
1018
863
  });
1019
864
 
1020
- template = cf.merge(role);
1021
- if (update) fixtures.update('service-role-url-suffix', template);
1022
- assert.deepEqual(
1023
- noUndefined(template),
1024
- fixtures.get('service-role-url-suffix'),
1025
- 'expected resources generated, service for which AWS::URLSuffix is invalid'
1026
- );
865
+ test('expected resources generated, service for which AWS::URLSuffix is valid', () => {
866
+ const role = new cf.shortcuts.ServiceRole({
867
+ LogicalName: 'MyRole',
868
+ Service: 'ec2'
869
+ });
1027
870
 
1028
- role = new cf.shortcuts.ServiceRole({
1029
- LogicalName: 'MyRole',
1030
- Service: 'ec2.amazonaws.com'
871
+ const template = cf.merge(role);
872
+ if (update) fixtures.update('service-role-url-suffix', template);
873
+ expect(noUndefined(template)).toEqual(fixtures.get('service-role-url-suffix'));
1031
874
  });
1032
875
 
1033
- template = cf.merge(role);
1034
- if (update)
1035
- fixtures.update('service-role-url-suffix-with-replacement', template);
1036
- assert.deepEqual(
1037
- noUndefined(template),
1038
- fixtures.get('service-role-url-suffix-with-replacement'),
1039
- 'expected resources generated, service for which AWS::URLSuffix is invalid specified with a suffix'
1040
- );
876
+ test('expected resources generated, service for which AWS::URLSuffix is invalid specified with a suffix', () => {
877
+ const role = new cf.shortcuts.ServiceRole({
878
+ LogicalName: 'MyRole',
879
+ Service: 'ec2.amazonaws.com'
880
+ });
1041
881
 
1042
- role = new cf.shortcuts.ServiceRole({
1043
- LogicalName: 'MyRole',
1044
- Service: 'lambda.amazonaws.com',
1045
- Statement: [
1046
- {
1047
- Effect: 'Allow',
1048
- Action: 's3:GetObject',
1049
- Resource: 'arn:aws:s3:::fake/data'
1050
- }
1051
- ],
1052
- ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
1053
- MaxSessionDuration: 3600,
1054
- Path: '/fake/',
1055
- RoleName: 'my-role',
1056
- Condition: 'Always',
1057
- DependsOn: 'AnotherThing'
1058
- });
1059
-
1060
- template = cf.merge(
1061
- { Conditions: { Always: cf.equals('1', '1') } },
1062
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1063
- role
1064
- );
1065
- if (update) fixtures.update('service-role-no-defaults', template);
1066
- assert.deepEqual(
1067
- noUndefined(template),
1068
- fixtures.get('service-role-no-defaults'),
1069
- 'expected resources generated without defaults'
1070
- );
882
+ const template = cf.merge(role);
883
+ if (update) fixtures.update('service-role-url-suffix-with-replacement', template);
884
+ expect(noUndefined(template)).toEqual(fixtures.get('service-role-url-suffix-with-replacement'));
885
+ });
886
+
887
+ test('expected resources generated without defaults', () => {
888
+ const role = new cf.shortcuts.ServiceRole({
889
+ LogicalName: 'MyRole',
890
+ Service: 'lambda.amazonaws.com',
891
+ Statement: [
892
+ {
893
+ Effect: 'Allow',
894
+ Action: 's3:GetObject',
895
+ Resource: 'arn:aws:s3:::fake/data'
896
+ }
897
+ ],
898
+ ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
899
+ MaxSessionDuration: 3600,
900
+ Path: '/fake/',
901
+ RoleName: 'my-role',
902
+ Condition: 'Always',
903
+ DependsOn: 'AnotherThing'
904
+ });
1071
905
 
1072
- assert.end();
906
+ const template = cf.merge(
907
+ { Conditions: { Always: cf.equals('1', '1') } },
908
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
909
+ role
910
+ );
911
+ if (update) fixtures.update('service-role-no-defaults', template);
912
+ expect(noUndefined(template)).toEqual(fixtures.get('service-role-no-defaults'));
913
+ });
1073
914
  });
1074
915
 
1075
- test('[shortcuts] glue database', (assert) => {
1076
- assert.throws(
1077
- () => new cf.shortcuts.GlueDatabase(),
1078
- 'Options required',
1079
- 'throws without options'
1080
- );
1081
- assert.throws(
1082
- () => new cf.shortcuts.GlueDatabase({}),
1083
- /You must provide a LogicalName and Name/,
1084
- 'throws without required parameters'
1085
- );
916
+ describe('[shortcuts] glue database', () => {
917
+ test('throws without options', () => {
918
+ expect(() => new cf.shortcuts.GlueDatabase()).toThrow('Options required');
919
+ });
1086
920
 
1087
- let db = new cf.shortcuts.GlueDatabase({
1088
- LogicalName: 'MyDatabase',
1089
- Name: 'my_database'
921
+ test('throws without required parameters', () => {
922
+ expect(() => new cf.shortcuts.GlueDatabase({})).toThrow(/You must provide a LogicalName and Name/);
1090
923
  });
1091
924
 
1092
- let template = cf.merge(db);
1093
- if (update) fixtures.update('glue-database-defaults', template);
1094
- assert.deepEqual(
1095
- noUndefined(template),
1096
- fixtures.get('glue-database-defaults'),
1097
- 'expected resources generated with defaults'
1098
- );
925
+ test('expected resources generated with defaults', () => {
926
+ const db = new cf.shortcuts.GlueDatabase({
927
+ LogicalName: 'MyDatabase',
928
+ Name: 'my_database'
929
+ });
1099
930
 
1100
- db = new cf.shortcuts.GlueDatabase({
1101
- LogicalName: 'MyDatabase',
1102
- Name: 'my_database',
1103
- CatalogId: '123456',
1104
- Description: 'my_database description',
1105
- LocationUri: 'fakeuri',
1106
- Parameters: { thing: 'a' },
1107
- Condition: 'Always',
1108
- DependsOn: 'AnotherThing'
1109
- });
1110
-
1111
- template = cf.merge(
1112
- { Conditions: { Always: cf.equals('1', '1') } },
1113
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1114
- db
1115
- );
1116
- if (update) fixtures.update('glue-database-no-defaults', template);
1117
- assert.deepEqual(
1118
- noUndefined(template),
1119
- fixtures.get('glue-database-no-defaults'),
1120
- 'expected resources generated without defaults'
1121
- );
931
+ const template = cf.merge(db);
932
+ if (update) fixtures.update('glue-database-defaults', template);
933
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-database-defaults'));
934
+ });
935
+
936
+ test('expected resources generated without defaults', () => {
937
+ const db = new cf.shortcuts.GlueDatabase({
938
+ LogicalName: 'MyDatabase',
939
+ Name: 'my_database',
940
+ CatalogId: '123456',
941
+ Description: 'my_database description',
942
+ LocationUri: 'fakeuri',
943
+ Parameters: { thing: 'a' },
944
+ Condition: 'Always',
945
+ DependsOn: 'AnotherThing'
946
+ });
1122
947
 
1123
- assert.end();
948
+ const template = cf.merge(
949
+ { Conditions: { Always: cf.equals('1', '1') } },
950
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
951
+ db
952
+ );
953
+ if (update) fixtures.update('glue-database-no-defaults', template);
954
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-database-no-defaults'));
955
+ });
1124
956
  });
1125
957
 
1126
- test('[shortcuts] glue table', (assert) => {
1127
- assert.throws(
1128
- () => new cf.shortcuts.GlueTable(),
1129
- 'Options required',
1130
- 'throws without options'
1131
- );
1132
- assert.throws(
1133
- () => new cf.shortcuts.GlueTable({}),
1134
- /You must provide a LogicalName, Name, DatabaseName, and Columns/,
1135
- 'throws without required parameters'
1136
- );
958
+ describe('[shortcuts] glue table', () => {
959
+ test('throws without options', () => {
960
+ expect(() => new cf.shortcuts.GlueTable()).toThrow('Options required');
961
+ });
1137
962
 
1138
- let db = new cf.shortcuts.GlueTable({
1139
- LogicalName: 'MyTable',
1140
- DatabaseName: 'my_database',
1141
- Name: 'my_table',
1142
- Columns: [
1143
- { Name: 'column', Type: 'string' }
1144
- ]
1145
- });
1146
-
1147
- let template = cf.merge(db);
1148
- if (update) fixtures.update('glue-table-defaults', template);
1149
- assert.deepEqual(
1150
- noUndefined(template),
1151
- fixtures.get('glue-table-defaults'),
1152
- 'expected resources generated with defaults'
1153
- );
963
+ test('throws without required parameters', () => {
964
+ expect(() => new cf.shortcuts.GlueTable({})).toThrow(/You must provide a LogicalName, Name, DatabaseName, and Columns/);
965
+ });
1154
966
 
1155
- db = new cf.shortcuts.GlueTable({
1156
- LogicalName: 'MyTable',
1157
- DatabaseName: 'my_database',
1158
- Name: 'my_table',
1159
- Columns: [
1160
- { Name: 'column', Type: 'string' }
1161
- ],
1162
- CatalogId: '1234',
1163
- Owner: 'Team',
1164
- Parameters: { table: 'params' },
1165
- Description: 'my_table description',
1166
- Retention: 12,
1167
- TableType: 'EXTERNAL_TABLE',
1168
- ViewExpandedText: '/* Presto View */',
1169
- ViewOriginalText: '/* Presto View: abc123= */',
1170
- BucketColumns: ['column'],
1171
- Compressed: true,
1172
- InputFormat: 'fake.input.format',
1173
- Location: 's3://fake/location',
1174
- OutputFormat: 'fake.output.format',
1175
- StorageParameters: { storage: 'parameters' },
1176
- SerdeInfo: {
1177
- SerializationLibrary: 'fake.serde'
1178
- },
1179
- SkewedColumns: {
1180
- SkewedColumnNames: ['column'],
1181
- SkewedColumnValueLocationMap: { fake: 'map' },
1182
- SkewedColumnValues: ['value']
1183
- },
1184
- SortColumns: [
1185
- { Column: 'column', SortOrder: 0 }
1186
- ],
1187
- StoredAsSubdirectory: true,
1188
- Condition: 'Always',
1189
- DependsOn: 'AnotherThing'
1190
- });
1191
-
1192
- template = cf.merge(
1193
- { Conditions: { Always: cf.equals('1', '1') } },
1194
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1195
- db
1196
- );
1197
- if (update) fixtures.update('glue-table-no-defaults', template);
1198
- assert.deepEqual(
1199
- noUndefined(template),
1200
- fixtures.get('glue-table-no-defaults'),
1201
- 'expected resources generated without defaults'
1202
- );
967
+ test('expected resources generated with defaults', () => {
968
+ const db = new cf.shortcuts.GlueTable({
969
+ LogicalName: 'MyTable',
970
+ DatabaseName: 'my_database',
971
+ Name: 'my_table',
972
+ Columns: [
973
+ { Name: 'column', Type: 'string' }
974
+ ]
975
+ });
976
+
977
+ const template = cf.merge(db);
978
+ if (update) fixtures.update('glue-table-defaults', template);
979
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-table-defaults'));
980
+ });
1203
981
 
1204
- assert.end();
982
+ test('expected resources generated without defaults', () => {
983
+ const db = new cf.shortcuts.GlueTable({
984
+ LogicalName: 'MyTable',
985
+ DatabaseName: 'my_database',
986
+ Name: 'my_table',
987
+ Columns: [
988
+ { Name: 'column', Type: 'string' }
989
+ ],
990
+ CatalogId: '1234',
991
+ Owner: 'Team',
992
+ Parameters: { table: 'params' },
993
+ Description: 'my_table description',
994
+ Retention: 12,
995
+ TableType: 'EXTERNAL_TABLE',
996
+ ViewExpandedText: '/* Presto View */',
997
+ ViewOriginalText: '/* Presto View: abc123= */',
998
+ BucketColumns: ['column'],
999
+ Compressed: true,
1000
+ InputFormat: 'fake.input.format',
1001
+ Location: 's3://fake/location',
1002
+ OutputFormat: 'fake.output.format',
1003
+ StorageParameters: { storage: 'parameters' },
1004
+ SerdeInfo: {
1005
+ SerializationLibrary: 'fake.serde'
1006
+ },
1007
+ SkewedColumns: {
1008
+ SkewedColumnNames: ['column'],
1009
+ SkewedColumnValueLocationMap: { fake: 'map' },
1010
+ SkewedColumnValues: ['value']
1011
+ },
1012
+ SortColumns: [
1013
+ { Column: 'column', SortOrder: 0 }
1014
+ ],
1015
+ StoredAsSubdirectory: true,
1016
+ Condition: 'Always',
1017
+ DependsOn: 'AnotherThing'
1018
+ });
1019
+
1020
+ const template = cf.merge(
1021
+ { Conditions: { Always: cf.equals('1', '1') } },
1022
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1023
+ db
1024
+ );
1025
+ if (update) fixtures.update('glue-table-no-defaults', template);
1026
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-table-no-defaults'));
1027
+ });
1205
1028
  });
1206
1029
 
1207
- test('[shortcuts] glue json table', (assert) => {
1208
- assert.throws(
1209
- () => new cf.shortcuts.GlueJsonTable(),
1210
- 'Options required',
1211
- 'throws without options'
1212
- );
1213
- assert.throws(
1214
- () => new cf.shortcuts.GlueJsonTable({}),
1215
- /You must provide a Location/,
1216
- 'throws without required parameters'
1217
- );
1030
+ describe('[shortcuts] glue json table', () => {
1031
+ test('throws without options', () => {
1032
+ expect(() => new cf.shortcuts.GlueJsonTable()).toThrow('Options required');
1033
+ });
1218
1034
 
1219
- let db = new cf.shortcuts.GlueJsonTable({
1220
- LogicalName: 'MyTable',
1221
- DatabaseName: 'my_database',
1222
- Name: 'my_table',
1223
- Columns: [
1224
- { Name: 'column', Type: 'string' }
1225
- ],
1226
- Location: 's3://fake/location'
1227
- });
1228
-
1229
- let template = cf.merge(db);
1230
- if (update) fixtures.update('glue-json-table-defaults', template);
1231
- assert.deepEqual(
1232
- noUndefined(template),
1233
- fixtures.get('glue-json-table-defaults'),
1234
- 'expected resources generated with defaults'
1235
- );
1035
+ test('throws without required parameters', () => {
1036
+ expect(() => new cf.shortcuts.GlueJsonTable({})).toThrow(/You must provide a Location/);
1037
+ });
1236
1038
 
1237
- db = new cf.shortcuts.GlueJsonTable({
1238
- LogicalName: 'MyTable',
1239
- DatabaseName: 'my_database',
1240
- Name: 'my_table',
1241
- Columns: [
1242
- { Name: 'column', Type: 'string' }
1243
- ],
1244
- CatalogId: '1234',
1245
- Owner: 'Team',
1246
- Parameters: { table: 'params' },
1247
- Description: 'my_table description',
1248
- Retention: 12,
1249
- TableType: 'EXTERNAL_TABLE',
1250
- ViewExpandedText: '/* Presto View */',
1251
- ViewOriginalText: '/* Presto View: abc123= */',
1252
- BucketColumns: ['column'],
1253
- Compressed: true,
1254
- Location: 's3://fake/location',
1255
- InputFormat: 'fake.input.format',
1256
- OutputFormat: 'fake.output.format',
1257
- StorageParameters: { storage: 'parameters' },
1258
- SerdeInfo: {
1259
- SerializationLibrary: 'fake.serde'
1260
- },
1261
- SkewedColumns: {
1262
- SkewedColumnNames: ['column'],
1263
- SkewedColumnValueLocationMap: { fake: 'map' },
1264
- SkewedColumnValues: ['value']
1265
- },
1266
- SortColumns: [
1267
- { Column: 'column', SortOrder: 0 }
1268
- ],
1269
- StoredAsSubdirectory: true,
1270
- Condition: 'Always',
1271
- DependsOn: 'AnotherThing'
1272
- });
1273
-
1274
- template = cf.merge(
1275
- { Conditions: { Always: cf.equals('1', '1') } },
1276
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1277
- db
1278
- );
1279
- if (update) fixtures.update('glue-json-table-no-defaults', template);
1280
- assert.deepEqual(
1281
- noUndefined(template),
1282
- fixtures.get('glue-json-table-no-defaults'),
1283
- 'expected resources generated without defaults'
1284
- );
1039
+ test('expected resources generated with defaults', () => {
1040
+ const db = new cf.shortcuts.GlueJsonTable({
1041
+ LogicalName: 'MyTable',
1042
+ DatabaseName: 'my_database',
1043
+ Name: 'my_table',
1044
+ Columns: [
1045
+ { Name: 'column', Type: 'string' }
1046
+ ],
1047
+ Location: 's3://fake/location'
1048
+ });
1285
1049
 
1286
- assert.end();
1050
+ const template = cf.merge(db);
1051
+ if (update) fixtures.update('glue-json-table-defaults', template);
1052
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-json-table-defaults'));
1053
+ });
1054
+
1055
+ test('expected resources generated without defaults', () => {
1056
+ const db = new cf.shortcuts.GlueJsonTable({
1057
+ LogicalName: 'MyTable',
1058
+ DatabaseName: 'my_database',
1059
+ Name: 'my_table',
1060
+ Columns: [
1061
+ { Name: 'column', Type: 'string' }
1062
+ ],
1063
+ CatalogId: '1234',
1064
+ Owner: 'Team',
1065
+ Parameters: { table: 'params' },
1066
+ Description: 'my_table description',
1067
+ Retention: 12,
1068
+ TableType: 'EXTERNAL_TABLE',
1069
+ ViewExpandedText: '/* Presto View */',
1070
+ ViewOriginalText: '/* Presto View: abc123= */',
1071
+ BucketColumns: ['column'],
1072
+ Compressed: true,
1073
+ Location: 's3://fake/location',
1074
+ InputFormat: 'fake.input.format',
1075
+ OutputFormat: 'fake.output.format',
1076
+ StorageParameters: { storage: 'parameters' },
1077
+ SerdeInfo: {
1078
+ SerializationLibrary: 'fake.serde'
1079
+ },
1080
+ SkewedColumns: {
1081
+ SkewedColumnNames: ['column'],
1082
+ SkewedColumnValueLocationMap: { fake: 'map' },
1083
+ SkewedColumnValues: ['value']
1084
+ },
1085
+ SortColumns: [
1086
+ { Column: 'column', SortOrder: 0 }
1087
+ ],
1088
+ StoredAsSubdirectory: true,
1089
+ Condition: 'Always',
1090
+ DependsOn: 'AnotherThing'
1091
+ });
1092
+
1093
+ const template = cf.merge(
1094
+ { Conditions: { Always: cf.equals('1', '1') } },
1095
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1096
+ db
1097
+ );
1098
+ if (update) fixtures.update('glue-json-table-no-defaults', template);
1099
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-json-table-no-defaults'));
1100
+ });
1287
1101
  });
1288
1102
 
1289
- test('[shortcuts] glue orc table', (assert) => {
1290
- assert.throws(
1291
- () => new cf.shortcuts.GlueOrcTable(),
1292
- 'Options required',
1293
- 'throws without options'
1294
- );
1295
- assert.throws(
1296
- () => new cf.shortcuts.GlueOrcTable({}),
1297
- /You must provide a Location/,
1298
- 'throws without required parameters'
1299
- );
1103
+ describe('[shortcuts] glue orc table', () => {
1104
+ test('throws without options', () => {
1105
+ expect(() => new cf.shortcuts.GlueOrcTable()).toThrow('Options required');
1106
+ });
1300
1107
 
1301
- let db = new cf.shortcuts.GlueOrcTable({
1302
- LogicalName: 'MyTable',
1303
- DatabaseName: 'my_database',
1304
- Name: 'my_table',
1305
- Columns: [
1306
- { Name: 'column', Type: 'string' }
1307
- ],
1308
- Location: 's3://fake/location'
1309
- });
1310
-
1311
- let template = cf.merge(db);
1312
- if (update) fixtures.update('glue-orc-table-defaults', template);
1313
- assert.deepEqual(
1314
- noUndefined(template),
1315
- fixtures.get('glue-orc-table-defaults'),
1316
- 'expected resources generated with defaults'
1317
- );
1108
+ test('throws without required parameters', () => {
1109
+ expect(() => new cf.shortcuts.GlueOrcTable({})).toThrow(/You must provide a Location/);
1110
+ });
1318
1111
 
1319
- db = new cf.shortcuts.GlueOrcTable({
1320
- LogicalName: 'MyTable',
1321
- DatabaseName: 'my_database',
1322
- Name: 'my_table',
1323
- Columns: [
1324
- { Name: 'column', Type: 'string' }
1325
- ],
1326
- CatalogId: '1234',
1327
- Owner: 'Team',
1328
- Parameters: { table: 'params' },
1329
- Description: 'my_table description',
1330
- Retention: 12,
1331
- TableType: 'EXTERNAL_TABLE',
1332
- ViewExpandedText: '/* Presto View */',
1333
- ViewOriginalText: '/* Presto View: abc123= */',
1334
- BucketColumns: ['column'],
1335
- Compressed: true,
1336
- Location: 's3://fake/location',
1337
- InputFormat: 'fake.input.format',
1338
- OutputFormat: 'fake.output.format',
1339
- StorageParameters: { storage: 'parameters' },
1340
- SerdeInfo: {
1341
- SerializationLibrary: 'fake.serde'
1342
- },
1343
- SkewedColumns: {
1344
- SkewedColumnNames: ['column'],
1345
- SkewedColumnValueLocationMap: { fake: 'map' },
1346
- SkewedColumnValues: ['value']
1347
- },
1348
- SortColumns: [
1349
- { Column: 'column', SortOrder: 0 }
1350
- ],
1351
- StoredAsSubdirectory: true,
1352
- Condition: 'Always',
1353
- DependsOn: 'AnotherThing'
1354
- });
1355
-
1356
- template = cf.merge(
1357
- { Conditions: { Always: cf.equals('1', '1') } },
1358
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1359
- db
1360
- );
1361
- if (update) fixtures.update('glue-orc-table-no-defaults', template);
1362
- assert.deepEqual(
1363
- noUndefined(template),
1364
- fixtures.get('glue-orc-table-no-defaults'),
1365
- 'expected resources generated without defaults'
1366
- );
1112
+ test('expected resources generated with defaults', () => {
1113
+ const db = new cf.shortcuts.GlueOrcTable({
1114
+ LogicalName: 'MyTable',
1115
+ DatabaseName: 'my_database',
1116
+ Name: 'my_table',
1117
+ Columns: [
1118
+ { Name: 'column', Type: 'string' }
1119
+ ],
1120
+ Location: 's3://fake/location'
1121
+ });
1122
+
1123
+ const template = cf.merge(db);
1124
+ if (update) fixtures.update('glue-orc-table-defaults', template);
1125
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-orc-table-defaults'));
1126
+ });
1127
+
1128
+ test('expected resources generated without defaults', () => {
1129
+ const db = new cf.shortcuts.GlueOrcTable({
1130
+ LogicalName: 'MyTable',
1131
+ DatabaseName: 'my_database',
1132
+ Name: 'my_table',
1133
+ Columns: [
1134
+ { Name: 'column', Type: 'string' }
1135
+ ],
1136
+ CatalogId: '1234',
1137
+ Owner: 'Team',
1138
+ Parameters: { table: 'params' },
1139
+ Description: 'my_table description',
1140
+ Retention: 12,
1141
+ TableType: 'EXTERNAL_TABLE',
1142
+ ViewExpandedText: '/* Presto View */',
1143
+ ViewOriginalText: '/* Presto View: abc123= */',
1144
+ BucketColumns: ['column'],
1145
+ Compressed: true,
1146
+ Location: 's3://fake/location',
1147
+ InputFormat: 'fake.input.format',
1148
+ OutputFormat: 'fake.output.format',
1149
+ StorageParameters: { storage: 'parameters' },
1150
+ SerdeInfo: {
1151
+ SerializationLibrary: 'fake.serde'
1152
+ },
1153
+ SkewedColumns: {
1154
+ SkewedColumnNames: ['column'],
1155
+ SkewedColumnValueLocationMap: { fake: 'map' },
1156
+ SkewedColumnValues: ['value']
1157
+ },
1158
+ SortColumns: [
1159
+ { Column: 'column', SortOrder: 0 }
1160
+ ],
1161
+ StoredAsSubdirectory: true,
1162
+ Condition: 'Always',
1163
+ DependsOn: 'AnotherThing'
1164
+ });
1367
1165
 
1368
- assert.end();
1166
+ const template = cf.merge(
1167
+ { Conditions: { Always: cf.equals('1', '1') } },
1168
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1169
+ db
1170
+ );
1171
+ if (update) fixtures.update('glue-orc-table-no-defaults', template);
1172
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-orc-table-no-defaults'));
1173
+ });
1369
1174
  });
1370
1175
 
1371
- test('[shortcuts] glue parquet table', (assert) => {
1372
- assert.throws(
1373
- () => new cf.shortcuts.GlueParquetTable(),
1374
- 'Options required',
1375
- 'throws without options'
1376
- );
1377
- assert.throws(
1378
- () => new cf.shortcuts.GlueParquetTable({}),
1379
- /You must provide a Location/,
1380
- 'throws without required parameters'
1381
- );
1176
+ describe('[shortcuts] glue parquet table', () => {
1177
+ test('throws without options', () => {
1178
+ expect(() => new cf.shortcuts.GlueParquetTable()).toThrow('Options required');
1179
+ });
1382
1180
 
1383
- let db = new cf.shortcuts.GlueParquetTable({
1384
- LogicalName: 'MyTable',
1385
- DatabaseName: 'my_database',
1386
- Name: 'my_table',
1387
- Columns: [
1388
- { Name: 'column', Type: 'string' }
1389
- ],
1390
- Location: 's3://fake/location'
1391
- });
1392
-
1393
- let template = cf.merge(db);
1394
- if (update) fixtures.update('glue-parquet-table-defaults', template);
1395
- assert.deepEqual(
1396
- noUndefined(template),
1397
- fixtures.get('glue-parquet-table-defaults'),
1398
- 'expected resources generated with defaults'
1399
- );
1181
+ test('throws without required parameters', () => {
1182
+ expect(() => new cf.shortcuts.GlueParquetTable({})).toThrow(/You must provide a Location/);
1183
+ });
1400
1184
 
1401
- db = new cf.shortcuts.GlueParquetTable({
1402
- LogicalName: 'MyTable',
1403
- DatabaseName: 'my_database',
1404
- Name: 'my_table',
1405
- Columns: [
1406
- { Name: 'column', Type: 'string' }
1407
- ],
1408
- CatalogId: '1234',
1409
- Owner: 'Team',
1410
- Parameters: { table: 'params' },
1411
- Description: 'my_table description',
1412
- Retention: 12,
1413
- TableType: 'EXTERNAL_TABLE',
1414
- ViewExpandedText: '/* Presto View */',
1415
- ViewOriginalText: '/* Presto View: abc123= */',
1416
- BucketColumns: ['column'],
1417
- Compressed: true,
1418
- Location: 's3://fake/location',
1419
- InputFormat: 'fake.input.format',
1420
- OutputFormat: 'fake.output.format',
1421
- StorageParameters: { storage: 'parameters' },
1422
- SerdeInfo: {
1423
- SerializationLibrary: 'fake.serde'
1424
- },
1425
- SkewedColumns: {
1426
- SkewedColumnNames: ['column'],
1427
- SkewedColumnValueLocationMap: { fake: 'map' },
1428
- SkewedColumnValues: ['value']
1429
- },
1430
- SortColumns: [
1431
- { Column: 'column', SortOrder: 0 }
1432
- ],
1433
- StoredAsSubdirectory: true,
1434
- Condition: 'Always',
1435
- DependsOn: 'AnotherThing'
1436
- });
1437
-
1438
- template = cf.merge(
1439
- { Conditions: { Always: cf.equals('1', '1') } },
1440
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1441
- db
1442
- );
1443
- if (update) fixtures.update('glue-parquet-table-no-defaults', template);
1444
- assert.deepEqual(
1445
- noUndefined(template),
1446
- fixtures.get('glue-parquet-table-no-defaults'),
1447
- 'expected resources generated without defaults'
1448
- );
1185
+ test('expected resources generated with defaults', () => {
1186
+ const db = new cf.shortcuts.GlueParquetTable({
1187
+ LogicalName: 'MyTable',
1188
+ DatabaseName: 'my_database',
1189
+ Name: 'my_table',
1190
+ Columns: [
1191
+ { Name: 'column', Type: 'string' }
1192
+ ],
1193
+ Location: 's3://fake/location'
1194
+ });
1195
+
1196
+ const template = cf.merge(db);
1197
+ if (update) fixtures.update('glue-parquet-table-defaults', template);
1198
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-parquet-table-defaults'));
1199
+ });
1200
+
1201
+ test('expected resources generated without defaults', () => {
1202
+ const db = new cf.shortcuts.GlueParquetTable({
1203
+ LogicalName: 'MyTable',
1204
+ DatabaseName: 'my_database',
1205
+ Name: 'my_table',
1206
+ Columns: [
1207
+ { Name: 'column', Type: 'string' }
1208
+ ],
1209
+ CatalogId: '1234',
1210
+ Owner: 'Team',
1211
+ Parameters: { table: 'params' },
1212
+ Description: 'my_table description',
1213
+ Retention: 12,
1214
+ TableType: 'EXTERNAL_TABLE',
1215
+ ViewExpandedText: '/* Presto View */',
1216
+ ViewOriginalText: '/* Presto View: abc123= */',
1217
+ BucketColumns: ['column'],
1218
+ Compressed: true,
1219
+ Location: 's3://fake/location',
1220
+ InputFormat: 'fake.input.format',
1221
+ OutputFormat: 'fake.output.format',
1222
+ StorageParameters: { storage: 'parameters' },
1223
+ SerdeInfo: {
1224
+ SerializationLibrary: 'fake.serde'
1225
+ },
1226
+ SkewedColumns: {
1227
+ SkewedColumnNames: ['column'],
1228
+ SkewedColumnValueLocationMap: { fake: 'map' },
1229
+ SkewedColumnValues: ['value']
1230
+ },
1231
+ SortColumns: [
1232
+ { Column: 'column', SortOrder: 0 }
1233
+ ],
1234
+ StoredAsSubdirectory: true,
1235
+ Condition: 'Always',
1236
+ DependsOn: 'AnotherThing'
1237
+ });
1449
1238
 
1450
- assert.end();
1239
+ const template = cf.merge(
1240
+ { Conditions: { Always: cf.equals('1', '1') } },
1241
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1242
+ db
1243
+ );
1244
+ if (update) fixtures.update('glue-parquet-table-no-defaults', template);
1245
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-parquet-table-no-defaults'));
1246
+ });
1451
1247
  });
1452
1248
 
1453
- test('[shortcuts] glue view', (assert) => {
1454
- assert.throws(
1455
- () => new cf.shortcuts.GluePrestoView(),
1456
- 'Options required',
1457
- 'throws without options'
1458
- );
1459
- assert.throws(
1460
- () => new cf.shortcuts.GluePrestoView({}),
1461
- /You must provide a DatabaseName, Columns, and OriginalSql/,
1462
- 'throws without required parameters'
1463
- );
1249
+ describe('[shortcuts] glue view', () => {
1250
+ test('throws without options', () => {
1251
+ expect(() => new cf.shortcuts.GluePrestoView()).toThrow('Options required');
1252
+ });
1464
1253
 
1465
- let db = new cf.shortcuts.GluePrestoView({
1466
- LogicalName: 'MyView',
1467
- DatabaseName: 'my_database',
1468
- Name: 'my_view',
1469
- Columns: [
1470
- { Name: 'column', Type: 'string' }
1471
- ],
1472
- OriginalSql: 'SELECT * FROM another.table'
1473
- });
1474
-
1475
- let template = cf.merge(db);
1476
- if (update) fixtures.update('glue-view-defaults', template);
1477
- assert.deepEqual(
1478
- noUndefined(template),
1479
- fixtures.get('glue-view-defaults'),
1480
- 'expected resources generated with defaults'
1481
- );
1254
+ test('throws without required parameters', () => {
1255
+ expect(() => new cf.shortcuts.GluePrestoView({})).toThrow(/You must provide a DatabaseName, Columns, and OriginalSql/);
1256
+ });
1482
1257
 
1483
- db = new cf.shortcuts.GluePrestoView({
1484
- LogicalName: 'MyTable',
1485
- DatabaseName: 'my_database',
1486
- Name: 'my_view',
1487
- Columns: [
1488
- { Name: 'column', Type: 'string' }
1489
- ],
1490
- OriginalSql: 'SELECT * FROM another.table',
1491
- CatalogId: '1234',
1492
- Owner: 'Team',
1493
- Parameters: { table: 'params' },
1494
- Description: 'my_view description',
1495
- Retention: 12,
1496
- TableType: 'EXTERNAL_TABLE',
1497
- BucketColumns: ['column'],
1498
- Compressed: true,
1499
- Location: 's3://fake/location',
1500
- InputFormat: 'fake.input.format',
1501
- OutputFormat: 'fake.output.format',
1502
- StorageParameters: { storage: 'parameters' },
1503
- SerdeInfo: {
1504
- SerializationLibrary: 'fake.serde'
1505
- },
1506
- SkewedColumns: {
1507
- SkewedColumnNames: ['column'],
1508
- SkewedColumnValueLocationMap: { fake: 'map' },
1509
- SkewedColumnValues: ['value']
1510
- },
1511
- SortColumns: [
1512
- { Column: 'column', SortOrder: 0 }
1513
- ],
1514
- StoredAsSubdirectory: true,
1515
- SqlVariables: { env: { Ref: 'AWS::StackName' } },
1516
- Condition: 'Always',
1517
- DependsOn: 'AnotherThing'
1518
- });
1519
-
1520
- template = cf.merge(
1521
- { Conditions: { Always: cf.equals('1', '1') } },
1522
- { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1523
- db
1524
- );
1525
- if (update) fixtures.update('glue-view-no-defaults', template);
1526
- assert.deepEqual(
1527
- noUndefined(template),
1528
- fixtures.get('glue-view-no-defaults'),
1529
- 'expected resources generated without defaults'
1530
- );
1258
+ test('expected resources generated with defaults', () => {
1259
+ const db = new cf.shortcuts.GluePrestoView({
1260
+ LogicalName: 'MyView',
1261
+ DatabaseName: 'my_database',
1262
+ Name: 'my_view',
1263
+ Columns: [
1264
+ { Name: 'column', Type: 'string' }
1265
+ ],
1266
+ OriginalSql: 'SELECT * FROM another.table'
1267
+ });
1531
1268
 
1532
- assert.end();
1269
+ const template = cf.merge(db);
1270
+ if (update) fixtures.update('glue-view-defaults', template);
1271
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-view-defaults'));
1272
+ });
1273
+
1274
+ test('expected resources generated without defaults', () => {
1275
+ const db = new cf.shortcuts.GluePrestoView({
1276
+ LogicalName: 'MyTable',
1277
+ DatabaseName: 'my_database',
1278
+ Name: 'my_view',
1279
+ Columns: [
1280
+ { Name: 'column', Type: 'string' }
1281
+ ],
1282
+ OriginalSql: 'SELECT * FROM another.table',
1283
+ CatalogId: '1234',
1284
+ Owner: 'Team',
1285
+ Parameters: { table: 'params' },
1286
+ Description: 'my_view description',
1287
+ Retention: 12,
1288
+ TableType: 'EXTERNAL_TABLE',
1289
+ BucketColumns: ['column'],
1290
+ Compressed: true,
1291
+ Location: 's3://fake/location',
1292
+ InputFormat: 'fake.input.format',
1293
+ OutputFormat: 'fake.output.format',
1294
+ StorageParameters: { storage: 'parameters' },
1295
+ SerdeInfo: {
1296
+ SerializationLibrary: 'fake.serde'
1297
+ },
1298
+ SkewedColumns: {
1299
+ SkewedColumnNames: ['column'],
1300
+ SkewedColumnValueLocationMap: { fake: 'map' },
1301
+ SkewedColumnValues: ['value']
1302
+ },
1303
+ SortColumns: [
1304
+ { Column: 'column', SortOrder: 0 }
1305
+ ],
1306
+ StoredAsSubdirectory: true,
1307
+ SqlVariables: { env: { Ref: 'AWS::StackName' } },
1308
+ Condition: 'Always',
1309
+ DependsOn: 'AnotherThing'
1310
+ });
1311
+
1312
+ const template = cf.merge(
1313
+ { Conditions: { Always: cf.equals('1', '1') } },
1314
+ { Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
1315
+ db
1316
+ );
1317
+ if (update) fixtures.update('glue-view-no-defaults', template);
1318
+ expect(noUndefined(template)).toEqual(fixtures.get('glue-view-no-defaults'));
1319
+ });
1533
1320
  });
1534
1321
 
1535
1322
  const normalizeDeployment = (template) => {
@@ -1540,230 +1327,192 @@ const normalizeDeployment = (template) => {
1540
1327
  return JSON.parse(str);
1541
1328
  };
1542
1329
 
1543
- test('[shortcuts] hookshot passthrough', (assert) => {
1544
- assert.throws(
1545
- () => new cf.shortcuts.hookshot.Passthrough(),
1546
- 'Options required',
1547
- 'throws without options'
1548
- );
1549
- assert.throws(
1550
- () => new cf.shortcuts.hookshot.Passthrough({}),
1551
- /You must provide a Prefix, and PassthroughTo/,
1552
- 'throws without required parameters'
1553
- );
1330
+ describe('[shortcuts] hookshot passthrough', () => {
1331
+ test('throws without options', () => {
1332
+ expect(() => new cf.shortcuts.hookshot.Passthrough()).toThrow('Options required');
1333
+ });
1554
1334
 
1555
- assert.throws(
1556
- () =>
1557
- new cf.shortcuts.hookshot.Passthrough({
1558
- Prefix: 'Pass',
1559
- PassthroughTo: 'Destination',
1560
- LoggingLevel: 'HAM'
1561
- }),
1562
- /LoggingLevel must be one of OFF, INFO, or ERROR/,
1563
- 'throws with invalid LoggingLevel'
1564
- );
1335
+ test('throws without required parameters', () => {
1336
+ expect(() => new cf.shortcuts.hookshot.Passthrough({})).toThrow(/You must provide a Prefix, and PassthroughTo/);
1337
+ });
1565
1338
 
1566
- assert.throws(
1567
- () =>
1568
- new cf.shortcuts.hookshot.Passthrough({
1569
- Prefix: 'Pass',
1570
- PassthroughTo: 'Destination',
1571
- LoggingLevel: 'INFO',
1572
- Runtime: 'python3.7'
1573
- }),
1574
- /Only valid nodejs runtimes are supported for hookshot lambdas, received: 'python3.7'/,
1575
- 'throws with invalid lambda Runtime python3.7'
1576
- );
1339
+ test('throws with invalid LoggingLevel', () => {
1340
+ expect(() => new cf.shortcuts.hookshot.Passthrough({
1341
+ Prefix: 'Pass',
1342
+ PassthroughTo: 'Destination',
1343
+ LoggingLevel: 'HAM'
1344
+ })).toThrow(/LoggingLevel must be one of OFF, INFO, or ERROR/);
1345
+ });
1577
1346
 
1578
- assert.throws(
1579
- () =>
1580
- new cf.shortcuts.hookshot.Passthrough({
1581
- Prefix: 'Pass',
1582
- PassthroughTo: 'Destination',
1583
- LoggingLevel: 'INFO',
1584
- Runtime: 'nodejs16.x'
1585
- }),
1586
- /Only nodejs runtimes >= 18 are supported for hookshot lambdas, received: 'nodejs16.x'/,
1587
- 'throws with invalid lambda Runtime nodejs16.x'
1588
- );
1347
+ test('throws with invalid lambda Runtime python3.7', () => {
1348
+ expect(() => new cf.shortcuts.hookshot.Passthrough({
1349
+ Prefix: 'Pass',
1350
+ PassthroughTo: 'Destination',
1351
+ LoggingLevel: 'INFO',
1352
+ Runtime: 'python3.7'
1353
+ })).toThrow(/Only valid nodejs runtimes are supported for hookshot lambdas, received: 'python3.7'/);
1354
+ });
1589
1355
 
1590
- const to = new cf.shortcuts.Lambda({
1356
+ test('throws with invalid lambda Runtime nodejs16.x', () => {
1357
+ expect(() => new cf.shortcuts.hookshot.Passthrough({
1358
+ Prefix: 'Pass',
1359
+ PassthroughTo: 'Destination',
1360
+ LoggingLevel: 'INFO',
1361
+ Runtime: 'nodejs16.x'
1362
+ })).toThrow(/Only nodejs runtimes >= 18 are supported for hookshot lambdas, received: 'nodejs16.x'/);
1363
+ });
1364
+
1365
+ const getDestinationLambda = () => new cf.shortcuts.Lambda({
1591
1366
  LogicalName: 'Destination',
1592
1367
  Code: {
1593
1368
  ZipFile: 'module.exports.handler = (e, c, cb) => cb();'
1594
1369
  }
1595
1370
  });
1596
1371
 
1597
- let passthrough = new cf.shortcuts.hookshot.Passthrough({
1598
- Prefix: 'Pass',
1599
- PassthroughTo: 'Destination'
1372
+ test('expected resources generated with defaults', () => {
1373
+ const to = getDestinationLambda();
1374
+ const passthrough = new cf.shortcuts.hookshot.Passthrough({
1375
+ Prefix: 'Pass',
1376
+ PassthroughTo: 'Destination'
1377
+ });
1378
+
1379
+ const template = cf.merge(passthrough, to);
1380
+ if (update) fixtures.update('hookshot-passthrough', template);
1381
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough')));
1600
1382
  });
1601
1383
 
1602
- let template = cf.merge(passthrough, to);
1603
- if (update) fixtures.update('hookshot-passthrough', template);
1604
- assert.deepEqual(
1605
- normalizeDeployment(noUndefined(template)),
1606
- normalizeDeployment(fixtures.get('hookshot-passthrough')),
1607
- 'expected resources generated with defaults'
1608
- );
1384
+ test('expected resources generated with alarm config', () => {
1385
+ const to = getDestinationLambda();
1386
+ const passthrough = new cf.shortcuts.hookshot.Passthrough({
1387
+ Prefix: 'Pass',
1388
+ PassthroughTo: 'Destination',
1389
+ AlarmActions: ['devnull@mapbox.com']
1390
+ });
1609
1391
 
1610
- passthrough = new cf.shortcuts.hookshot.Passthrough({
1611
- Prefix: 'Pass',
1612
- PassthroughTo: 'Destination',
1613
- AlarmActions: ['devnull@mapbox.com']
1392
+ const template = cf.merge(passthrough, to);
1393
+ if (update) fixtures.update('hookshot-passthrough-alarms', template);
1394
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough-alarms')));
1614
1395
  });
1615
1396
 
1616
- template = cf.merge(passthrough, to);
1617
- if (update) fixtures.update('hookshot-passthrough-alarms', template);
1618
- assert.deepEqual(
1619
- normalizeDeployment(noUndefined(template)),
1620
- normalizeDeployment(fixtures.get('hookshot-passthrough-alarms')),
1621
- 'expected resources generated with alarm config'
1622
- );
1397
+ test('expected resources generated with configured LoggingLevel', () => {
1398
+ const to = getDestinationLambda();
1399
+ const passthrough = new cf.shortcuts.hookshot.Passthrough({
1400
+ Prefix: 'Pass',
1401
+ PassthroughTo: 'Destination',
1402
+ LoggingLevel: 'INFO'
1403
+ });
1623
1404
 
1624
- passthrough = new cf.shortcuts.hookshot.Passthrough({
1625
- Prefix: 'Pass',
1626
- PassthroughTo: 'Destination',
1627
- LoggingLevel: 'INFO'
1405
+ const template = cf.merge(passthrough, to);
1406
+ if (update) fixtures.update('hookshot-passthrough-logging', template);
1407
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough-logging')));
1628
1408
  });
1629
1409
 
1630
- template = cf.merge(passthrough, to);
1631
- if (update) fixtures.update('hookshot-passthrough-logging', template);
1632
- assert.deepEqual(
1633
- normalizeDeployment(noUndefined(template)),
1634
- normalizeDeployment(fixtures.get('hookshot-passthrough-logging')),
1635
- 'expected resources generated with configured LoggingLevel'
1636
- );
1410
+ test('expected resources generated with detailed logging and metrics', () => {
1411
+ const to = getDestinationLambda();
1412
+ const passthrough = new cf.shortcuts.hookshot.Passthrough({
1413
+ Prefix: 'Pass',
1414
+ PassthroughTo: 'Destination',
1415
+ DataTraceEnabled: true,
1416
+ MetricsEnabled: true
1417
+ });
1637
1418
 
1638
- passthrough = new cf.shortcuts.hookshot.Passthrough({
1639
- Prefix: 'Pass',
1640
- PassthroughTo: 'Destination',
1641
- DataTraceEnabled: true,
1642
- MetricsEnabled: true
1419
+ const template = cf.merge(passthrough, to);
1420
+ if (update) fixtures.update('hookshot-passthrough-enhanced-logging', template);
1421
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough-enhanced-logging')));
1643
1422
  });
1644
1423
 
1645
- template = cf.merge(passthrough, to);
1646
- if (update)
1647
- fixtures.update('hookshot-passthrough-enhanced-logging', template);
1648
- assert.deepEqual(
1649
- normalizeDeployment(noUndefined(template)),
1650
- normalizeDeployment(fixtures.get('hookshot-passthrough-enhanced-logging')),
1651
- 'expected resources generated with detailed logging and metrics'
1652
- );
1653
-
1654
- passthrough = new cf.shortcuts.hookshot.Passthrough({
1655
- Prefix: 'Pass',
1656
- PassthroughTo: 'Destination',
1657
- DataTraceEnabled: true,
1658
- MetricsEnabled: true,
1659
- LoggingLevel: 'INFO'
1660
- });
1661
-
1662
- template = cf.merge(passthrough, to);
1663
- if (update)
1664
- fixtures.update('hookshot-passthrough-full-blown-logging', template);
1665
- assert.deepEqual(
1666
- normalizeDeployment(noUndefined(template)),
1667
- normalizeDeployment(
1668
- fixtures.get('hookshot-passthrough-full-blown-logging')
1669
- ),
1670
- 'LoggingLevel respected with detailed logging and metrics'
1671
- );
1424
+ test('LoggingLevel respected with detailed logging and metrics', () => {
1425
+ const to = getDestinationLambda();
1426
+ const passthrough = new cf.shortcuts.hookshot.Passthrough({
1427
+ Prefix: 'Pass',
1428
+ PassthroughTo: 'Destination',
1429
+ DataTraceEnabled: true,
1430
+ MetricsEnabled: true,
1431
+ LoggingLevel: 'INFO'
1432
+ });
1672
1433
 
1673
- passthrough = new cf.shortcuts.hookshot.Passthrough({
1674
- Prefix: 'Pass',
1675
- PassthroughTo: 'Destination',
1676
- AccessLogFormat: '{ "requestId":"$context.requestId" }'
1434
+ const template = cf.merge(passthrough, to);
1435
+ if (update) fixtures.update('hookshot-passthrough-full-blown-logging', template);
1436
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough-full-blown-logging')));
1677
1437
  });
1678
1438
 
1679
- template = cf.merge(passthrough, to);
1680
- if (update)
1681
- fixtures.update('hookshot-passthrough-access-log-format', template);
1682
- assert.deepEqual(
1683
- normalizeDeployment(noUndefined(template)),
1684
- normalizeDeployment(fixtures.get('hookshot-passthrough-access-log-format')),
1685
- 'expected resources generated with access logs'
1686
- );
1439
+ test('expected resources generated with access logs', () => {
1440
+ const to = getDestinationLambda();
1441
+ const passthrough = new cf.shortcuts.hookshot.Passthrough({
1442
+ Prefix: 'Pass',
1443
+ PassthroughTo: 'Destination',
1444
+ AccessLogFormat: '{ "requestId":"$context.requestId" }'
1445
+ });
1687
1446
 
1688
- assert.end();
1447
+ const template = cf.merge(passthrough, to);
1448
+ if (update) fixtures.update('hookshot-passthrough-access-log-format', template);
1449
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough-access-log-format')));
1450
+ });
1689
1451
  });
1690
1452
 
1691
- test('[shortcuts] hookshot github', (assert) => {
1692
- assert.throws(
1693
- () => new cf.shortcuts.hookshot.Github(),
1694
- /You must provide a Prefix, and PassthroughTo/,
1695
- 'throws without required parameters'
1696
- );
1453
+ describe('[shortcuts] hookshot github', () => {
1454
+ test('throws without required parameters', () => {
1455
+ expect(() => new cf.shortcuts.hookshot.Github()).toThrow(/You must provide a Prefix, and PassthroughTo/);
1456
+ });
1697
1457
 
1698
- assert.throws(
1699
- () =>
1700
- new cf.shortcuts.hookshot.Github({
1701
- Prefix: 'Pass',
1702
- PassthroughTo: 'Destination',
1703
- Runtime: 'python3.7'
1704
- }),
1705
- /Only valid nodejs runtimes are supported for hookshot lambdas, received: 'python3.7'/,
1706
- 'throws with invalid lambda Runtime python3.7'
1707
- );
1458
+ test('throws with invalid lambda Runtime python3.7', () => {
1459
+ expect(() => new cf.shortcuts.hookshot.Github({
1460
+ Prefix: 'Pass',
1461
+ PassthroughTo: 'Destination',
1462
+ Runtime: 'python3.7'
1463
+ })).toThrow(/Only valid nodejs runtimes are supported for hookshot lambdas, received: 'python3.7'/);
1464
+ });
1708
1465
 
1709
- assert.throws(
1710
- () =>
1711
- new cf.shortcuts.hookshot.Github({
1712
- Prefix: 'Pass',
1713
- PassthroughTo: 'Destination',
1714
- Runtime: 'nodejs16.x'
1715
- }),
1716
- /Only nodejs runtimes >= 18 are supported for hookshot lambdas, received: 'nodejs16.x'/,
1717
- 'throws with invalid lambda Runtime nodejs16.x'
1718
- );
1466
+ test('throws with invalid lambda Runtime nodejs16.x', () => {
1467
+ expect(() => new cf.shortcuts.hookshot.Github({
1468
+ Prefix: 'Pass',
1469
+ PassthroughTo: 'Destination',
1470
+ Runtime: 'nodejs16.x'
1471
+ })).toThrow(/Only nodejs runtimes >= 18 are supported for hookshot lambdas, received: 'nodejs16.x'/);
1472
+ });
1719
1473
 
1720
- const to = new cf.shortcuts.Lambda({
1474
+ const getDestinationLambda = () => new cf.shortcuts.Lambda({
1721
1475
  LogicalName: 'Destination',
1722
1476
  Code: {
1723
1477
  ZipFile: 'module.exports.handler = (e, c, cb) => cb();'
1724
1478
  }
1725
1479
  });
1726
1480
 
1727
- let github = new cf.shortcuts.hookshot.Github({
1728
- Prefix: 'Pass',
1729
- PassthroughTo: 'Destination'
1730
- });
1731
-
1732
- let template = cf.merge(github, to);
1733
- if (update) fixtures.update('hookshot-github', template);
1734
- assert.deepEqual(
1735
- normalizeDeployment(noUndefined(template)),
1736
- normalizeDeployment(fixtures.get('hookshot-github')),
1737
- 'expected resources generated with defaults'
1738
- );
1481
+ test('expected resources generated with defaults', () => {
1482
+ const to = getDestinationLambda();
1483
+ const github = new cf.shortcuts.hookshot.Github({
1484
+ Prefix: 'Pass',
1485
+ PassthroughTo: 'Destination'
1486
+ });
1739
1487
 
1740
- github = new cf.shortcuts.hookshot.Github({
1741
- Prefix: 'Pass',
1742
- PassthroughTo: 'Destination',
1743
- WebhookSecret: 'abc123'
1488
+ const template = cf.merge(github, to);
1489
+ if (update) fixtures.update('hookshot-github', template);
1490
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-github')));
1744
1491
  });
1745
1492
 
1746
- template = cf.merge(github, to);
1747
- if (update) fixtures.update('hookshot-github-secret-string', template);
1748
- assert.deepEqual(
1749
- normalizeDeployment(noUndefined(template)),
1750
- normalizeDeployment(fixtures.get('hookshot-github-secret-string')),
1751
- 'expected resources generated when secret passed as string'
1752
- );
1493
+ test('expected resources generated when secret passed as string', () => {
1494
+ const to = getDestinationLambda();
1495
+ const github = new cf.shortcuts.hookshot.Github({
1496
+ Prefix: 'Pass',
1497
+ PassthroughTo: 'Destination',
1498
+ WebhookSecret: 'abc123'
1499
+ });
1753
1500
 
1754
- github = new cf.shortcuts.hookshot.Github({
1755
- Prefix: 'Pass',
1756
- PassthroughTo: 'Destination',
1757
- WebhookSecret: cf.ref('SomeParameter')
1758
- });
1759
- const Parameters = { SomeParameter: { Type: 'String' } };
1760
- template = cf.merge(github, to, { Parameters });
1761
- if (update) fixtures.update('hookshot-github-secret-ref', template);
1762
- assert.deepEqual(
1763
- normalizeDeployment(noUndefined(template)),
1764
- normalizeDeployment(fixtures.get('hookshot-github-secret-ref')),
1765
- 'expected resources generated when secret passed as ref'
1766
- );
1501
+ const template = cf.merge(github, to);
1502
+ if (update) fixtures.update('hookshot-github-secret-string', template);
1503
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-github-secret-string')));
1504
+ });
1767
1505
 
1768
- assert.end();
1506
+ test('expected resources generated when secret passed as ref', () => {
1507
+ const to = getDestinationLambda();
1508
+ const github = new cf.shortcuts.hookshot.Github({
1509
+ Prefix: 'Pass',
1510
+ PassthroughTo: 'Destination',
1511
+ WebhookSecret: cf.ref('SomeParameter')
1512
+ });
1513
+ const Parameters = { SomeParameter: { Type: 'String' } };
1514
+ const template = cf.merge(github, to, { Parameters });
1515
+ if (update) fixtures.update('hookshot-github-secret-ref', template);
1516
+ expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-github-secret-ref')));
1517
+ });
1769
1518
  });