From 52dd00796d3243393020e59bf5d9c7ff976aff0c Mon Sep 17 00:00:00 2001 From: Anish Karandikar Date: Thu, 17 May 2018 11:26:01 -0400 Subject: [PATCH] test(cors): Add test for CORS headers --- package.json | 2 +- test/test.Util.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e3958716..6722fd53 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "scripts": { "lint": "eslint src/ test/", - "test": "npm run lint && ./test-api-local.sh", + "test": "npm run lint && AWS_ACCESS_KEY_ID=foo AWS_SECRET_ACCESS_KEY=bar ./test-api-local.sh", "start": "./start-server.sh", "stop": "./stop-server.sh", "deploy": "serverless deploy", diff --git a/test/test.Util.js b/test/test.Util.js index 9c9adb11..c0b3c417 100644 --- a/test/test.Util.js +++ b/test/test.Util.js @@ -69,6 +69,16 @@ describe('Util', async () => { `Expected key not found: [${k}], ` + `Actual: [${JSON.stringify(pong.data)}]`); }); + + // Verify CORS headers + [ + ['access-control-allow-origin', '*'], + ['access-control-allow-credentials', 'true'], + ].forEach(pair => { + assert.equal(pong.headers[pair[0]], pair[1], + `Expected header not found: [${pair[0]}]=[${pair[1]}]` + ); + }); }); });