From ab75100ca1d22e8eaeaf6c68b140ee534506cb9f Mon Sep 17 00:00:00 2001 From: mickychetta Date: Mon, 10 Jan 2022 21:11:32 +0000 Subject: [PATCH] changed error message and integ test --- .../aws-route53-apigateway/lib/index.ts | 9 +++------ .../test/test.route53-apigateway.test.ts | 14 +++++++------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/source/patterns/@aws-solutions-constructs/aws-route53-apigateway/lib/index.ts b/source/patterns/@aws-solutions-constructs/aws-route53-apigateway/lib/index.ts index f2f4dfce7..cdeaedb41 100755 --- a/source/patterns/@aws-solutions-constructs/aws-route53-apigateway/lib/index.ts +++ b/source/patterns/@aws-solutions-constructs/aws-route53-apigateway/lib/index.ts @@ -88,9 +88,6 @@ export class Route53ToApiGateway extends Construct { super(scope, id); defaults.CheckProps(props); - // Certificate must already be issued when the user is bringing an existing one - // If you are using privateHostedZoneProps, the certificate must already be issued - // from a previous domain in order to be used in the newly created Private Hosted Zone. this.certificate = props.existingCertificateInterface; if (props.existingVpc) { @@ -105,14 +102,14 @@ export class Route53ToApiGateway extends Construct { throw new Error('Cannot provide an existing VPC to an existing Private Hosted Zone.'); } if (props.privateHostedZoneProps) { - throw new Error('Must provide either existingHostedZoneInterface or privateHostedZoneProps.'); + throw new Error('Must provide either existingHostedZoneInterface or privateHostedZoneProps, but not both.'); } } else { // Creating a Private Hosted Zone if (props.publicApi) { throw new Error('Public APIs require an existingHostedZone be passed in the Props object.'); } else { if (!props.privateHostedZoneProps) { - throw new Error('Must supply privateHostedZoneProps to create a private API.'); + throw new Error('Must provide either existingHostedZoneInterface or privateHostedZoneProps.'); } if (props.privateHostedZoneProps.vpc) { throw new Error('All VPC specs must be provided at the Construct level in Route53ToApiGatewayProps.'); @@ -121,7 +118,7 @@ export class Route53ToApiGateway extends Construct { throw new Error('Must supply zoneName for Private Hosted Zone Props.'); } if ( !this.vpc ) { - throw new Error('Must supply an existing VPC for Private Hosted Zone Props.'); + throw new Error('Must specify an existingVPC for the Private Hosted Zone in the construct props.'); } const manufacturedProps: route53.PrivateHostedZoneProps = defaults.overrideProps(props.privateHostedZoneProps, { vpc: this.vpc }); this.hostedZone = new route53.PrivateHostedZone(this, `${id}-zone`, manufacturedProps); diff --git a/source/patterns/@aws-solutions-constructs/aws-route53-apigateway/test/test.route53-apigateway.test.ts b/source/patterns/@aws-solutions-constructs/aws-route53-apigateway/test/test.route53-apigateway.test.ts index 5f0b321fa..7e5c40680 100755 --- a/source/patterns/@aws-solutions-constructs/aws-route53-apigateway/test/test.route53-apigateway.test.ts +++ b/source/patterns/@aws-solutions-constructs/aws-route53-apigateway/test/test.route53-apigateway.test.ts @@ -132,7 +132,7 @@ test("Test for errors when creating a private hosted zone", () => { // Assertion 2 expect(app).toThrowError( - "Must supply privateHostedZoneProps to create a private API" + "Must provide either existingHostedZoneInterface or privateHostedZoneProps." ); app = () => @@ -178,7 +178,7 @@ test("Test for errors when creating a private hosted zone", () => { // Assertion 5 expect(app).toThrowError( - "Must provide either existingHostedZoneInterface or privateHostedZoneProps." + "Must provide either existingHostedZoneInterface or privateHostedZoneProps, but not both." ); app = () => @@ -191,7 +191,7 @@ test("Test for errors when creating a private hosted zone", () => { existingCertificateInterface: certificate }); - // Assertion 7 + // Assertion 6 expect(app).toThrowError( 'Must supply zoneName for Private Hosted Zone Props.' ); @@ -206,9 +206,9 @@ test("Test for errors when creating a private hosted zone", () => { existingCertificateInterface: certificate }); - // Assertion 6 + // Assertion 7 expect(app).toThrowError( - 'Must supply an existing VPC for Private Hosted Zone Props.' + 'Must specify an existingVPC for the Private Hosted Zone in the construct props.' ); }); @@ -272,7 +272,7 @@ test("Integration test for A record creation in Public Hosted Zone ", () => { deployApi(stack, true); // Assertions - expect(stack).toHaveResourceLike("AWS::Route53::RecordSet", { + expect(stack).toHaveResource("AWS::Route53::RecordSet", { Name: "www.test-example.com.", Type: "A", AliasTarget: { @@ -313,7 +313,7 @@ test("Integration test for A record creation in Private Hosted Zone ", () => { deployApi(stack, false); // Assertions - expect(stack).toHaveResourceLike("AWS::Route53::RecordSet", { + expect(stack).toHaveResource("AWS::Route53::RecordSet", { Name: "www.test-example.com.", Type: "A", AliasTarget: {