|
| 1 | +'use strict' |
| 2 | + |
| 3 | +const expect = require('chai').expect |
| 4 | +const fetch = require('node-fetch') |
| 5 | +const { deployService, removeService, getApiGatewayEndpoint } = require('./../../utils') |
| 6 | + |
| 7 | +describe('SQS Proxy Integration Test', () => { |
| 8 | + let endpoint |
| 9 | + let stackName |
| 10 | + let stage |
| 11 | + const config = '__tests__/integration/sqs/service/serverless.yml' |
| 12 | + |
| 13 | + beforeAll(async () => { |
| 14 | + stage = Math.random() |
| 15 | + .toString(32) |
| 16 | + .substring(2) |
| 17 | + stackName = 'sqs-proxy-' + stage |
| 18 | + deployService(stage, config) |
| 19 | + endpoint = await getApiGatewayEndpoint(stackName) |
| 20 | + }) |
| 21 | + |
| 22 | + afterAll(() => { |
| 23 | + removeService(stage, config) |
| 24 | + }) |
| 25 | + |
| 26 | + it('should get correct response from sqs proxy endpoint', async () => { |
| 27 | + const testEndpoint = `${endpoint}/sqs` |
| 28 | + |
| 29 | + const response = await fetch(testEndpoint, { |
| 30 | + method: 'POST', |
| 31 | + headers: { 'Content-Type': 'application/json' }, |
| 32 | + body: JSON.stringify({ message: 'testtest' }) |
| 33 | + }) |
| 34 | + expect(response.headers.get('access-control-allow-origin')).to.deep.equal('*') |
| 35 | + expect(response.status).to.be.equal(200) |
| 36 | + const body = await response.json() |
| 37 | + expect(body.SendMessageResponse.SendMessageResult).to.have.own.property( |
| 38 | + 'MD5OfMessageAttributes' |
| 39 | + ) |
| 40 | + expect(body.SendMessageResponse.SendMessageResult).to.have.own.property('MD5OfMessageBody') |
| 41 | + expect(body.SendMessageResponse.SendMessageResult).to.have.own.property('MessageId') |
| 42 | + expect(body.SendMessageResponse.SendMessageResult).to.have.own.property('SequenceNumber') |
| 43 | + expect(body.SendMessageResponse.ResponseMetadata).to.have.own.property('RequestId') |
| 44 | + }) |
| 45 | +}) |
0 commit comments