Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(apigateway): SpecRestApi ignores disableExecuteApiEndpoint property #21296

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-apigateway/lib/restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ export class SpecRestApi extends RestApiBase {
bodyS3Location: apiDefConfig.inlineDefinition ? undefined : apiDefConfig.s3Location,
endpointConfiguration: this._configureEndpoints(props),
parameters: props.parameters,
disableExecuteApiEndpoint: props.disableExecuteApiEndpoint,
});

props.apiDefinition.bindAfterCreate(this, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,4 +697,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1079,4 +1079,4 @@
"version": "0.0.0"
}
}
}
}
69 changes: 59 additions & 10 deletions packages/@aws-cdk/aws-apigateway/test/restapi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1083,20 +1083,69 @@ describe('restapi', () => {
});
});

test('"disableExecuteApiEndpoint" can disable the default execute-api endpoint', () => {
// GIVEN
const stack = new Stack();
describe('DisableExecuteApiEndpoint', () => {
test('disableExecuteApiEndpoint is false when set to false in RestApi', () => {
// GIVEN
const stack = new Stack();

// WHEN
const api = new apigw.RestApi(stack, 'my-api', { disableExecuteApiEndpoint: true });
api.root.addMethod('GET');
// WHEN
const api = new apigw.RestApi(stack, 'my-api', { disableExecuteApiEndpoint: false });
api.root.addMethod('GET');

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ApiGateway::RestApi', {
DisableExecuteApiEndpoint: true,
// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ApiGateway::RestApi', {
DisableExecuteApiEndpoint: false,
});
});
});

test('disableExecuteApiEndpoint is true when set to true in RestApi', () => {
// GIVEN
const stack = new Stack();

// WHEN
const api = new apigw.RestApi(stack, 'my-api', { disableExecuteApiEndpoint: true });
api.root.addMethod('GET');

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ApiGateway::RestApi', {
DisableExecuteApiEndpoint: true,
});
});

test('disableExecuteApiEndpoint is false when set to false in SpecRestApi', () => {
// GIVEN
const stack = new Stack();

// WHEN
const api = new apigw.SpecRestApi(stack, 'my-api', {
apiDefinition: apigw.ApiDefinition.fromInline({ foo: 'bar' }),
disableExecuteApiEndpoint: false,
});
api.root.addMethod('GET');

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ApiGateway::RestApi', {
DisableExecuteApiEndpoint: false,
});
});

test('disableExecuteApiEndpoint is true when set to true in SpecRestApi', () => {
// GIVEN
const stack = new Stack();

// WHEN
const api = new apigw.SpecRestApi(stack, 'my-api', {
apiDefinition: apigw.ApiDefinition.fromInline({ foo: 'bar' }),
disableExecuteApiEndpoint: true,
});
api.root.addMethod('GET');

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ApiGateway::RestApi', {
DisableExecuteApiEndpoint: true,
});
});
});

describe('Description', () => {
test('description can be set', () => {
Expand Down