feat: EC2 UI polished + storage persisting

This commit is contained in:
Zakaria
2026-09-25 18:18:33 -04:00
parent 1b129e9dcf
commit 093afb9b2b
40 changed files with 2586 additions and 102 deletions
+84
View File
@@ -17,6 +17,8 @@ import {awsKmsSchema} from '../cloud-spi/kmsSchema'
import {awsStorageSchema, azureStorageSchema, gcpStorageSchema} from '../cloud-spi/storageSchema'
import {awsSesEmailSchema} from '../cloud-spi/emailSchema'
import {awsAppConfigSchema} from '../cloud-spi/appConfigSchema'
import {awsEventBridgeSchema} from '../cloud-spi/eventbridgeSchema'
import {awsNotificationsSchema} from '../cloud-spi/notificationsSchema'
import type {
AppConfigConfigurationProfile,
AppConfigDeployment,
@@ -99,6 +101,88 @@ function appWithRoutes(
return app
}
describe('EventBridge rule routes', () => {
test('routes rule lifecycle requests through the Events adapter using the event bus resource id', async () => {
const calls: Array<{operation: string; args: unknown[]}> = []
const adapter = mockAdapter('aws', {
service: 'events',
schema: awsEventBridgeSchema,
listEventBridgeRules: async (...args) => {
calls.push({operation: 'list', args})
return []
},
createEventBridgeRule: async (...args) => {
calls.push({operation: 'create', args})
return {
name: 'hourly', busName: 'orders', busId: 'event-bus:orders', arn: null,
scheduleExpression: 'rate(1 hour)', state: 'ENABLED', targets: [],
}
},
deleteEventBridgeRule: async (...args) => {
calls.push({operation: 'delete', args})
},
})
const app = appWithRoutes([adapter])
const create = await app.request('/api/clouds/aws/services/events/resources/event-bus:orders/rules', {
method: 'POST',
headers: {'content-type': 'application/json'},
body: JSON.stringify({
name: 'hourly', scheduleExpression: 'rate(1 hour)',
targets: [{id: 'worker', arn: 'arn:aws:lambda:us-east-1:000000000000:function:worker'}],
}),
})
expect(create.status).toBe(201)
await app.request('/api/clouds/aws/services/events/resources/event-bus:orders/rules')
const remove = await app.request('/api/clouds/aws/services/events/resources/event-bus:orders/rules/hourly', {method: 'DELETE'})
expect(remove.status).toBe(200)
expect(calls).toEqual([
{operation: 'create', args: ['event-bus:orders', {name: 'hourly', scheduleExpression: 'rate(1 hour)', eventPattern: undefined, state: undefined, description: undefined, targets: [{id: 'worker', arn: 'arn:aws:lambda:us-east-1:000000000000:function:worker'}]}]},
{operation: 'list', args: ['event-bus:orders']},
{operation: 'delete', args: ['event-bus:orders', 'hourly']},
])
})
})
describe('SNS subscription routes', () => {
test('routes subscription lifecycle requests through the Notifications adapter', async () => {
const calls: Array<{operation: string; args: unknown[]}> = []
const adapter = mockAdapter('aws', {
service: 'notifications',
schema: awsNotificationsSchema,
createSnsSubscription: async (...args) => {
calls.push({operation: 'create', args})
return {arn: 'subscription-1', protocol: 'sqs', endpoint: 'arn:aws:sqs:us-east-1:000000000000:orders', status: 'Confirmed', filterPolicy: null}
},
listSnsSubscriptions: async (...args) => {
calls.push({operation: 'list', args})
return []
},
deleteSnsSubscription: async (...args) => {
calls.push({operation: 'delete', args})
},
})
const app = appWithRoutes([adapter])
const create = await app.request('/api/clouds/aws/services/notifications/resources/orders/subscriptions', {
method: 'POST',
headers: {'content-type': 'application/json'},
body: JSON.stringify({protocol: 'sqs', endpoint: 'arn:aws:sqs:us-east-1:000000000000:orders'}),
})
expect(create.status).toBe(201)
await app.request('/api/clouds/aws/services/notifications/resources/orders/subscriptions')
const remove = await app.request('/api/clouds/aws/services/notifications/resources/orders/subscriptions/subscription-1', {method: 'DELETE'})
expect(remove.status).toBe(200)
expect(calls).toEqual([
{operation: 'create', args: ['orders', {protocol: 'sqs', endpoint: 'arn:aws:sqs:us-east-1:000000000000:orders'}]},
{operation: 'list', args: ['orders']},
{operation: 'delete', args: ['subscription-1']},
])
})
})
const databaseSnapshot: DatabaseSnapshot = {
id: 'orders-db-snapshot-1',
name: 'orders-db-snapshot-1',