feat: CORS enable button... small fixes
This commit is contained in:
@@ -310,6 +310,24 @@ describe('AwsApiGatewayAdapter', () => {
|
||||
expect((lambdaCommands[0] as RemovePermissionCommand).input).toMatchObject({FunctionName: 'hello', StatementId: 'apigateway-a1b2c3-dev-POST-hello'})
|
||||
})
|
||||
|
||||
test('deletes a CORS OPTIONS method and redeploys its stage', async () => {
|
||||
const commands: unknown[] = []
|
||||
const adapter = new AwsApiGatewayAdapter(fakeClient((command) => {
|
||||
commands.push(command)
|
||||
if (command instanceof GetMethodCommand) {
|
||||
return {methodIntegration: {type: 'MOCK'}}
|
||||
}
|
||||
return {}
|
||||
}), fakeLambda(() => ({})))
|
||||
|
||||
await adapter.deleteApiGatewayRoute('a1b2c3', {resourceId: 'resource456', path: '/hello', method: 'OPTIONS', stage: 'dev'})
|
||||
|
||||
expect(commands.map((command) => (command as {constructor: {name: string}}).constructor.name)).toEqual([
|
||||
'GetMethodCommand', 'DeleteMethodCommand', 'CreateDeploymentCommand',
|
||||
])
|
||||
expect((commands[1] as DeleteMethodCommand).input).toMatchObject({httpMethod: 'OPTIONS'})
|
||||
})
|
||||
|
||||
test('enables CORS for non-proxy methods, creates OPTIONS, and reports proxy methods', async () => {
|
||||
const commands: unknown[] = []
|
||||
const adapter = new AwsApiGatewayAdapter(fakeClient((command) => {
|
||||
|
||||
@@ -220,7 +220,7 @@ export class AwsApiGatewayAdapter implements CloudServiceAdapter {
|
||||
async deleteApiGatewayRoute(apiId: string, input: ApiGatewayDeleteRouteInput): Promise<void> {
|
||||
const method = input.method.toUpperCase()
|
||||
const stage = stageName(input.stage)
|
||||
if (!['GET', 'POST', 'PUT', 'DELETE'].includes(method)) throw new ValidationError('method must be GET, POST, PUT, or DELETE')
|
||||
if (!CORS_METHODS.includes(method)) throw new ValidationError('method must be GET, POST, PUT, DELETE, or OPTIONS')
|
||||
if (!stringValue(input.resourceId)) throw new ValidationError('resourceId is required')
|
||||
|
||||
const route = await this.apiGateway.send(new GetMethodCommand({
|
||||
|
||||
Reference in New Issue
Block a user