forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cloudfront): complete viewerCertificate support (aws#4579)
* feat(cloudfront): complete viewerCertificate support * chore: tslint errors * feat(certificatemanager): add getCertificateRegion method * chore: more tslint * chore(acm): export utils * chore(acm): add fromCertificateArn test * feat(cloudfront): throw cert not in us-east-1 * chore: remove eroneous import * chore: more tslint fixes * chore: fix integ test arn * chore: more integ test arn * chore: fix cert region * chore: refactor static X -> fromX * chore: refactor arrow into classic functions * chore: refactor fromCertificate apis * chore: viewer certificate docs * chore: fix README link
- Loading branch information
1 parent
3202720
commit 80b4ac9
Showing
12 changed files
with
674 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export * from './certificate'; | ||
export * from './dns-validated-certificate'; | ||
export * from './util'; | ||
|
||
// AWS::CertificateManager CloudFormation Resources: | ||
export * from './certificatemanager.generated'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 102 additions & 9 deletions
111
packages/@aws-cdk/aws-certificatemanager/test/test.util.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,108 @@ | ||
import { PublicHostedZone } from '@aws-cdk/aws-route53'; | ||
import { App, Stack } from '@aws-cdk/core'; | ||
import { Test } from 'nodeunit'; | ||
import { apexDomain } from '../lib/util'; | ||
import { Certificate, DnsValidatedCertificate } from '../lib'; | ||
import { apexDomain, getCertificateRegion, isDnsValidatedCertificate } from '../lib/util'; | ||
|
||
export = { | ||
'apex domain returns right domain'(test: Test) { | ||
test.equals('domain.com', apexDomain('domain.com')); | ||
test.equals('domain.com', apexDomain('test.domain.com')); | ||
test.done(); | ||
'apex domain': { | ||
'returns right domain'(test: Test) { | ||
test.equals('domain.com', apexDomain('domain.com')); | ||
test.equals('domain.com', apexDomain('test.domain.com')); | ||
test.done(); | ||
}, | ||
|
||
'understands eTLDs'(test: Test) { | ||
test.equals('domain.co.uk', apexDomain('test.domain.co.uk')); | ||
test.done(); | ||
}, | ||
}, | ||
'isDnsValidatedCertificate': { | ||
'new DnsValidatedCertificate is a DnsValidatedCertificate'(test: Test) { | ||
const stack = new Stack(); | ||
|
||
const hostedZone = new PublicHostedZone(stack, 'ExampleDotCom', { | ||
zoneName: 'example.com' | ||
}); | ||
const cert = new DnsValidatedCertificate(stack, 'Certificate', { | ||
domainName: 'test.example.com', | ||
hostedZone | ||
}); | ||
|
||
test.ok(isDnsValidatedCertificate(cert)); | ||
test.done(); | ||
}, | ||
'new Certificate is not a DnsValidatedCertificate'(test: Test) { | ||
const stack = new Stack(); | ||
|
||
const cert = new Certificate(stack, 'Certificate', { | ||
domainName: 'test.example.com' | ||
}); | ||
|
||
test.ok(!isDnsValidatedCertificate(cert)); | ||
test.done(); | ||
}, | ||
'fromCertificateArn is not a DnsValidatedCertificate'(test: Test) { | ||
const stack = new Stack(); | ||
|
||
const cert = Certificate.fromCertificateArn(stack, 'Certificate', 'cert-arn'); | ||
|
||
test.ok(!isDnsValidatedCertificate(cert)); | ||
test.done(); | ||
}, | ||
}, | ||
'getCertificateRegion': { | ||
'from stack'(test: Test) { | ||
// GIVEN | ||
const app = new App(); | ||
const stack = new Stack(app, 'RegionStack', {env: {region: 'eu-west-1'}}); | ||
|
||
'apex domain understands eTLDs'(test: Test) { | ||
test.equals('domain.co.uk', apexDomain('test.domain.co.uk')); | ||
test.done(); | ||
} | ||
const certificate = new Certificate(stack, 'TestCertificate', { | ||
domainName: 'www.example.com', | ||
}); | ||
|
||
test.equals(getCertificateRegion(certificate), 'eu-west-1'); | ||
test.done(); | ||
}, | ||
'from DnsValidatedCertificate region'(test: Test) { | ||
// GIVEN | ||
const app = new App(); | ||
const stack = new Stack(app, 'RegionStack', {env: {region: 'eu-west-1'}}); | ||
const hostedZone = new PublicHostedZone(stack, 'ExampleDotCom', { | ||
zoneName: 'example.com' | ||
}); | ||
|
||
const certificate = new DnsValidatedCertificate(stack, 'TestCertificate', { | ||
domainName: 'www.example.com', | ||
hostedZone, | ||
region: 'eu-west-3' | ||
}); | ||
|
||
test.equals(getCertificateRegion(certificate), 'eu-west-3'); | ||
test.done(); | ||
}, | ||
'fromCertificateArn'(test: Test) { | ||
// GIVEN | ||
const app = new App(); | ||
const stack = new Stack(app, 'RegionStack', {env: {region: 'eu-west-1'}}); | ||
|
||
const certificate = Certificate.fromCertificateArn( | ||
stack, 'TestCertificate', 'arn:aws:acm:us-east-2:1111111:certificate/11-3336f1-44483d-adc7-9cd375c5169d' | ||
); | ||
|
||
test.equals(getCertificateRegion(certificate), 'us-east-2'); | ||
test.done(); | ||
}, | ||
'region agnostic stack'(test: Test) { | ||
// GIVEN | ||
const stack = new Stack(); | ||
|
||
const certificate = new Certificate(stack, 'TestCertificate', { | ||
domainName: 'www.example.com', | ||
}); | ||
|
||
test.equals(getCertificateRegion(certificate), '${Token[AWS::Region.4]}'); | ||
test.done(); | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.