diff --git a/services/real-time/package-lock.json b/services/real-time/package-lock.json index 2fa57937eb..1541d23171 100644 --- a/services/real-time/package-lock.json +++ b/services/real-time/package-lock.json @@ -666,15 +666,6 @@ "type-detect": "0.1.1" } }, - "define-properties": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", - "integrity": "sha1-z4jabL7ib+bbcJT2HYcMvYTO6fE=", - "dev": true, - "requires": { - "object-keys": "^1.0.12" - } - }, "delay": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/delay/-/delay-4.3.0.tgz", @@ -700,6 +691,12 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, "dtrace-provider": { "version": "0.2.8", "resolved": "https://registry.npmjs.org/dtrace-provider/-/dtrace-provider-0.2.8.tgz", @@ -766,31 +763,6 @@ "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", "integrity": "sha1-6WQhkyWiHQX0RGai9obtbOX13R0=" }, - "es-abstract": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", - "integrity": "sha1-rIYUX91QmdjdSVWMy6Lq+biOJOk=", - "dev": true, - "requires": { - "es-to-primitive": "^1.2.0", - "function-bind": "^1.1.1", - "has": "^1.0.3", - "is-callable": "^1.1.4", - "is-regex": "^1.0.4", - "object-keys": "^1.0.12" - } - }, - "es-to-primitive": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", - "integrity": "sha1-7fckeAM0VujdqO8J4ArZZQcH83c=", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, "es6-promise": { "version": "4.2.8", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", @@ -1046,12 +1018,12 @@ } }, "formatio": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/formatio/-/formatio-1.1.1.tgz", - "integrity": "sha1-XtPM1jZVEJc4NGXZlhmRAOhhYek=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/formatio/-/formatio-1.2.0.tgz", + "integrity": "sha1-87IWfZBoxGmKjVH092CjmlTYGOs=", "dev": true, "requires": { - "samsam": "~1.1" + "samsam": "1.x" } }, "forwarded": { @@ -1070,12 +1042,6 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha1-pWiZ0+o8m6uHS7l3O3xe3pL0iV0=", - "dev": true - }, "gaxios": { "version": "1.8.4", "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-1.8.4.tgz", @@ -1189,21 +1155,6 @@ "har-schema": "^2.0.0" } }, - "has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha1-ci18v8H2qoJB8W3YFOAR4fQeh5Y=", - "dev": true, - "requires": { - "function-bind": "^1.1.1" - } - }, - "has-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", - "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", - "dev": true - }, "he": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", @@ -1323,53 +1274,11 @@ "resolved": "https://registry.npmjs.org/is/-/is-3.3.0.tgz", "integrity": "sha512-nW24QBoPcFGGHJGUwnfpI7Yc5CdqWNdsyHQszVE/z2pKHXzh7FZ5GWhJqSyaQ9wMkQnsTx+kAI8bHlCX4tKdbg==" }, - "is-arguments": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.0.4.tgz", - "integrity": "sha1-P6+WbHy6D/Q3+zH2JQCC/PBEjPM=", - "dev": true - }, "is-buffer": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==" }, - "is-callable": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", - "integrity": "sha1-HhrfIZ4e62hNaR+dagX/DTCiTXU=", - "dev": true - }, - "is-date-object": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", - "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", - "dev": true - }, - "is-generator-function": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.7.tgz", - "integrity": "sha1-0hMuUpuwAAp/gHlNS99c1eWBNSI=", - "dev": true - }, - "is-regex": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", - "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", - "dev": true, - "requires": { - "has": "^1.0.1" - } - }, - "is-symbol": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", - "integrity": "sha1-oFX2rlcZLK7jKeeoYBGLSXqVDzg=", - "dev": true, - "requires": { - "has-symbols": "^1.0.0" - } - }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -1503,9 +1412,9 @@ } }, "lolex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-1.3.2.tgz", - "integrity": "sha1-fD2mL/yzDw9agKJWbKJORdigHzE=", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-1.6.0.tgz", + "integrity": "sha1-OpoCg0UqR9dDnnJzG54H1zhuSfY=", "dev": true }, "long": { @@ -1730,6 +1639,12 @@ "integrity": "sha1-OSHhECMtHreQ89rGG7NwUxx9NW4=", "dev": true }, + "native-promise-only": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/native-promise-only/-/native-promise-only-0.8.1.tgz", + "integrity": "sha1-IKMYwwy0X3H+et+/eyHJnBRy7xE=", + "dev": true + }, "ncp": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", @@ -1756,24 +1671,6 @@ "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", "integrity": "sha1-R6ewFrqmi1+g7PPe4IqFxnmsZFU=" }, - "object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha1-HEfyct8nfzsdrwYWd9nILiMixg4=", - "dev": true - }, - "object.entries": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.0.tgz", - "integrity": "sha1-ICT8bWuiRq7ji9sP/Vz7zzcbdRk=", - "dev": true, - "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.12.0", - "function-bind": "^1.1.1", - "has": "^1.0.3" - } - }, "on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", @@ -2202,9 +2099,9 @@ "integrity": "sha1-RPoWGwGHuVSd2Eu5GAL5vYOFzWo=" }, "samsam": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.1.2.tgz", - "integrity": "sha1-vsEf3IOp/aBjQBIQ5AF2wwJNFWc=", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "sandboxed-module": { @@ -2299,15 +2196,42 @@ "integrity": "sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw==" }, "sinon": { - "version": "1.17.7", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-1.17.7.tgz", - "integrity": "sha1-RUKk9JugxFwF6y6d2dID4rjv4L8=", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-2.4.1.tgz", + "integrity": "sha512-vFTrO9Wt0ECffDYIPSP/E5bBugt0UjcBQOfQUMh66xzkyPEnhl/vM2LRZi2ajuTdkH07sA6DzrM6KvdvGIH8xw==", "dev": true, "requires": { - "formatio": "1.1.1", - "lolex": "1.3.2", - "samsam": "1.1.2", - "util": ">=0.10.3 <1" + "diff": "^3.1.0", + "formatio": "1.2.0", + "lolex": "^1.6.0", + "native-promise-only": "^0.8.1", + "path-to-regexp": "^1.7.0", + "samsam": "^1.1.3", + "text-encoding": "0.6.4", + "type-detect": "^4.0.0" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "path-to-regexp": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", + "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", + "dev": true, + "requires": { + "isarray": "0.0.1" + } + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + } } }, "socket.io": { @@ -2453,6 +2377,12 @@ } } }, + "text-encoding": { + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.6.4.tgz", + "integrity": "sha1-45mpgiV6J22uQou5KEXLcb3CbRk=", + "dev": true + }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -2554,27 +2484,6 @@ } } }, - "util": { - "version": "0.12.1", - "resolved": "https://registry.npmjs.org/util/-/util-0.12.1.tgz", - "integrity": "sha1-+QjntjPnOWx2TmlN0U5xYlbOit4=", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "is-arguments": "^1.0.4", - "is-generator-function": "^1.0.7", - "object.entries": "^1.1.0", - "safe-buffer": "^5.1.2" - }, - "dependencies": { - "safe-buffer": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", - "integrity": "sha1-t02uxJsRSPiMZLaNSbHoFcHy9Rk=", - "dev": true - } - } - }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/services/real-time/package.json b/services/real-time/package.json index ea3db675ce..1e20ac28fc 100644 --- a/services/real-time/package.json +++ b/services/real-time/package.json @@ -42,7 +42,7 @@ "chai": "~1.9.1", "cookie-signature": "^1.0.5", "sandboxed-module": "~0.3.0", - "sinon": "^1.5.2", + "sinon": "^2.4.1", "mocha": "^4.0.1", "uid-safe": "^1.0.1", "timekeeper": "0.0.4" diff --git a/services/real-time/test/unit/coffee/AuthorizationManagerTests.coffee b/services/real-time/test/unit/coffee/AuthorizationManagerTests.coffee index 9856684247..46b9e8be9a 100644 --- a/services/real-time/test/unit/coffee/AuthorizationManagerTests.coffee +++ b/services/real-time/test/unit/coffee/AuthorizationManagerTests.coffee @@ -27,19 +27,19 @@ describe 'AuthorizationManager', -> @AuthorizationManager.assertClientCanViewProject @client, (error) -> expect(error).to.be.null done() - + it "should allow the readAndWrite privilegeLevel", (done) -> @client.params.privilege_level = "readAndWrite" @AuthorizationManager.assertClientCanViewProject @client, (error) -> expect(error).to.be.null done() - + it "should allow the owner privilegeLevel", (done) -> @client.params.privilege_level = "owner" @AuthorizationManager.assertClientCanViewProject @client, (error) -> expect(error).to.be.null done() - + it "should return an error with any other privilegeLevel", (done) -> @client.params.privilege_level = "unknown" @AuthorizationManager.assertClientCanViewProject @client, (error) -> @@ -52,19 +52,19 @@ describe 'AuthorizationManager', -> @AuthorizationManager.assertClientCanEditProject @client, (error) -> error.message.should.equal "not authorized" done() - + it "should allow the readAndWrite privilegeLevel", (done) -> @client.params.privilege_level = "readAndWrite" @AuthorizationManager.assertClientCanEditProject @client, (error) -> expect(error).to.be.null done() - + it "should allow the owner privilegeLevel", (done) -> @client.params.privilege_level = "owner" @AuthorizationManager.assertClientCanEditProject @client, (error) -> expect(error).to.be.null done() - + it "should return an error with any other privilegeLevel", (done) -> @client.params.privilege_level = "unknown" @AuthorizationManager.assertClientCanEditProject @client, (error) -> @@ -84,20 +84,16 @@ describe 'AuthorizationManager', -> @client.params.privilege_level = "unknown" it "should not allow access", () -> - @AuthorizationManager.assertClientCanViewProjectAndDoc @client, @doc_id, @callback - @callback - .calledWith(new Error("not authorised")) - .should.equal true + @AuthorizationManager.assertClientCanViewProjectAndDoc @client, @doc_id, (err) -> + err.message.should.equal "not authorized" describe "even when authorised at the doc level", -> beforeEach (done) -> @AuthorizationManager.addAccessToDoc @client, @doc_id, done it "should not allow access", () -> - @AuthorizationManager.assertClientCanViewProjectAndDoc @client, @doc_id, @callback - @callback - .calledWith(new Error("not authorised")) - .should.equal true + @AuthorizationManager.assertClientCanViewProjectAndDoc @client, @doc_id, (err) -> + err.message.should.equal "not authorized" describe "when authorised at the project level", -> beforeEach () -> @@ -105,10 +101,8 @@ describe 'AuthorizationManager', -> describe "and not authorised at the document level", -> it "should not allow access", () -> - @AuthorizationManager.assertClientCanViewProjectAndDoc @client, @doc_id, @callback - @callback - .calledWith(new Error("not authorised")) - .should.equal true + @AuthorizationManager.assertClientCanViewProjectAndDoc @client, @doc_id, (err) -> + err.message.should.equal "not authorized" describe "and authorised at the document level", -> beforeEach (done) -> @@ -126,10 +120,8 @@ describe 'AuthorizationManager', -> @AuthorizationManager.removeAccessToDoc @client, @doc_id, done it "should deny access", () -> - @AuthorizationManager.assertClientCanViewProjectAndDoc @client, @doc_id, @callback - @callback - .calledWith(new Error("not authorised")) - .should.equal true + @AuthorizationManager.assertClientCanViewProjectAndDoc @client, @doc_id, (err) -> + err.message.should.equal "not authorized" describe "assertClientCanEditProjectAndDoc", -> beforeEach () -> @@ -142,20 +134,16 @@ describe 'AuthorizationManager', -> @client.params.privilege_level = "readOnly" it "should not allow access", () -> - @AuthorizationManager.assertClientCanEditProjectAndDoc @client, @doc_id, @callback - @callback - .calledWith(new Error("not authorised")) - .should.equal true + @AuthorizationManager.assertClientCanEditProjectAndDoc @client, @doc_id, (err) -> + err.message.should.equal "not authorized" describe "even when authorised at the doc level", -> beforeEach (done) -> @AuthorizationManager.addAccessToDoc @client, @doc_id, done it "should not allow access", () -> - @AuthorizationManager.assertClientCanEditProjectAndDoc @client, @doc_id, @callback - @callback - .calledWith(new Error("not authorised")) - .should.equal true + @AuthorizationManager.assertClientCanEditProjectAndDoc @client, @doc_id, (err) -> + err.message.should.equal "not authorized" describe "when authorised at the project level", -> beforeEach () -> @@ -163,10 +151,8 @@ describe 'AuthorizationManager', -> describe "and not authorised at the document level", -> it "should not allow access", () -> - @AuthorizationManager.assertClientCanEditProjectAndDoc @client, @doc_id, @callback - @callback - .calledWith(new Error("not authorised")) - .should.equal true + @AuthorizationManager.assertClientCanEditProjectAndDoc @client, @doc_id, (err) -> + err.message.should.equal "not authorized" describe "and authorised at the document level", -> beforeEach (done) -> @@ -184,7 +170,5 @@ describe 'AuthorizationManager', -> @AuthorizationManager.removeAccessToDoc @client, @doc_id, done it "should deny access", () -> - @AuthorizationManager.assertClientCanEditProjectAndDoc @client, @doc_id, @callback - @callback - .calledWith(new Error("not authorised")) - .should.equal true + @AuthorizationManager.assertClientCanEditProjectAndDoc @client, @doc_id, (err) -> + err.message.should.equal "not authorized" diff --git a/services/real-time/test/unit/coffee/WebApiManagerTests.coffee b/services/real-time/test/unit/coffee/WebApiManagerTests.coffee index a87522c0a9..e65ba93859 100644 --- a/services/real-time/test/unit/coffee/WebApiManagerTests.coffee +++ b/services/real-time/test/unit/coffee/WebApiManagerTests.coffee @@ -60,7 +60,7 @@ describe 'WebApiManager', -> it "should call the callback with an error", -> @callback - .calledWith(new Error("non-success code from web: 500")) + .calledWith(sinon.match({message: "non-success status code from web: 500"})) .should.equal true describe "with no data from web", -> @@ -70,7 +70,7 @@ describe 'WebApiManager', -> it "should call the callback with an error", -> @callback - .calledWith(new Error("no data returned from joinProject request")) + .calledWith(sinon.match({message: "no data returned from joinProject request"})) .should.equal true describe "when the project is over its rate limit", -> @@ -80,5 +80,5 @@ describe 'WebApiManager', -> it "should call the callback with a TooManyRequests error code", -> @callback - .calledWith(new CodedError("rate-limit hit when joining project", "TooManyRequests")) + .calledWith(sinon.match({message: "rate-limit hit when joining project", code: "TooManyRequests"})) .should.equal true diff --git a/services/real-time/test/unit/coffee/WebsocketControllerTests.coffee b/services/real-time/test/unit/coffee/WebsocketControllerTests.coffee index 79b22dbc81..498b425281 100644 --- a/services/real-time/test/unit/coffee/WebsocketControllerTests.coffee +++ b/services/real-time/test/unit/coffee/WebsocketControllerTests.coffee @@ -119,7 +119,7 @@ describe 'WebsocketController', -> it "should return an error", -> @callback - .calledWith(new Error("not authorized")) + .calledWith(sinon.match({message: "not authorized"})) .should.equal true it "should not log an error", -> @@ -143,7 +143,7 @@ describe 'WebsocketController', -> it "should return an error", -> @callback - .calledWith(new Error("subscribe failed")) + .calledWith(sinon.match({message: "subscribe failed"})) .should.equal true @callback.args[0][0].message.should.equal "subscribe failed" @@ -369,7 +369,7 @@ describe 'WebsocketController', -> @WebsocketController.joinDoc @client, @doc_id, -1, @options, @callback it "should call the callback with an error", -> - @callback.calledWith(@err).should.equal true + @callback.calledWith(sinon.match({message: "not authorized"})).should.equal true it "should not call the DocumentUpdaterManager", -> @DocumentUpdaterManager.getDocument.called.should.equal false