@cumulus/cumulus-message-adapter-js
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -9,2 +9,10 @@ # Changelog | ||
## [v1.0.5] - 2018-10-10 | ||
### Added | ||
- Update tests to use downloaded message adapter [CUMULUS-864] | ||
### Fixed | ||
- Fix npm package vulnerabilities | ||
## [v1.0.4] - 2018-08-16 | ||
@@ -33,3 +41,8 @@ ### Added | ||
[Unreleased]: https://github.com/cumulus-nasa/cumulus-cumulus-message-adapter-js/compare/v1.0.3...HEAD | ||
[Unreleased]: | ||
https://github.com/cumulus-nasa/cumulus-cumulus-message-adapter-js/compare/v1.0.5...HEAD | ||
[v1.0.5]: | ||
https://github.com/cumulus-nasa/cumulus-cumulus-message-adapter-js/compare/v1.0.4...v1.0.5 | ||
[v1.0.4]: | ||
https://github.com/cumulus-nasa/cumulus-cumulus-message-adapter-js/compare/v1.0.3...v1.0.4 | ||
[v1.0.3]: https://github.com/cumulus-nasa/cumulus-cumulus-message-adapter-js/compare/v1.0.2...v1.0.3 | ||
@@ -36,0 +49,0 @@ [v1.0.2]: https://github.com/cumulus-nasa/cumulus-cumulus-message-adapter-js/compare/v1.0.1...v1.0.2 |
{ | ||
"name": "@cumulus/cumulus-message-adapter-js", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Cumulus message adapter", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "rm -rf cumulus-message-adapter && cp -R test/cumulus-message-adapter . && ava; rm -rf cumulus-message-adapter" | ||
"test": "ava" | ||
}, | ||
"ava": { | ||
"files": "test" | ||
"files": "test/test*.js" | ||
}, | ||
@@ -43,4 +43,8 @@ "publishConfig": { | ||
"eslint-plugin-node": "^5.2.1", | ||
"eslint-plugin-react": "^7.6.0" | ||
"eslint-plugin-react": "^7.6.0", | ||
"extract-zip": "^1.6.6", | ||
"fs-extra": "^5.0.0", | ||
"lodash.clonedeep": "^4.5.0", | ||
"request": "^2.83.0" | ||
} | ||
} |
@@ -69,3 +69,3 @@ # @cumulus/cumulus-message-adapter-js | ||
The `schemas` JSON should contain `input:`, `output:`, and `config:` with strings for each location. If the schema locations are not specified, the message adapter will look for schemas in a schemas directory at the root level for the files: input.json, output.json, or config.json. If the schema is not specified or missing, schema validation will not be peformed. | ||
The `schemas` JSON should contain `input:`, `output:`, and `config:` with strings for each location. If the schema locations are not specified, the message adapter will look for schemas in a schemas directory at the root level for the files: input.json, output.json, or config.json. If the schema is not specified or missing, schema validation will not be performed. | ||
@@ -72,0 +72,0 @@ ## Example Cumulus task |
@@ -0,6 +1,29 @@ | ||
const test = require('ava').serial; | ||
const clonedeep = require('lodash.clonedeep'); | ||
const fs = require('fs-extra'); | ||
const path = require('path'); | ||
const test = require('ava').serial; | ||
const cumulusMessageAdapter = require('../index'); | ||
const { downloadCMA } = require('./adapter'); | ||
// store test context data | ||
const testContext = {}; | ||
test.before(async() => { | ||
testContext.dir = path.join(__dirname, 'alternate-dir'); | ||
fs.mkdirpSync(testContext.dir); | ||
// download and unzip the message adapter | ||
const { src, dest } = await downloadCMA(testContext.dir, testContext.dir); | ||
const inputJson = path.join(__dirname, 'fixtures/messages/basic.input.json'); | ||
testContext.inputEvent = JSON.parse(fs.readFileSync(inputJson)); | ||
const outputJson = path.join(__dirname, 'fixtures/messages/basic.output.json'); | ||
testContext.outputEvent = JSON.parse(fs.readFileSync(outputJson)); | ||
}); | ||
test.after.always('final cleanup', () => | ||
fs.remove(testContext.dir) | ||
); | ||
test.cb('CUMULUS_MESSAGE_ADAPTER_DIR sets the location of the message adapter', (t) => { | ||
@@ -13,15 +36,6 @@ const dir = path.join(__dirname, 'alternate-dir', 'cumulus-message-adapter'); | ||
const inputEvent = { a: 1 }; | ||
// assign task output from the lambda | ||
const expectedOutput = clonedeep(testContext.outputEvent); | ||
expectedOutput.payload = businessLogicOutput; | ||
const expectedOutput = { | ||
event: { | ||
event: inputEvent, | ||
context: {}, | ||
schemas: null | ||
}, | ||
handler_response: businessLogicOutput, | ||
message_config: null, | ||
schemas: null | ||
}; | ||
function callback(err, data) { | ||
@@ -33,3 +47,3 @@ t.is(err, null); | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, inputEvent, {}, callback); | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, testContext.inputEvent, {}, callback); | ||
}); | ||
@@ -36,0 +50,0 @@ |
@@ -0,4 +1,34 @@ | ||
/* eslint-disable no-param-reassign */ | ||
const test = require('ava'); | ||
const fs = require('fs-extra'); | ||
const path = require('path'); | ||
const clonedeep = require('lodash.clonedeep'); | ||
const cumulusMessageAdapter = require('../index'); | ||
const { downloadCMA } = require('./adapter'); | ||
// store test context data | ||
const testContext = {}; | ||
test.before(async() => { | ||
const srcdir = __dirname; | ||
const destdir = path.join(__dirname, '../'); | ||
// download and unzip the message adapter | ||
const { src, dest } = await downloadCMA(srcdir, destdir); | ||
testContext.src = src; | ||
testContext.dest = dest; | ||
const inputJson = path.join(__dirname, 'fixtures/messages/basic.input.json'); | ||
testContext.inputEvent = JSON.parse(fs.readFileSync(inputJson)); | ||
const outputJson = path.join(__dirname, 'fixtures/messages/basic.output.json'); | ||
testContext.outputEvent = JSON.parse(fs.readFileSync(outputJson)); | ||
}); | ||
test.after.always('final cleanup', () => | ||
Promise.all([ | ||
fs.remove(testContext.src), | ||
fs.remove(testContext.dest) | ||
])); | ||
test.cb('The correct cumulus message is returned', (t) => { | ||
@@ -8,15 +38,6 @@ const businessLogicOutput = 42; | ||
const inputEvent = { a: 1 }; | ||
// assign task output from the lambda | ||
const expectedOutput = clonedeep(testContext.outputEvent); | ||
expectedOutput.payload = businessLogicOutput; | ||
const expectedOutput = { | ||
event: { | ||
event: inputEvent, | ||
context: {}, | ||
schemas: null | ||
}, | ||
handler_response: businessLogicOutput, | ||
message_config: null, | ||
schemas: null | ||
}; | ||
function callback(err, data) { | ||
@@ -28,3 +49,3 @@ t.is(err, null); | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, inputEvent, {}, callback); | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, testContext.inputEvent, {}, callback); | ||
}); | ||
@@ -36,15 +57,5 @@ | ||
const inputEvent = { a: 1 }; | ||
const expectedOutput = clonedeep(testContext.outputEvent); | ||
expectedOutput.payload = businessLogicOutput; | ||
const expectedOutput = { | ||
event: { | ||
event: inputEvent, | ||
context: {}, | ||
schemas: null | ||
}, | ||
handler_response: businessLogicOutput, | ||
message_config: null, | ||
schemas: null | ||
}; | ||
function callback(err, data) { | ||
@@ -56,13 +67,12 @@ t.is(err, null); | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, inputEvent, {}, callback); | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, testContext.inputEvent, {}, callback); | ||
}); | ||
test.cb('The businessLogic receives the correct arguments', (t) => { | ||
const inputEvent = { a: 1 }; | ||
const context = { b: 2 }; | ||
const expectedNestedEvent = { | ||
event: { event: { a: 1 }, context, schemas: null }, | ||
schemas: null, | ||
context | ||
input: testContext.inputEvent.payload, | ||
config: testContext.inputEvent.workflow_config[testContext.inputEvent.cumulus_meta.task] | ||
}; | ||
@@ -73,16 +83,15 @@ | ||
t.deepEqual(actualContext, context); | ||
return 42; | ||
} | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, inputEvent, context, t.end); | ||
return cumulusMessageAdapter | ||
.runCumulusTask(businessLogic, testContext.inputEvent, context, t.end); | ||
}); | ||
test.cb('A WorkflowError is returned properly', (t) => { | ||
const inputEvent = { a: 1 }; | ||
const expectedOutput = clonedeep(testContext.outputEvent); | ||
expectedOutput.payload = null; | ||
expectedOutput.exception = 'SomeWorkflowError'; | ||
const expectedOutput = { | ||
a: 1, | ||
payload: null, | ||
exception: 'SomeWorkflowError' | ||
}; | ||
function businessLogic() { | ||
@@ -100,3 +109,3 @@ const error = new Error('Oh snap'); | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, inputEvent, {}, callback); | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, testContext.inputEvent, {}, callback); | ||
}); | ||
@@ -116,3 +125,3 @@ | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, {}, {}, callback); | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, testContext.inputEvent, {}, callback); | ||
}); | ||
@@ -132,14 +141,10 @@ | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, {}, {}, callback); | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, testContext.inputEvent, {}, callback); | ||
}); | ||
test.cb('A Promise WorkflowError is returned properly', (t) => { | ||
const inputEvent = { a: 1 }; | ||
const expectedOutput = clonedeep(testContext.outputEvent); | ||
expectedOutput.payload = null; | ||
expectedOutput.exception = 'SomeWorkflowError'; | ||
const expectedOutput = { | ||
a: 1, | ||
payload: null, | ||
exception: 'SomeWorkflowError' | ||
}; | ||
function businessLogic() { | ||
@@ -157,3 +162,3 @@ const error = new Error('Oh no'); | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, inputEvent, {}, callback); | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, testContext.inputEvent, {}, callback); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
233371
20
6320
13
15