Skip to content

Commit

Permalink
Add unit test ensuring ViewerProtocolPolicy is properly set
Browse files Browse the repository at this point in the history
  • Loading branch information
skorfmann committed Mar 4, 2019
1 parent be01097 commit 411c450
Showing 1 changed file with 77 additions and 1 deletion.
78 changes: 77 additions & 1 deletion packages/@aws-cdk/aws-cloudfront/test/test.basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from '@aws-cdk/assert';
import s3 = require('@aws-cdk/aws-s3');
import cdk = require('@aws-cdk/cdk');
import { Test } from 'nodeunit';
import { CloudFrontWebDistribution } from '../lib';
import { CloudFrontWebDistribution, ViewerProtocolPolicy } from '../lib';

// tslint:disable:object-literal-key-quotes

Expand Down Expand Up @@ -246,4 +246,80 @@ export = {
});
test.done();
},

'distribution with ViewerProtocolPolicy set to a non-default value'(test: Test) {
const stack = new cdk.Stack();
const sourceBucket = new s3.Bucket(stack, 'Bucket');

new CloudFrontWebDistribution(stack, 'AnAmazingWebsiteProbably', {
viewerProtocolPolicy: ViewerProtocolPolicy.AllowAll,
originConfigs: [
{
s3OriginSource: {
s3BucketSource: sourceBucket
},
behaviors: [
{
isDefaultBehavior: true,
}
]
}
]
});

expect(stack).toMatch({
"Resources": {
"Bucket83908E77": {
"Type": "AWS::S3::Bucket",
"DeletionPolicy": "Retain",
},
"AnAmazingWebsiteProbablyCFDistribution47E3983B": {
"Type": "AWS::CloudFront::Distribution",
"Properties": {
"DistributionConfig": {
"DefaultRootObject": "index.html",
"Origins": [
{
"DomainName": {
"Fn::GetAtt": [
"Bucket83908E77",
"DomainName"
]
},
"Id": "origin1",
"S3OriginConfig": {}
}
],
"ViewerCertificate": {
"CloudFrontDefaultCertificate": true
},
"PriceClass": "PriceClass_100",
"DefaultCacheBehavior": {
"AllowedMethods": [
"GET",
"HEAD"
],
"CachedMethods": [
"GET",
"HEAD"
],
"TargetOriginId": "origin1",
"ViewerProtocolPolicy": "allow-all",
"ForwardedValues": {
"QueryString": false,
"Cookies": { "Forward": "none" }
}
},
"Enabled": true,
"IPV6Enabled": true,
"HttpVersion": "http2",
"CacheBehaviors": []
}
}
}
}
});
test.done();
},

};

0 comments on commit 411c450

Please sign in to comment.