Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-deny-list-to-origin-request-policy-…
Browse files Browse the repository at this point in the history
…behaviors
  • Loading branch information
mergify[bot] authored Jul 7, 2023
2 parents d57fc8a + 9bcc6d5 commit 6e2437b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-apigateway/lib/method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export class Method extends Resource {
authorizer._attachToApi(this.api);
}

this.methodResponses = options.methodResponses ?? [];
this.methodResponses = options.methodResponses ?? defaultMethodOptions.methodResponses ?? [];

const integration = props.integration ?? this.resource.defaultIntegration ?? new MockIntegration();
const bindResult = integration.bind(this);
Expand Down
32 changes: 32 additions & 0 deletions packages/aws-cdk-lib/aws-apigateway/test/method.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,38 @@ describe('method', () => {

});

test('methodResponse should be passed from defaultMethodOptions', () => {
// GIVEN
const stack = new cdk.Stack();
const api = new apigw.RestApi(stack, 'test-api', {
cloudWatchRole: false,
deploy: false,
defaultMethodOptions: {
requestParameters: { 'method.request.path.proxy': true },
methodResponses: [
{
statusCode: '200',
},
],
},
});

// WHEN
new apigw.Method(stack, 'method-man', {
httpMethod: 'GET',
resource: api.root,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ApiGateway::Method', {
HttpMethod: 'GET',
MethodResponses: [{
StatusCode: '200',
}],
});

});

describe('Metrics', () => {
test('metric', () => {
// GIVEN
Expand Down

0 comments on commit 6e2437b

Please sign in to comment.