From 424cfe375141ffccf0336876a31b82df1578e26d Mon Sep 17 00:00:00 2001 From: spg Date: Fri, 8 Mar 2019 21:58:50 -0800 Subject: [PATCH 1/4] fix(acm) Export dns-validated-certificate --- packages/@aws-cdk/aws-certificatemanager/lib/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/@aws-cdk/aws-certificatemanager/lib/index.ts b/packages/@aws-cdk/aws-certificatemanager/lib/index.ts index 50873fe8ee56f..85e821e42fbb6 100644 --- a/packages/@aws-cdk/aws-certificatemanager/lib/index.ts +++ b/packages/@aws-cdk/aws-certificatemanager/lib/index.ts @@ -1,4 +1,5 @@ export * from './certificate'; +export * from './dns-validated-certificate'; // AWS::CertificateManager CloudFormation Resources: export * from './certificatemanager.generated'; From e89632f0bbb7579b58f47bcfcc5bc56dbb548e5b Mon Sep 17 00:00:00 2001 From: spg Date: Mon, 11 Mar 2019 20:55:13 -0700 Subject: [PATCH 2/4] Rename --- packages/@aws-cdk/aws-certificatemanager/README.md | 4 ++-- .../lib/dns-validated-certificate.ts | 6 +++--- .../test/test.dns-validated-certificate.ts | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/@aws-cdk/aws-certificatemanager/README.md b/packages/@aws-cdk/aws-certificatemanager/README.md index bbb16d5b5064c..69889eb494533 100644 --- a/packages/@aws-cdk/aws-certificatemanager/README.md +++ b/packages/@aws-cdk/aws-certificatemanager/README.md @@ -17,14 +17,14 @@ zone `example.com` that provides authoritative records for the domain. ```ts import { HostedZoneProvider } from '@aws-cdk/aws-route53'; -import { DNSValidatedCertificate } from '@aws-cdk/aws-certificatemanager'; +import { DnsValidatedCertificate } from '@aws-cdk/aws-certificatemanager'; const hostedZone = new HostedZoneProvider(this, { domainName: 'example.com', privateZone: false }).findAndImport(this, 'ExampleDotCom'); -const certificate = new DNSValidatedCertificate(this, 'TestCertificate', { +const certificate = new DnsValidatedCertificate(this, 'TestCertificate', { domainName: 'test.example.com', hostedZone: hostedZone }); diff --git a/packages/@aws-cdk/aws-certificatemanager/lib/dns-validated-certificate.ts b/packages/@aws-cdk/aws-certificatemanager/lib/dns-validated-certificate.ts index 18d3e7d34d9ea..85b10c5d04acd 100644 --- a/packages/@aws-cdk/aws-certificatemanager/lib/dns-validated-certificate.ts +++ b/packages/@aws-cdk/aws-certificatemanager/lib/dns-validated-certificate.ts @@ -6,7 +6,7 @@ import cdk = require('@aws-cdk/cdk'); import path = require('path'); import { CertificateImportProps, CertificateProps, ICertificate } from './certificate'; -export interface DNSValidatedCertificateProps extends CertificateProps { +export interface DnsValidatedCertificateProps extends CertificateProps { /** * Route 53 Hosted Zone used to perform DNS validation of the request. The zone * must be authoritative for the domain name specified in the Certificate Request. @@ -18,13 +18,13 @@ export interface DNSValidatedCertificateProps extends CertificateProps { * A certificate managed by AWS Certificate Manager. Will be automatically * validated using DNS validation against the specified Route 53 hosted zone. */ -export class DNSValidatedCertificate extends cdk.Construct implements ICertificate { +export class DnsValidatedCertificate extends cdk.Construct implements ICertificate { public readonly certificateArn: string; private normalizedZoneName: string; private hostedZoneId: string; private domainName: string; - constructor(scope: cdk.Construct, id: string, props: DNSValidatedCertificateProps) { + constructor(scope: cdk.Construct, id: string, props: DnsValidatedCertificateProps) { super(scope, id); this.domainName = props.domainName; diff --git a/packages/@aws-cdk/aws-certificatemanager/test/test.dns-validated-certificate.ts b/packages/@aws-cdk/aws-certificatemanager/test/test.dns-validated-certificate.ts index 0c66841ecf0cd..aef0e680b6dd5 100644 --- a/packages/@aws-cdk/aws-certificatemanager/test/test.dns-validated-certificate.ts +++ b/packages/@aws-cdk/aws-certificatemanager/test/test.dns-validated-certificate.ts @@ -2,7 +2,7 @@ import { expect, haveResource } from '@aws-cdk/assert'; import { PublicHostedZone } from '@aws-cdk/aws-route53'; import { Stack } from '@aws-cdk/cdk'; import { Test } from 'nodeunit'; -import { DNSValidatedCertificate } from '../lib/dns-validated-certificate'; +import { DnsValidatedCertificate } from '../lib/dns-validated-certificate'; export = { 'creates CloudFormation Custom Resource'(test: Test) { @@ -12,7 +12,7 @@ export = { zoneName: 'example.com' }); - const cert = new DNSValidatedCertificate(stack, 'Certificate', { + const cert = new DnsValidatedCertificate(stack, 'Certificate', { domainName: 'test.example.com', hostedZone: exampleDotComZone, }); @@ -90,7 +90,7 @@ export = { zoneName: 'hello.com' }); - const refProps = new DNSValidatedCertificate(stack, 'Cert', { + const refProps = new DnsValidatedCertificate(stack, 'Cert', { domainName: 'hello.com', hostedZone: helloDotComZone, }).export(); @@ -106,7 +106,7 @@ export = { zoneName: 'hello.com' }); - const cert = new DNSValidatedCertificate(stack, 'Cert', { + const cert = new DnsValidatedCertificate(stack, 'Cert', { domainName: 'example.com', hostedZone: helloDotComZone, }); From df88e05f2ce55ec97f8a0553a03e310e22416d59 Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Tue, 12 Mar 2019 09:46:31 +0200 Subject: [PATCH 3/4] Change "validate" to protected --- .../aws-certificatemanager/lib/dns-validated-certificate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-certificatemanager/lib/dns-validated-certificate.ts b/packages/@aws-cdk/aws-certificatemanager/lib/dns-validated-certificate.ts index 85b10c5d04acd..2c7d234849f78 100644 --- a/packages/@aws-cdk/aws-certificatemanager/lib/dns-validated-certificate.ts +++ b/packages/@aws-cdk/aws-certificatemanager/lib/dns-validated-certificate.ts @@ -80,7 +80,7 @@ export class DnsValidatedCertificate extends cdk.Construct implements ICertifica }; } - public validate(): string[] { + protected validate(): string[] { const errors: string[] = []; // Ensure the zone name is a parent zone of the certificate domain name if (!this.domainName.endsWith('.' + this.normalizedZoneName)) { From 46f2a5f557e18e9a03e03aac88ca96e562aca348 Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Tue, 12 Mar 2019 10:46:20 +0200 Subject: [PATCH 4/4] fix validation tests --- .../test/test.dns-validated-certificate.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/@aws-cdk/aws-certificatemanager/test/test.dns-validated-certificate.ts b/packages/@aws-cdk/aws-certificatemanager/test/test.dns-validated-certificate.ts index aef0e680b6dd5..7920e0d41b9e9 100644 --- a/packages/@aws-cdk/aws-certificatemanager/test/test.dns-validated-certificate.ts +++ b/packages/@aws-cdk/aws-certificatemanager/test/test.dns-validated-certificate.ts @@ -12,7 +12,7 @@ export = { zoneName: 'example.com' }); - const cert = new DnsValidatedCertificate(stack, 'Certificate', { + new DnsValidatedCertificate(stack, 'Certificate', { domainName: 'test.example.com', hostedZone: exampleDotComZone, }); @@ -77,9 +77,6 @@ export = { } })); - const errors = cert.validate(); - test.equal(errors.length, 0); - test.done(); }, @@ -106,14 +103,13 @@ export = { zoneName: 'hello.com' }); - const cert = new DnsValidatedCertificate(stack, 'Cert', { + new DnsValidatedCertificate(stack, 'Cert', { domainName: 'example.com', hostedZone: helloDotComZone, }); - const errors = cert.validate(); - test.equal(errors.length, 1); - + // a bit of a hack: expect(stack) will trigger validation. + test.throws(() => expect(stack), /DNS zone hello.com is not authoritative for certificate domain name example.com/); test.done(); }, };