diff --git a/packages/aws-cdk-lib/aws-apigateway/test/method.test.ts b/packages/aws-cdk-lib/aws-apigateway/test/method.test.ts index 7cb2d63f59b08..fe38e525b1bcf 100644 --- a/packages/aws-cdk-lib/aws-apigateway/test/method.test.ts +++ b/packages/aws-cdk-lib/aws-apigateway/test/method.test.ts @@ -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],