-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into cr-role-arn
- Loading branch information
Showing
183 changed files
with
30,554 additions
and
1,915 deletions.
There are no files selected for viewing
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
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
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
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
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
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
107 changes: 107 additions & 0 deletions
107
packages/@aws-cdk/aws-apigateway/test/base-path-mapping.test.ts
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,107 @@ | ||
import '@aws-cdk/assert/jest'; | ||
import * as acm from '@aws-cdk/aws-certificatemanager'; | ||
import * as cdk from '@aws-cdk/core'; | ||
import * as apigw from '../lib'; | ||
|
||
describe('BasePathMapping', () => { | ||
test('default setup', () => { | ||
// GIVEN | ||
const stack = new cdk.Stack(); | ||
const api = new apigw.RestApi(stack, 'MyApi'); | ||
api.root.addMethod('GET'); // api must have atleast one method. | ||
const domain = new apigw.DomainName(stack, 'MyDomain', { | ||
domainName: 'example.com', | ||
certificate: acm.Certificate.fromCertificateArn(stack, 'cert', 'arn:aws:acm:us-east-1:1111111:certificate/11-3336f1-44483d-adc7-9cd375c5169d'), | ||
endpointType: apigw.EndpointType.REGIONAL, | ||
}); | ||
|
||
// WHEN | ||
new apigw.BasePathMapping(stack, 'MyBasePath', { | ||
restApi: api, | ||
domainName: domain, | ||
}); | ||
|
||
// THEN | ||
expect(stack).toHaveResource('AWS::ApiGateway::BasePathMapping', { | ||
DomainName: { Ref: 'MyDomainE4943FBC' }, | ||
RestApiId: { Ref: 'MyApi49610EDF' }, | ||
}); | ||
}); | ||
|
||
test('specify basePath property', () => { | ||
// GIVEN | ||
const stack = new cdk.Stack(); | ||
const api = new apigw.RestApi(stack, 'MyApi'); | ||
api.root.addMethod('GET'); // api must have atleast one method. | ||
const domain = new apigw.DomainName(stack, 'MyDomain', { | ||
domainName: 'example.com', | ||
certificate: acm.Certificate.fromCertificateArn(stack, 'cert', 'arn:aws:acm:us-east-1:1111111:certificate/11-3336f1-44483d-adc7-9cd375c5169d'), | ||
endpointType: apigw.EndpointType.REGIONAL, | ||
}); | ||
|
||
// WHEN | ||
new apigw.BasePathMapping(stack, 'MyBasePath', { | ||
restApi: api, | ||
domainName: domain, | ||
basePath: 'My_B45E-P4th', | ||
}); | ||
|
||
// THEN | ||
expect(stack).toHaveResourceLike('AWS::ApiGateway::BasePathMapping', { | ||
BasePath: 'My_B45E-P4th', | ||
}); | ||
}); | ||
|
||
test('throw error for invalid basePath property', () => { | ||
// GIVEN | ||
const stack = new cdk.Stack(); | ||
const api = new apigw.RestApi(stack, 'MyApi'); | ||
api.root.addMethod('GET'); // api must have atleast one method. | ||
const domain = new apigw.DomainName(stack, 'MyDomain', { | ||
domainName: 'example.com', | ||
certificate: acm.Certificate.fromCertificateArn(stack, 'cert', 'arn:aws:acm:us-east-1:1111111:certificate/11-3336f1-44483d-adc7-9cd375c5169d'), | ||
endpointType: apigw.EndpointType.REGIONAL, | ||
}); | ||
|
||
// WHEN | ||
const invalidBasePath = '/invalid-/base-path'; | ||
|
||
// THEN | ||
expect(() => { | ||
new apigw.BasePathMapping(stack, 'MyBasePath', { | ||
restApi: api, | ||
domainName: domain, | ||
basePath: invalidBasePath, | ||
}); | ||
}).toThrowError(/base path may only contain/); | ||
}); | ||
|
||
test('specify stage property', () => { | ||
// GIVEN | ||
const stack = new cdk.Stack(); | ||
const api = new apigw.RestApi(stack, 'MyApi'); | ||
api.root.addMethod('GET'); // api must have atleast one method. | ||
const domain = new apigw.DomainName(stack, 'MyDomain', { | ||
domainName: 'example.com', | ||
certificate: acm.Certificate.fromCertificateArn(stack, 'cert', 'arn:aws:acm:us-east-1:1111111:certificate/11-3336f1-44483d-adc7-9cd375c5169d'), | ||
endpointType: apigw.EndpointType.REGIONAL, | ||
}); | ||
const stage = new apigw.Stage(stack, 'MyStage', { | ||
deployment: new apigw.Deployment(stack, 'MyDeplouyment', { | ||
api, | ||
}), | ||
}); | ||
|
||
// WHEN | ||
new apigw.BasePathMapping(stack, 'MyBasePathMapping', { | ||
restApi: api, | ||
domainName: domain, | ||
stage, | ||
}); | ||
|
||
// THEN | ||
expect(stack).toHaveResourceLike('AWS::ApiGateway::BasePathMapping', { | ||
Stage: { Ref: 'MyStage572B0482' }, | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.