Skip to content

Commit

Permalink
revert: fix(apigateway): set authorization scope when authorization t…
Browse files Browse the repository at this point in the history
…ype is Cognito
  • Loading branch information
GavinZZ committed Jul 10, 2024
1 parent 7cd0f65 commit 8260844
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 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 @@ -812,6 +812,25 @@ describe('method', () => {
}).not.toThrow(/Authorization type is set to AWS_IAM which is different from what is required by the authorizer/);
});

test('No options authorization type set but expect auth scope set', () => {
const stack = new cdk.Stack();
const api = new apigw.RestApi(stack, 'test-api', {
cloudWatchRole: false,
deploy: false,
defaultMethodOptions: {
authorizationType: apigw.AuthorizationType.COGNITO,
},
});

api.root.resourceForPath('/user/profile').addMethod('GET', undefined, {
authorizationScopes: ['profile'],
});

Template.fromStack(stack).hasResourceProperties('AWS::ApiGateway::Method', {
AuthorizationScopes: ['profile'],
});
});

test.each([
[apigw.AuthorizationType.IAM, undefined],
[apigw.AuthorizationType.NONE, undefined],
Expand Down

0 comments on commit 8260844

Please sign in to comment.