|
1 | 1 | // tslint:disable:object-literal-key-quotes
|
2 |
| -import { expect, haveResource } from '@aws-cdk/assert'; |
| 2 | +import { ABSENT, expect, haveResource } from '@aws-cdk/assert'; |
3 | 3 | import * as acm from '@aws-cdk/aws-certificatemanager';
|
4 | 4 | import { Stack } from '@aws-cdk/core';
|
5 | 5 | import { Test } from 'nodeunit';
|
@@ -65,6 +65,53 @@ export = {
|
65 | 65 | test.done();
|
66 | 66 | },
|
67 | 67 |
|
| 68 | + 'accepts different security policies'(test: Test) { |
| 69 | + // GIVEN |
| 70 | + const stack = new Stack(); |
| 71 | + const cert = new acm.Certificate(stack, 'Cert', { domainName: 'example.com' }); |
| 72 | + |
| 73 | + // WHEN |
| 74 | + new apigw.DomainName(stack, 'my-domain', { |
| 75 | + domainName: 'old.example.com', |
| 76 | + certificate: cert, |
| 77 | + securityPolicy: apigw.SecurityPolicy.TLS_1_0 |
| 78 | + }); |
| 79 | + |
| 80 | + new apigw.DomainName(stack, 'your-domain', { |
| 81 | + domainName: 'new.example.com', |
| 82 | + certificate: cert, |
| 83 | + securityPolicy: apigw.SecurityPolicy.TLS_1_2 |
| 84 | + }); |
| 85 | + |
| 86 | + new apigw.DomainName(stack, 'default-domain', { |
| 87 | + domainName: 'default.example.com', |
| 88 | + certificate: cert |
| 89 | + }); |
| 90 | + |
| 91 | + // THEN |
| 92 | + expect(stack).to(haveResource('AWS::ApiGateway::DomainName', { |
| 93 | + "DomainName": "old.example.com", |
| 94 | + "EndpointConfiguration": { "Types": [ "REGIONAL" ] }, |
| 95 | + "RegionalCertificateArn": { "Ref": "Cert5C9FAEC1" }, |
| 96 | + "SecurityPolicy": "TLS_1_0" |
| 97 | + })); |
| 98 | + |
| 99 | + expect(stack).to(haveResource('AWS::ApiGateway::DomainName', { |
| 100 | + "DomainName": "new.example.com", |
| 101 | + "EndpointConfiguration": { "Types": [ "REGIONAL" ] }, |
| 102 | + "RegionalCertificateArn": { "Ref": "Cert5C9FAEC1" }, |
| 103 | + "SecurityPolicy": "TLS_1_2" |
| 104 | + })); |
| 105 | + |
| 106 | + expect(stack).to(haveResource('AWS::ApiGateway::DomainName', { |
| 107 | + "DomainName": "default.example.com", |
| 108 | + "EndpointConfiguration": { "Types": [ "REGIONAL" ] }, |
| 109 | + "RegionalCertificateArn": { "Ref": "Cert5C9FAEC1" }, |
| 110 | + "SecurityPolicy": ABSENT |
| 111 | + })); |
| 112 | + test.done(); |
| 113 | + }, |
| 114 | + |
68 | 115 | '"mapping" can be used to automatically map this domain to the deployment stage of an API'(test: Test) {
|
69 | 116 | // GIVEN
|
70 | 117 | const stack = new Stack();
|
|
0 commit comments