diff --git a/integration-tests/rest-user.js b/integration-tests/rest-user.js index d5c1269..816d981 100644 --- a/integration-tests/rest-user.js +++ b/integration-tests/rest-user.js @@ -511,6 +511,27 @@ describe('REST API User', function () { }); }); + it('should update current user agreedToPersonalDataCollection field', function (done) { + req.update(path.combine(path.USER, path.CURRENT)) + .params({jwt: jwt, data: {agreedToPersonalDataCollection: true}}) + .send(function (err) { + if (err) { + return done(err); + } + + req.get(path.combine(path.USER, path.CURRENT)) + .params({jwt: jwt}) + .expect({ + id: user.id, + login: user.login, + role: 1, + status: 0, + agreedToPersonalDataCollection: true + }) + .send(done); + }); + }); + it('should update current user data field', function (done) { req.update(path.combine(path.USER, path.CURRENT)) .params({jwt: jwt, data: {data: {userdata: "userdata"}}}) diff --git a/integration-tests/ws-user.js b/integration-tests/ws-user.js index 4cb9347..f4b77f6 100644 --- a/integration-tests/ws-user.js +++ b/integration-tests/ws-user.js @@ -660,6 +660,42 @@ describe('WebSocket API User', function () { }); }); + it('should update current user agreedToPersonalDataCollection field', function (done) { + var requestId = getRequestId(); + + conn.on({ + action: "user/updateCurrent", + requestId: requestId, + status: "success" + }, (err, data) => { + if (err) { + return done(err); + } + var requestId2 = getRequestId(); + + conn.on({ + current: { + id: user.id, + login: user.login, + role: 1, + status: 0, + agreedToPersonalDataCollection: true + } + }, done); + + conn.send({ + action: 'user/getCurrent', + requestId: requestId + }); + }); + + conn.send({ + action: 'user/updateCurrent', + requestId: requestId, + user: { agreedToPersonalDataCollection: true } + }); + }); + it('should update current user data field', function (done) { var requestId = getRequestId(); var requestId2 = getRequestId(); @@ -941,7 +977,7 @@ describe('WebSocket API User', function () { code: status.NOT_AUTHORIZED, error: 'Unauthorized' }, done); - + noTokenConn.send({ action: 'authenticate', requestId: getRequestId(), @@ -956,7 +992,7 @@ describe('WebSocket API User', function () { code: status.NOT_AUTHORIZED, error: 'Unauthorized' }, done); - + noTokenConn.send({ action: 'user/list', requestId: getRequestId(), @@ -971,7 +1007,7 @@ describe('WebSocket API User', function () { code: status.NOT_AUTHORIZED, error: 'Unauthorized' }, done); - + noTokenConn.send({ action: 'user/get', requestId: getRequestId(), @@ -986,7 +1022,7 @@ describe('WebSocket API User', function () { code: status.NOT_AUTHORIZED, error: 'Unauthorized' }, done); - + noTokenConn.send({ action: 'user/getCurrent', requestId: getRequestId(), @@ -1001,7 +1037,7 @@ describe('WebSocket API User', function () { code: status.NOT_AUTHORIZED, error: 'Unauthorized' }, done); - + noTokenConn.send({ action: 'user/insert', requestId: getRequestId(), @@ -1016,7 +1052,7 @@ describe('WebSocket API User', function () { code: status.NOT_AUTHORIZED, error: 'Unauthorized' }, done); - + noTokenConn.send({ action: 'user/update', requestId: getRequestId(), @@ -1031,7 +1067,7 @@ describe('WebSocket API User', function () { code: status.NOT_AUTHORIZED, error: 'Unauthorized' }, done); - + noTokenConn.send({ action: 'user/updateCurrent', requestId: getRequestId(), @@ -1046,7 +1082,7 @@ describe('WebSocket API User', function () { code: status.NOT_AUTHORIZED, error: 'Unauthorized' }, done); - + noTokenConn.send({ action: 'user/delete', requestId: getRequestId(), @@ -1100,7 +1136,7 @@ describe('WebSocket API User', function () { action: 'authenticate', status: 'success' }, callback); - + nonNetworkConn.send({ action: 'authenticate', requestId: getRequestId(), @@ -1125,7 +1161,7 @@ describe('WebSocket API User', function () { code: status.FORBIDDEN, error: 'Access is denied' }, done); - + nonNetworkConn.send({ action: 'user/list', requestId: getRequestId() @@ -1139,7 +1175,7 @@ describe('WebSocket API User', function () { code: status.FORBIDDEN, error: 'Access is denied' }, done); - + nonNetworkConn.send({ action: 'user/get', requestId: getRequestId(), @@ -1154,7 +1190,7 @@ describe('WebSocket API User', function () { code: status.NOT_AUTHORIZED, error: 'Invalid credentials' }, done); - + refreshConn.send({ action: 'authenticate', requestId: getRequestId(), @@ -1169,7 +1205,7 @@ describe('WebSocket API User', function () { code: status.FORBIDDEN, error: 'Access is denied' }, done); - + nonNetworkConn.send({ action: 'user/list', requestId: getRequestId() @@ -1183,7 +1219,7 @@ describe('WebSocket API User', function () { code: status.FORBIDDEN, error: 'Access is denied' }, done); - + nonNetworkConn.send({ action: 'user/list', requestId: getRequestId(), @@ -1198,7 +1234,7 @@ describe('WebSocket API User', function () { code: status.FORBIDDEN, error: 'Access is denied' }, done); - + nonNetworkConn.send({ action: 'user/insert', requestId: getRequestId(), @@ -1213,7 +1249,7 @@ describe('WebSocket API User', function () { code: status.FORBIDDEN, error: 'Access is denied' }, done); - + nonNetworkConn.send({ action: 'user/update', requestId: getRequestId(), @@ -1229,7 +1265,7 @@ describe('WebSocket API User', function () { code: status.FORBIDDEN, error: 'Access is denied' }, done); - + nonNetworkConn.send({ action: 'user/delete', requestId: requestId, @@ -1336,7 +1372,7 @@ describe('WebSocket API User', function () { action: 'authenticate', status: 'success' }, callback); - + conn.send({ action: 'authenticate', requestId: getRequestId(), @@ -1352,7 +1388,7 @@ describe('WebSocket API User', function () { assert(data.user.lastLogin !== null); done(); }); - + adminConn.send({ action: 'user/get', userId: user.id @@ -1463,7 +1499,7 @@ describe('WebSocket API User', function () { action: 'authenticate', status: 'success' }, callback); - + conn.send({ action: 'authenticate', requestId: getRequestId(), diff --git a/package-lock.json b/package-lock.json index 661022d..9b97e1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,43 +22,103 @@ "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==" }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", + "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=" + }, "commander": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz", - "integrity": "sha1-/UMOiJgy7DU7ms0d4hfBHLPu+HM=" + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", + "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", + "requires": { + "graceful-readlink": ">= 1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, "debug": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", "requires": { - "ms": "0.7.1" + "ms": "2.0.0" } }, "diff": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz", - "integrity": "sha1-fyjS657nsVqX79ic5j3P2qPMur8=" + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz", + "integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=" }, "escape-string-regexp": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz", - "integrity": "sha1-Tbwv5nTnGUnK8/smlc5/LcHZqNE=" + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "glob": { - "version": "3.2.11", - "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", - "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", + "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", "inherits": "2", - "minimatch": "0.3" + "minimatch": "^3.0.2", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, + "graceful-readlink": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=" + }, "growl": { "version": "1.9.2", "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=" }, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=" + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, "inherits": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", @@ -69,44 +129,81 @@ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" }, - "jade": { - "version": "0.26.3", - "resolved": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz", - "integrity": "sha1-jxDXl32NefL2/4YqgbBRPMslaGw=", - "requires": { - "commander": "0.6.1", - "mkdirp": "0.3.0" - }, - "dependencies": { - "commander": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-0.6.1.tgz", - "integrity": "sha1-+mihT2qUXVTbvlDYzbMyDp47GgY=" - }, - "mkdirp": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz", - "integrity": "sha1-G79asbqCevI1dRQ0kEJkVfSB/h4=" - } - } + "json3": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz", + "integrity": "sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=" }, "jwt-decode": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-2.2.0.tgz", "integrity": "sha1-fYa9VmefWM5qhHBKZX3TkruoGnk=" }, - "lru-cache": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", - "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=" + "lodash._baseassign": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", + "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", + "requires": { + "lodash._basecopy": "^3.0.0", + "lodash.keys": "^3.0.0" + } + }, + "lodash._basecopy": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", + "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=" + }, + "lodash._basecreate": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz", + "integrity": "sha1-G8ZhYU2qf8MRt9A78WgGoCE8+CE=" + }, + "lodash._getnative": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", + "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=" + }, + "lodash._isiterateecall": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", + "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=" + }, + "lodash.create": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz", + "integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=", + "requires": { + "lodash._baseassign": "^3.0.0", + "lodash._basecreate": "^3.0.0", + "lodash._isiterateecall": "^3.0.0" + } + }, + "lodash.isarguments": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", + "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=" + }, + "lodash.isarray": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", + "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=" + }, + "lodash.keys": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", + "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", + "requires": { + "lodash._getnative": "^3.0.0", + "lodash.isarguments": "^3.0.0", + "lodash.isarray": "^3.0.0" + } }, "minimatch": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", - "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "requires": { - "lru-cache": "2", - "sigmund": "~1.0.0" + "brace-expansion": "^1.1.7" } }, "minimist": { @@ -123,26 +220,28 @@ } }, "mocha": { - "version": "2.5.3", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-2.5.3.tgz", - "integrity": "sha1-FhvlvetJZ3HrmzV0UFC2IrWu/Fg=", + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.3.tgz", + "integrity": "sha512-/6na001MJWEtYxHOV1WLfsmR4YIynkUEhBwzsb+fk2qmQ3iqsi258l/Q2MWHJMImAcNpZ8DEdYAK72NHoIQ9Eg==", "requires": { - "commander": "2.3.0", - "debug": "2.2.0", - "diff": "1.4.0", - "escape-string-regexp": "1.0.2", - "glob": "3.2.11", + "browser-stdout": "1.3.0", + "commander": "2.9.0", + "debug": "2.6.8", + "diff": "3.2.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.1", "growl": "1.9.2", - "jade": "0.26.3", + "he": "1.1.1", + "json3": "3.3.2", + "lodash.create": "3.1.1", "mkdirp": "0.5.1", - "supports-color": "1.2.0", - "to-iso-string": "0.0.2" + "supports-color": "3.1.2" } }, "ms": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, "nconf": { "version": "0.6.9", @@ -161,6 +260,14 @@ } } }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, "optimist": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.0.tgz", @@ -170,6 +277,11 @@ "wordwrap": "~0.0.2" } }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, "should": { "version": "11.2.1", "resolved": "https://registry.npmjs.org/should/-/should-11.2.1.tgz", @@ -218,20 +330,13 @@ "resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.0.tgz", "integrity": "sha1-yYzaN0qmsZDfi6h8mInCtNtiAGM=" }, - "sigmund": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", - "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=" - }, "supports-color": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.2.0.tgz", - "integrity": "sha1-/x7R5hFp0Gs88tWI4YixjYhH4X4=" - }, - "to-iso-string": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/to-iso-string/-/to-iso-string-0.0.2.tgz", - "integrity": "sha1-TcGeZk38y+Jb2NtQiwDG2hWCVdE=" + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz", + "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=", + "requires": { + "has-flag": "^1.0.0" + } }, "util": { "version": "0.10.3", @@ -246,6 +351,11 @@ "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=" }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, "ws": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/ws/-/ws-5.2.0.tgz",