-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
test.integration.ts
58 lines (53 loc) · 1.82 KB
/
test.integration.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import * as ec2 from '@aws-cdk/aws-ec2';
import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2';
import * as iam from '@aws-cdk/aws-iam';
import * as cdk from '@aws-cdk/core';
import { Test } from 'nodeunit';
import * as apigw from '../lib';
export = {
'integration "credentialsRole" and "credentialsPassthrough" are mutually exclusive'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const role = new iam.Role(stack, 'MyRole', { assumedBy: new iam.ServicePrincipal('foo') });
// THEN
test.throws(() => new apigw.Integration({
type: apigw.IntegrationType.AWS_PROXY,
options: {
credentialsPassthrough: true,
credentialsRole: role,
},
}), /'credentialsPassthrough' and 'credentialsRole' are mutually exclusive/);
test.done();
},
'integration connectionType VpcLink requires vpcLink to be set'(test: Test) {
test.throws(() => new apigw.Integration({
type: apigw.IntegrationType.HTTP_PROXY,
integrationHttpMethod: 'ANY',
options: {
connectionType: apigw.ConnectionType.VPC_LINK,
},
}), /'connectionType' of VPC_LINK requires 'vpcLink' prop to be set/);
test.done();
},
'connectionType of INTERNET and vpcLink are mutually exclusive'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.Vpc(stack, 'VPC');
const nlb = new elbv2.NetworkLoadBalancer(stack, 'NLB', {
vpc,
});
const link = new apigw.VpcLink(stack, 'link', {
targets: [nlb],
});
// THEN
test.throws(() => new apigw.Integration({
type: apigw.IntegrationType.HTTP_PROXY,
integrationHttpMethod: 'ANY',
options: {
connectionType: apigw.ConnectionType.INTERNET,
vpcLink: link,
},
}), /cannot set 'vpcLink' where 'connectionType' is INTERNET/);
test.done();
},
};