@@ -17,10 +17,33 @@ describe('api key', () => {
17
17
// should have an api key with no props defined.
18
18
} ) ;
19
19
20
+
21
+ test ( 'enabled flag is respected' , ( ) => {
22
+ // GIVEN
23
+ const stack = new cdk . Stack ( ) ;
24
+
25
+ // WHEN
26
+ new apigateway . ApiKey ( stack , 'my-api-key' , {
27
+ enabled : false ,
28
+ value : 'arandomstringwithmorethantwentycharacters' ,
29
+ } ) ;
30
+
31
+ // THEN
32
+ expect ( stack ) . toHaveResource ( 'AWS::ApiGateway::ApiKey' , {
33
+ Enabled : false ,
34
+ Value : 'arandomstringwithmorethantwentycharacters' ,
35
+ } ) ;
36
+ } ) ;
37
+
38
+
20
39
test ( 'specify props for apiKey' , ( ) => {
21
40
// GIVEN
22
41
const stack = new cdk . Stack ( ) ;
23
- const api = new apigateway . RestApi ( stack , 'test-api' , { cloudWatchRole : false , deploy : true , deployOptions : { stageName : 'test' } } ) ;
42
+ const api = new apigateway . RestApi ( stack , 'test-api' , {
43
+ cloudWatchRole : false ,
44
+ deploy : true ,
45
+ deployOptions : { stageName : 'test' } ,
46
+ } ) ;
24
47
api . root . addMethod ( 'GET' ) ; // api must have atleast one method.
25
48
26
49
// WHEN
@@ -61,7 +84,11 @@ describe('api key', () => {
61
84
test ( 'use an imported api key' , ( ) => {
62
85
// GIVEN
63
86
const stack = new cdk . Stack ( ) ;
64
- const api = new apigateway . RestApi ( stack , 'test-api' , { cloudWatchRole : false , deploy : true , deployOptions : { stageName : 'test' } } ) ;
87
+ const api = new apigateway . RestApi ( stack , 'test-api' , {
88
+ cloudWatchRole : false ,
89
+ deploy : true ,
90
+ deployOptions : { stageName : 'test' } ,
91
+ } ) ;
65
92
api . root . addMethod ( 'GET' ) ; // api must have atleast one method.
66
93
67
94
// WHEN
@@ -83,7 +110,11 @@ describe('api key', () => {
83
110
// GIVEN
84
111
const stack = new cdk . Stack ( ) ;
85
112
const user = new iam . User ( stack , 'User' ) ;
86
- const api = new apigateway . RestApi ( stack , 'test-api' , { cloudWatchRole : false , deploy : true , deployOptions : { stageName : 'test' } } ) ;
113
+ const api = new apigateway . RestApi ( stack , 'test-api' , {
114
+ cloudWatchRole : false ,
115
+ deploy : true ,
116
+ deployOptions : { stageName : 'test' } ,
117
+ } ) ;
87
118
api . root . addMethod ( 'GET' ) ; // api must have atleast one method.
88
119
89
120
// WHEN
@@ -130,7 +161,11 @@ describe('api key', () => {
130
161
// GIVEN
131
162
const stack = new cdk . Stack ( ) ;
132
163
const user = new iam . User ( stack , 'User' ) ;
133
- const api = new apigateway . RestApi ( stack , 'test-api' , { cloudWatchRole : false , deploy : true , deployOptions : { stageName : 'test' } } ) ;
164
+ const api = new apigateway . RestApi ( stack , 'test-api' , {
165
+ cloudWatchRole : false ,
166
+ deploy : true ,
167
+ deployOptions : { stageName : 'test' } ,
168
+ } ) ;
134
169
api . root . addMethod ( 'GET' ) ; // api must have atleast one method.
135
170
136
171
// WHEN
@@ -182,7 +217,11 @@ describe('api key', () => {
182
217
// GIVEN
183
218
const stack = new cdk . Stack ( ) ;
184
219
const user = new iam . User ( stack , 'User' ) ;
185
- const api = new apigateway . RestApi ( stack , 'test-api' , { cloudWatchRole : false , deploy : true , deployOptions : { stageName : 'test' } } ) ;
220
+ const api = new apigateway . RestApi ( stack , 'test-api' , {
221
+ cloudWatchRole : false ,
222
+ deploy : true ,
223
+ deployOptions : { stageName : 'test' } ,
224
+ } ) ;
186
225
api . root . addMethod ( 'GET' ) ; // api must have atleast one method.
187
226
188
227
// WHEN
@@ -253,7 +292,11 @@ describe('api key', () => {
253
292
test ( 'only api key is created when rate limiting properties are not provided' , ( ) => {
254
293
// GIVEN
255
294
const stack = new cdk . Stack ( ) ;
256
- const api = new apigateway . RestApi ( stack , 'test-api' , { cloudWatchRole : false , deploy : true , deployOptions : { stageName : 'test' } } ) ;
295
+ const api = new apigateway . RestApi ( stack , 'test-api' , {
296
+ cloudWatchRole : false ,
297
+ deploy : true ,
298
+ deployOptions : { stageName : 'test' } ,
299
+ } ) ;
257
300
api . root . addMethod ( 'GET' ) ; // api must have atleast one method.
258
301
259
302
// WHEN
@@ -281,7 +324,11 @@ describe('api key', () => {
281
324
test ( 'api key and usage plan are created and linked when rate limiting properties are provided' , ( ) => {
282
325
// GIVEN
283
326
const stack = new cdk . Stack ( ) ;
284
- const api = new apigateway . RestApi ( stack , 'test-api' , { cloudWatchRole : false , deploy : true , deployOptions : { stageName : 'test' } } ) ;
327
+ const api = new apigateway . RestApi ( stack , 'test-api' , {
328
+ cloudWatchRole : false ,
329
+ deploy : true ,
330
+ deployOptions : { stageName : 'test' } ,
331
+ } ) ;
285
332
api . root . addMethod ( 'GET' ) ; // api must have atleast one method.
286
333
287
334
// WHEN
0 commit comments