@cumulus/cumulus-message-adapter-js
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -9,2 +9,6 @@ # Changelog | ||
## [v1.0.8] - 2019-09-16 | ||
### Added | ||
- Updated CMA client to handle parameterized configuration, set execution env variable regardless of message format | ||
## [v1.0.7] - 2018-11-08 | ||
@@ -51,4 +55,7 @@ | ||
[Unreleased]: | ||
https://github.com/nasa/cumulus-cumulus-message-adapter-js/compare/v1.0.7...HEAD | ||
https://github.com/nasa/cumulus-cumulus-message-adapter-js/compare/v1.0.8...HEAD | ||
[v1.0.8]: | ||
https://github.com/nasa/cumulus-cumulus-message-adapter-js/compare/v1.0.7...1.0.8 | ||
[v1.0.7]: | ||
@@ -55,0 +62,0 @@ https://github.com/nasa/cumulus-cumulus-message-adapter-js/compare/v1.0.6...v1.0.7 |
@@ -146,3 +146,6 @@ 'use strict'; | ||
process.env.EXECUTIONS = cumulusMessage.cumulus_meta.execution_name; | ||
} else if (cumulusMessage.cma) { | ||
process.env.EXECUTIONS = cumulusMessage.cma.event.cumulus_meta.execution_name; | ||
} | ||
process.env.SENDER = context.functionName; | ||
@@ -149,0 +152,0 @@ process.env.TASKVERSION = context.functionVersion; |
{ | ||
"name": "@cumulus/cumulus-message-adapter-js", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Cumulus message adapter", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -9,3 +9,3 @@ /* eslint-disable no-param-reassign */ | ||
const cumulusMessageAdapter = require('../index'); | ||
const { downloadCMA } = require('./adapter'); | ||
const { downloadCMA, extractZipFile } = require('./adapter'); | ||
@@ -19,8 +19,18 @@ // store test context data | ||
// download and unzip the message adapter | ||
const { src, dest } = await downloadCMA(srcdir, destdir); | ||
testContext.src = src; | ||
testContext.dest = dest; | ||
if (process.env.LOCAL_CMA_ZIP_FILE) { | ||
const dest = path.join(destdir, 'cumulus-message-adapter'); | ||
await extractZipFile(process.env.LOCAL_CMA_ZIP_FILE, dest) | ||
} | ||
else { | ||
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 executionInputJson = path.join(__dirname, 'fixtures/messages/execution.input.json'); | ||
testContext.executionInput = JSON.parse(fs.readFileSync(executionInputJson)); | ||
const paramInputJson = path.join(__dirname, 'fixtures/messages/parameterized.input.json'); | ||
testContext.paramInputEvent = JSON.parse(fs.readFileSync(paramInputJson)); | ||
const outputJson = path.join(__dirname, 'fixtures/messages/basic.output.json'); | ||
@@ -30,25 +40,37 @@ testContext.outputEvent = JSON.parse(fs.readFileSync(outputJson)); | ||
test.after.always('final cleanup', () => | ||
Promise.all([ | ||
test.after.always('final cleanup', () => { | ||
if(process.env.LOCAL_CMA_ZIP_FILE) { | ||
return Promise.resolve(); | ||
} | ||
return Promise.all([ | ||
fs.remove(testContext.src), | ||
fs.remove(testContext.dest) | ||
])); | ||
]); | ||
}); | ||
test.cb('The correct cumulus message is returned', (t) => { | ||
const businessLogicOutput = 42; | ||
const businessLogic = () => businessLogicOutput; | ||
test.cb('Execution is set when parameterized configuration is set', (t) => { | ||
const businessLogic = () => Promise.resolve(process.env.EXECUTIONS); | ||
const expectedOutput = 'execution_value'; | ||
function callback(err, data) { | ||
t.is(err, null); | ||
t.deepEqual(data.payload, expectedOutput); | ||
t.end(); | ||
} | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, testContext.paramInputEvent, {}, callback); | ||
}); | ||
// assign task output from the lambda | ||
const expectedOutput = clonedeep(testContext.outputEvent); | ||
expectedOutput.payload = businessLogicOutput; | ||
test.cb('Execution is set when cumulus_meta has an execution value', (t) => { | ||
const businessLogic = () => Promise.resolve(process.env.EXECUTIONS); | ||
const expectedOutput = 'execution_value'; | ||
function callback(err, data) { | ||
t.is(err, null); | ||
t.deepEqual(data, expectedOutput); | ||
t.deepEqual(data.payload, expectedOutput); | ||
t.end(); | ||
} | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, testContext.inputEvent, {}, callback); | ||
return cumulusMessageAdapter.runCumulusTask(businessLogic, testContext.paramInputEvent, {}, callback); | ||
}); | ||
test.cb('Correct cumulus message is returned when task returns a promise that resolves', (t) => { | ||
@@ -55,0 +77,0 @@ const businessLogicOutput = 42; |
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
236349
22
6400
21