-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f15e07
commit 0cf1835
Showing
4 changed files
with
4,674 additions
and
0 deletions.
There are no files selected for viewing
149 changes: 149 additions & 0 deletions
149
__tests__/__snapshots__/origin-with-custom-headers.test.js.snap
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 |
---|---|---|
@@ -0,0 +1,149 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Input origin with custom header creates distribution with custom url origin 1`] = ` | ||
Object { | ||
"DistributionConfig": Object { | ||
"Aliases": Object { | ||
"Items": Array [], | ||
"Quantity": 0, | ||
}, | ||
"CacheBehaviors": Object { | ||
"Items": Array [ | ||
Object { | ||
"AllowedMethods": Object { | ||
"CachedMethods": Object { | ||
"Items": Array [ | ||
"GET", | ||
"HEAD", | ||
], | ||
"Quantity": 2, | ||
}, | ||
"Items": Array [ | ||
"GET", | ||
"HEAD", | ||
"POST", | ||
], | ||
"Quantity": 3, | ||
}, | ||
"Compress": true, | ||
"DefaultTTL": 10, | ||
"FieldLevelEncryptionId": "", | ||
"ForwardedValues": Object { | ||
"Cookies": Object { | ||
"Forward": "all", | ||
}, | ||
"Headers": Object { | ||
"Items": Array [], | ||
"Quantity": 0, | ||
}, | ||
"QueryString": true, | ||
"QueryStringCacheKeys": Object { | ||
"Items": Array [], | ||
"Quantity": 0, | ||
}, | ||
}, | ||
"LambdaFunctionAssociations": Object { | ||
"Items": Array [], | ||
"Quantity": 0, | ||
}, | ||
"MaxTTL": 10, | ||
"MinTTL": 10, | ||
"PathPattern": "/some/path", | ||
"SmoothStreaming": false, | ||
"TargetOriginId": "exampleorigin.com", | ||
"TrustedSigners": Object { | ||
"Enabled": false, | ||
"Quantity": 0, | ||
}, | ||
"ViewerProtocolPolicy": "https-only", | ||
}, | ||
], | ||
"Quantity": 1, | ||
}, | ||
"CallerReference": "1566599541192", | ||
"Comment": "", | ||
"DefaultCacheBehavior": Object { | ||
"AllowedMethods": Object { | ||
"CachedMethods": Object { | ||
"Items": Array [ | ||
"HEAD", | ||
"GET", | ||
], | ||
"Quantity": 2, | ||
}, | ||
"Items": Array [ | ||
"HEAD", | ||
"GET", | ||
], | ||
"Quantity": 2, | ||
}, | ||
"Compress": false, | ||
"DefaultTTL": 86400, | ||
"FieldLevelEncryptionId": "", | ||
"ForwardedValues": Object { | ||
"Cookies": Object { | ||
"Forward": "none", | ||
}, | ||
"Headers": Object { | ||
"Items": Array [], | ||
"Quantity": 0, | ||
}, | ||
"QueryString": false, | ||
"QueryStringCacheKeys": Object { | ||
"Items": Array [], | ||
"Quantity": 0, | ||
}, | ||
}, | ||
"LambdaFunctionAssociations": Object { | ||
"Items": Array [], | ||
"Quantity": 0, | ||
}, | ||
"MaxTTL": 31536000, | ||
"MinTTL": 0, | ||
"SmoothStreaming": false, | ||
"TargetOriginId": "exampleorigin.com", | ||
"TrustedSigners": Object { | ||
"Enabled": false, | ||
"Items": Array [], | ||
"Quantity": 0, | ||
}, | ||
"ViewerProtocolPolicy": "redirect-to-https", | ||
}, | ||
"Enabled": true, | ||
"HttpVersion": "http2", | ||
"Origins": Object { | ||
"Items": Array [ | ||
Object { | ||
"CustomHeaders": Object { | ||
"Items": Array [ | ||
Object { | ||
"HeaderName": "x-api-key", | ||
"HeaderValue": "test", | ||
}, | ||
], | ||
"Quantity": 1, | ||
}, | ||
"CustomOriginConfig": Object { | ||
"HTTPPort": 80, | ||
"HTTPSPort": 443, | ||
"OriginKeepaliveTimeout": 5, | ||
"OriginProtocolPolicy": "https-only", | ||
"OriginReadTimeout": 30, | ||
"OriginSslProtocols": Object { | ||
"Items": Array [ | ||
"TLSv1.2", | ||
], | ||
"Quantity": 1, | ||
}, | ||
}, | ||
"DomainName": "exampleorigin.com", | ||
"Id": "exampleorigin.com", | ||
"OriginPath": "", | ||
}, | ||
], | ||
"Quantity": 1, | ||
}, | ||
"PriceClass": "PriceClass_All", | ||
}, | ||
} | ||
`; |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const { createComponent, assertHasCacheBehavior, assertHasOrigin } = require('../test-utils') | ||
const { mockCreateDistribution, mockCreateDistributionPromise } = require('aws-sdk') | ||
|
||
describe('Input origin with custom header', () => { | ||
let component | ||
|
||
beforeEach(async () => { | ||
mockCreateDistributionPromise.mockResolvedValueOnce({ | ||
Distribution: { | ||
Id: 'xyz' | ||
} | ||
}) | ||
|
||
component = await createComponent() | ||
}) | ||
|
||
it('creates distribution with custom url origin', async () => { | ||
await component.default({ | ||
origins: [ | ||
{ | ||
url: 'https://exampleorigin.com', | ||
pathPatterns: { | ||
'/some/path': { | ||
ttl: 10, | ||
allowedHttpMethods: ['GET', 'HEAD', 'POST'] | ||
} | ||
}, | ||
headers: { | ||
'x-api-key': 'test' | ||
} | ||
} | ||
] | ||
}) | ||
|
||
assertHasOrigin(mockCreateDistribution, { | ||
Id: 'exampleorigin.com', | ||
DomainName: 'exampleorigin.com', | ||
CustomHeaders: { | ||
Quantity: 1, | ||
Items: [{ HeaderName: 'x-api-key', HeaderValue: 'test' }] | ||
} | ||
}) | ||
|
||
assertHasCacheBehavior(mockCreateDistribution, { | ||
PathPattern: '/some/path', | ||
MinTTL: 10, | ||
TargetOriginId: 'exampleorigin.com' | ||
}) | ||
|
||
expect(mockCreateDistribution.mock.calls[0][0]).toMatchSnapshot() | ||
}) | ||
}) |
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.