Skip to content

Commit

Permalink
test: ensure zone is resolved correctly when using no /hostedzone prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexZeitler committed Nov 29, 2019
1 parent c8f39b4 commit 667f65f
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions packages/@aws-cdk/aws-route53/test/test.hosted-zone-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,44 @@ export = {
test.deepEqual(zoneRef.hostedZoneId, cdkZone.hostedZoneId);
test.done();
},
'HostedZoneProvider will return context values if availble when using plain hosted zone id'(test: Test) {
// GIVEN
const stack = new cdk.Stack(undefined, 'TestStack', { env: { account: '12345', region: 'us-east-1' } });
const filter = {domainName: 'test.com'};

HostedZone.fromLookup(stack, 'Ref', filter);

const missing = SynthUtils.synthesize(stack).assembly.manifest.missing!;
test.ok(missing && missing.length === 1);

const fakeZoneId = '11111111111111';
const fakeZone = {
Id: fakeZoneId,
Name: "example.com.",
CallerReference: "TestLates-PublicZo-OESZPDFV7G6A",
Config: {
Comment: "CDK created",
PrivateZone: false
},
ResourceRecordSetCount: 3
};

const stack2 = new cdk.Stack(undefined, 'TestStack', { env: { account: '12345', region: 'us-east-1' } });
stack2.node.setContext(missing[0].key, fakeZone);

const cdkZoneProps: HostedZoneAttributes = {
hostedZoneId: fakeZone.Id,
zoneName: 'example.com',
};

const cdkZone = HostedZone.fromHostedZoneAttributes(stack2, 'MyZone', cdkZoneProps);

// WHEN
const zoneId = cdkZone.hostedZoneId;

// THEN
test.deepEqual(fakeZoneId, zoneId);
test.done();
},
}
};

0 comments on commit 667f65f

Please sign in to comment.