feat: CORS enable button...ish still now understanding this
This commit is contained in:
@@ -145,6 +145,61 @@ describe('EventBridge rule routes', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('API Gateway CORS routes', () => {
|
||||
test('dispatches resource-scoped CORS configuration through the API Gateway adapter', async () => {
|
||||
const calls: unknown[] = []
|
||||
const app = appWithRoutes([mockAdapter('aws', {
|
||||
service: 'apigateway',
|
||||
enableApiGatewayCors: async (apiId, input) => {
|
||||
calls.push({apiId, input})
|
||||
return {configuredMethods: ['GET'], proxyMethods: ['POST']}
|
||||
},
|
||||
})])
|
||||
|
||||
const response = await app.request('/api/clouds/aws/services/apigateway/resources/api-123/cors', {
|
||||
method: 'POST', headers: {'content-type': 'application/json'},
|
||||
body: JSON.stringify({resourceId: 'resource-456', stage: 'dev', origin: '*', headers: 'Content-Type', methods: ['GET', 'POST']}),
|
||||
})
|
||||
|
||||
expect(response.status).toBe(200)
|
||||
expect(await response.json()).toEqual({configuredMethods: ['GET'], proxyMethods: ['POST']})
|
||||
expect(calls).toEqual([{apiId: 'api-123', input: {
|
||||
resourceId: 'resource-456', stage: 'dev', origin: '*', headers: 'Content-Type', methods: ['GET', 'POST'],
|
||||
}}])
|
||||
})
|
||||
})
|
||||
|
||||
describe('S3 website routes', () => {
|
||||
test('routes normalized website configuration lifecycle requests through the storage adapter', async () => {
|
||||
const calls: Array<{operation: string; args: unknown[]}> = []
|
||||
const adapter = mockAdapter('aws', {
|
||||
getS3BucketWebsite: async (...args) => {
|
||||
calls.push({operation: 'get', args})
|
||||
return {mode: 'index', indexDocument: 'index.html', errorDocument: null}
|
||||
},
|
||||
putS3BucketWebsite: async (...args) => { calls.push({operation: 'put', args}) },
|
||||
deleteS3BucketWebsite: async (...args) => { calls.push({operation: 'delete', args}) },
|
||||
})
|
||||
const app = appWithRoutes([adapter])
|
||||
|
||||
const get = await app.request('/api/clouds/aws/services/storage/resources/assets/website')
|
||||
const put = await app.request('/api/clouds/aws/services/storage/resources/assets/website', {
|
||||
method: 'PUT', headers: {'content-type': 'application/json'},
|
||||
body: JSON.stringify({mode: 'redirect', hostName: 'www.example.com', protocol: 'https'}),
|
||||
})
|
||||
const remove = await app.request('/api/clouds/aws/services/storage/resources/assets/website', {method: 'DELETE'})
|
||||
|
||||
expect(await get.json()).toEqual({mode: 'index', indexDocument: 'index.html', errorDocument: null})
|
||||
expect(put.status).toBe(200)
|
||||
expect(remove.status).toBe(200)
|
||||
expect(calls).toEqual([
|
||||
{operation: 'get', args: ['assets']},
|
||||
{operation: 'put', args: ['assets', {mode: 'redirect', hostName: 'www.example.com', protocol: 'https'}]},
|
||||
{operation: 'delete', args: ['assets']},
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe('SNS subscription routes', () => {
|
||||
test('routes subscription lifecycle requests through the Notifications adapter', async () => {
|
||||
const calls: Array<{operation: string; args: unknown[]}> = []
|
||||
|
||||
Reference in New Issue
Block a user