kinvey-code-task-runner
Advanced tools
Comparing version 2.4.1 to 2.5.0
## Changelog | ||
### 2.5.0 | ||
* Add login hooks properties | ||
### 2.4.1 | ||
@@ -4,0 +7,0 @@ * Fixed several security vulnerabilities |
@@ -40,2 +40,3 @@ // Copyright (c) 2018 Kinvey Inc. | ||
const method = res.locals.method || req.method; | ||
const isLoginHook = req.body.loginOptions != null; | ||
@@ -69,4 +70,4 @@ if (req.body.response) { | ||
headers: requestHeaders, | ||
username: req.get('X-Kinvey-Username') || '', | ||
userId: req.get('X-Kinvey-User-Id') || '' | ||
username: isLoginHook ? undefined : req.get('X-Kinvey-Username') || '', | ||
userId: isLoginHook ? undefined : req.get('X-Kinvey-User-Id') || '' | ||
}, | ||
@@ -125,2 +126,9 @@ response: { | ||
function appendLoginAttributes(req, res, next) { | ||
if (req.body.loginOptions) { | ||
req.task.request.loginOptions = req.body.loginOptions; | ||
} | ||
next(); | ||
} | ||
function getDataBody(result) { | ||
@@ -268,3 +276,3 @@ return result.response.body; | ||
// FlexFunctions route | ||
router.post('/_flexFunctions/:handlerName', mapPostToElements, generateBaseTask, addFunctionsTaskAttributes, appendQuery, appendId, appendBody, sendTask); | ||
router.post('/_flexFunctions/:handlerName', mapPostToElements, generateBaseTask, addFunctionsTaskAttributes, appendQuery, appendId, appendBody, appendLoginAttributes, sendTask); | ||
router.post('/_auth/:handlerName', generateBaseTask, addAuthTaskAttributes, sendTask); | ||
@@ -271,0 +279,0 @@ |
{ | ||
"name": "kinvey-code-task-runner", | ||
"version": "2.4.1", | ||
"version": "2.5.0", | ||
"description": "Task Runner for Kinvey Microservices", | ||
@@ -23,4 +23,4 @@ "engines": { | ||
"devDependencies": { | ||
"@progresskinvey/eslint-config-kinvey-platform": "0.2.0", | ||
"eslint": "5.16.0", | ||
"eslint-config-kinvey-platform": "0.1.6", | ||
"eslint-plugin-import": "2.16.0", | ||
@@ -34,4 +34,4 @@ "mocha": "5.1.1", | ||
"scripts": { | ||
"pretest": "npm run pretest", | ||
"lint": "./node_modules/.bin/eslint lib test *.js", | ||
"pretest": "npm run lint", | ||
"lint": "./node_modules/.bin/eslint lib test *.js --color", | ||
"test": "npm run test-unit && npm run test-integration", | ||
@@ -38,0 +38,0 @@ "test-unit": "mocha test/unit/*/*", |
@@ -440,2 +440,53 @@ // Copyright (c) 2018 Kinvey Inc. | ||
it('should add loginOptions and remove username and userId for loginHooks', (done) => { | ||
function taskReceivedCallback(receivedTask, callback) { | ||
receivedTask.response.statusCode = 200; | ||
receivedTask.response.body = {}; | ||
receivedTask.response.continue = true; | ||
callback(null, receivedTask); | ||
} | ||
startReceiver(taskReceivedCallback, () => { | ||
// noinspection JSCheckFunctionSignatures | ||
supertest(TEST_URL) | ||
.post(LOGIC_ROUTE) | ||
.send({ loginOptions: { type: 'kinvey' } }) | ||
.set('X-Kinvey-Username', 'abcd') | ||
.set('X-Kinvey-User-Id', 'abcd') | ||
.expect(200) | ||
.end((err, res) => { | ||
should.not.exist(res.body.request.userId); | ||
should.not.exist(res.body.request.username); | ||
res.body.request.loginOptions.should.be.an.Object(); | ||
res.statusCode.should.eql(200); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('should not return loginOptions and set username and userid for non loginHooks', (done) => { | ||
function taskReceivedCallback(receivedTask, callback) { | ||
receivedTask.response.statusCode = 200; | ||
receivedTask.response.body = {}; | ||
receivedTask.response.continue = true; | ||
callback(null, receivedTask); | ||
} | ||
startReceiver(taskReceivedCallback, () => { | ||
// noinspection JSCheckFunctionSignatures | ||
supertest(TEST_URL) | ||
.post(LOGIC_ROUTE) | ||
.set('X-Kinvey-Username', 'abcd') | ||
.set('X-Kinvey-User-Id', 'abcd') | ||
.expect(200) | ||
.end((err, res) => { | ||
should.exist(res.body.request.userId); | ||
should.exist(res.body.request.username); | ||
should.not.exist(res.body.request.loginOptions); | ||
res.statusCode.should.eql(200); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('should send a response', (done) => { | ||
@@ -442,0 +493,0 @@ function taskReceivedCallback(receivedTask, callback) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90779
1938