@mettlecast/domain-cdk-packer 0.2.90 → 0.2.92
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.
package/dist/DomainStack.js
CHANGED
|
@@ -124,7 +124,7 @@ export class DomainStack extends cdk.Stack {
|
|
|
124
124
|
const resolvedUserPoolId = userPoolId ?? cdk.Fn.select(1, cdk.Fn.split('/', userPoolArn));
|
|
125
125
|
jwtAuthorizer = new apigwv2.HttpAuthorizer(this, 'CognitoAuthorizer', {
|
|
126
126
|
httpApi: this.httpApi,
|
|
127
|
-
authorizerName:
|
|
127
|
+
authorizerName: `CognitoAuthorizer-${domainId}`,
|
|
128
128
|
type: apigwv2.HttpAuthorizerType.JWT,
|
|
129
129
|
identitySource: ['$request.header.Authorization'],
|
|
130
130
|
jwtAudience: [userPoolClientId],
|
|
@@ -69,17 +69,17 @@ describe('DomainStack', () => {
|
|
|
69
69
|
const eventBusArn = 'arn:aws:events:eu-north-1:123456789012:event-bus/tib-event-bus';
|
|
70
70
|
it('synthesises without error for minimal registry', () => {
|
|
71
71
|
const app = new cdk.App();
|
|
72
|
-
expect(() => new DomainStack(app, 'TestDomainStack', { registry: minimalRegistry, eventBusArn })).not.toThrow();
|
|
72
|
+
expect(() => new DomainStack(app, 'TestDomainStack', { registry: minimalRegistry, eventBusArn, projectId: 'Test', envCode: 'Dev' })).not.toThrow();
|
|
73
73
|
});
|
|
74
74
|
it('template contains HttpApi', () => {
|
|
75
75
|
const app = new cdk.App();
|
|
76
|
-
const stack = new DomainStack(app, 'TestDomainStack2', { registry: minimalRegistry, eventBusArn });
|
|
76
|
+
const stack = new DomainStack(app, 'TestDomainStack2', { registry: minimalRegistry, eventBusArn, projectId: 'Test', envCode: 'Dev' });
|
|
77
77
|
const template = Template.fromStack(stack);
|
|
78
78
|
template.resourceCountIs('AWS::ApiGatewayV2::Api', 1);
|
|
79
79
|
});
|
|
80
80
|
it('template contains one Lambda function for the api entry', () => {
|
|
81
81
|
const app = new cdk.App();
|
|
82
|
-
const stack = new DomainStack(app, 'TestDomainStack3', { registry: minimalRegistry, eventBusArn });
|
|
82
|
+
const stack = new DomainStack(app, 'TestDomainStack3', { registry: minimalRegistry, eventBusArn, projectId: 'Test', envCode: 'Dev' });
|
|
83
83
|
const template = Template.fromStack(stack);
|
|
84
84
|
template.resourceCountIs('AWS::Lambda::Function', 4);
|
|
85
85
|
});
|
|
@@ -90,6 +90,8 @@ describe('DomainStack', () => {
|
|
|
90
90
|
const stack = new DomainStack(app, 'TestDomainStackJwt', {
|
|
91
91
|
registry: minimalRegistry,
|
|
92
92
|
eventBusArn,
|
|
93
|
+
projectId: 'Test',
|
|
94
|
+
envCode: 'Dev',
|
|
93
95
|
userPoolArn,
|
|
94
96
|
userPoolClientId,
|
|
95
97
|
});
|
|
@@ -98,6 +100,21 @@ describe('DomainStack', () => {
|
|
|
98
100
|
AuthorizerType: 'JWT',
|
|
99
101
|
});
|
|
100
102
|
});
|
|
103
|
+
it('authorizer name is unique per-domain (includes domainId)', () => {
|
|
104
|
+
const app = new cdk.App();
|
|
105
|
+
const stack = new DomainStack(app, 'TestDomainStackName', {
|
|
106
|
+
registry: minimalRegistry,
|
|
107
|
+
eventBusArn,
|
|
108
|
+
projectId: 'Test',
|
|
109
|
+
envCode: 'Dev',
|
|
110
|
+
userPoolId: 'eu-north-1_test',
|
|
111
|
+
userPoolClientId: 'client-id',
|
|
112
|
+
});
|
|
113
|
+
const template = Template.fromStack(stack);
|
|
114
|
+
template.hasResourceProperties('AWS::ApiGatewayV2::Authorizer', {
|
|
115
|
+
Name: 'CognitoAuthorizer-test-domain',
|
|
116
|
+
});
|
|
117
|
+
});
|
|
101
118
|
it('no authorizer attached when no JWT-protected actions are declared', () => {
|
|
102
119
|
const app = new cdk.App();
|
|
103
120
|
const registryNoAuth = {
|
|
@@ -120,6 +137,8 @@ describe('DomainStack', () => {
|
|
|
120
137
|
const stack = new DomainStack(app, 'TestDomainStackNoAuth', {
|
|
121
138
|
registry: registryNoAuth,
|
|
122
139
|
eventBusArn,
|
|
140
|
+
projectId: 'Test',
|
|
141
|
+
envCode: 'Dev',
|
|
123
142
|
});
|
|
124
143
|
const template = Template.fromStack(stack);
|
|
125
144
|
template.resourceCountIs('AWS::ApiGatewayV2::Authorizer', 0);
|
|
@@ -130,6 +149,8 @@ describe('DomainStack', () => {
|
|
|
130
149
|
const stack = new DomainStack(app, 'TestDomainStackDbSecret', {
|
|
131
150
|
registry: minimalRegistry,
|
|
132
151
|
eventBusArn,
|
|
152
|
+
projectId: 'Test',
|
|
153
|
+
envCode: 'Dev',
|
|
133
154
|
dbSecretArn,
|
|
134
155
|
});
|
|
135
156
|
const template = Template.fromStack(stack);
|
|
@@ -143,6 +164,8 @@ describe('DomainStack', () => {
|
|
|
143
164
|
const stack = new DomainStack(app, 'TestDomainStackSecretGrant', {
|
|
144
165
|
registry: minimalRegistry,
|
|
145
166
|
eventBusArn,
|
|
167
|
+
projectId: 'Test',
|
|
168
|
+
envCode: 'Dev',
|
|
146
169
|
dbSecretArn,
|
|
147
170
|
});
|
|
148
171
|
const template = Template.fromStack(stack);
|
|
@@ -152,7 +175,7 @@ describe('DomainStack', () => {
|
|
|
152
175
|
});
|
|
153
176
|
describe('domain S3 bucket', () => {
|
|
154
177
|
const app = new cdk.App();
|
|
155
|
-
const stack = new DomainStack(app, 'TestDomainStackS3', { registry: minimalRegistry, eventBusArn });
|
|
178
|
+
const stack = new DomainStack(app, 'TestDomainStackS3', { registry: minimalRegistry, eventBusArn, projectId: 'Test', envCode: 'Dev' });
|
|
156
179
|
const template = Template.fromStack(stack);
|
|
157
180
|
it('creates exactly one S3 bucket', () => {
|
|
158
181
|
template.resourceCountIs('AWS::S3::Bucket', 1);
|
|
@@ -170,7 +193,7 @@ describe('DomainStack', () => {
|
|
|
170
193
|
});
|
|
171
194
|
describe('tenant-scoped IAM role (defence in depth)', () => {
|
|
172
195
|
const app = new cdk.App();
|
|
173
|
-
const stack = new DomainStack(app, 'TestDomainStackTenant', { registry: minimalRegistry, eventBusArn });
|
|
196
|
+
const stack = new DomainStack(app, 'TestDomainStackTenant', { registry: minimalRegistry, eventBusArn, projectId: 'Test', envCode: 'Dev' });
|
|
174
197
|
const template = Template.fromStack(stack);
|
|
175
198
|
it('creates a tenant-scoped IAM role', () => {
|
|
176
199
|
template.hasResourceProperties('AWS::IAM::Role', {
|
|
@@ -280,6 +303,8 @@ describe('DomainStack', () => {
|
|
|
280
303
|
const stack = new DomainStack(app, 'TestDomainStackMethods', {
|
|
281
304
|
registry: multiMethodRegistry,
|
|
282
305
|
eventBusArn,
|
|
306
|
+
projectId: 'Test',
|
|
307
|
+
envCode: 'Dev',
|
|
283
308
|
userPoolArn,
|
|
284
309
|
userPoolClientId,
|
|
285
310
|
});
|
|
@@ -302,6 +327,8 @@ describe('DomainStack', () => {
|
|
|
302
327
|
const stack = new DomainStack(app, 'TestDomainStackRouteAuth', {
|
|
303
328
|
registry: multiMethodRegistry,
|
|
304
329
|
eventBusArn,
|
|
330
|
+
projectId: 'Test',
|
|
331
|
+
envCode: 'Dev',
|
|
305
332
|
userPoolArn,
|
|
306
333
|
userPoolClientId,
|
|
307
334
|
});
|
|
@@ -325,6 +352,8 @@ describe('DomainStack', () => {
|
|
|
325
352
|
const stack = new DomainStack(app, 'TestDomainStackUnauthRoute', {
|
|
326
353
|
registry: multiMethodRegistry,
|
|
327
354
|
eventBusArn,
|
|
355
|
+
projectId: 'Test',
|
|
356
|
+
envCode: 'Dev',
|
|
328
357
|
userPoolArn,
|
|
329
358
|
userPoolClientId,
|
|
330
359
|
});
|
|
@@ -340,6 +369,8 @@ describe('DomainStack', () => {
|
|
|
340
369
|
const stack = new DomainStack(app, 'TestDomainStackMissingPool', {
|
|
341
370
|
registry: multiMethodRegistry,
|
|
342
371
|
eventBusArn,
|
|
372
|
+
projectId: 'Test',
|
|
373
|
+
envCode: 'Dev',
|
|
343
374
|
// No userPoolArn / userPoolId / userPoolClientId provided
|
|
344
375
|
});
|
|
345
376
|
// `Annotations.of(stack).errors` is not exposed; read the construct's
|
|
@@ -372,6 +403,8 @@ describe('DomainStack', () => {
|
|
|
372
403
|
const stack = new DomainStack(app, 'TestDomainStackNoJwtNeeded', {
|
|
373
404
|
registry: noJwtRegistry,
|
|
374
405
|
eventBusArn,
|
|
406
|
+
projectId: 'Test',
|
|
407
|
+
envCode: 'Dev',
|
|
375
408
|
});
|
|
376
409
|
const metadata = stack.node.metadata;
|
|
377
410
|
const errorMessages = metadata
|
|
@@ -445,6 +478,8 @@ describe('DomainStack', () => {
|
|
|
445
478
|
const stack = new DomainStack(app, 'TestDomainStackActionRoutes', {
|
|
446
479
|
registry: registryWithActions,
|
|
447
480
|
eventBusArn,
|
|
481
|
+
projectId: 'Test',
|
|
482
|
+
envCode: 'Dev',
|
|
448
483
|
userPoolArn: 'arn:aws:cognito-idp:eu-north-1:123456789012:userpool/eu-north-1_abc123xyz',
|
|
449
484
|
userPoolClientId: 'test-client-id',
|
|
450
485
|
});
|
|
@@ -459,6 +494,8 @@ describe('DomainStack', () => {
|
|
|
459
494
|
const stack = new DomainStack(app, 'TestDomainStackInternalOnly', {
|
|
460
495
|
registry: registryWithActions,
|
|
461
496
|
eventBusArn,
|
|
497
|
+
projectId: 'Test',
|
|
498
|
+
envCode: 'Dev',
|
|
462
499
|
userPoolArn: 'arn:aws:cognito-idp:eu-north-1:123456789012:userpool/eu-north-1_abc123xyz',
|
|
463
500
|
userPoolClientId: 'test-client-id',
|
|
464
501
|
});
|
|
@@ -472,6 +509,8 @@ describe('DomainStack', () => {
|
|
|
472
509
|
const stack = new DomainStack(app, 'TestDomainStackActionJwt', {
|
|
473
510
|
registry: registryWithActions,
|
|
474
511
|
eventBusArn,
|
|
512
|
+
projectId: 'Test',
|
|
513
|
+
envCode: 'Dev',
|
|
475
514
|
userPoolArn: 'arn:aws:cognito-idp:eu-north-1:123456789012:userpool/eu-north-1_abc123xyz',
|
|
476
515
|
userPoolClientId: 'test-client-id',
|
|
477
516
|
});
|