diff --git a/services/real-time/app/coffee/WebsocketController.coffee b/services/real-time/app/coffee/WebsocketController.coffee index d2aef5b424..ad7825f595 100644 --- a/services/real-time/app/coffee/WebsocketController.coffee +++ b/services/real-time/app/coffee/WebsocketController.coffee @@ -117,7 +117,7 @@ module.exports = WebsocketController = AuthorizationManager.assertClientCanViewProjectAndDoc client, cursorData.doc_id, (error) -> if error? - logger.warn {client_id: client.id, project_id, user_id}, "silently ignoring unauthorized updateClientPosition. Client likely hasn't called joinProject yet." + logger.warn {err: error, client_id: client.id, project_id, user_id}, "silently ignoring unauthorized updateClientPosition. Client likely hasn't called joinProject yet." return callback() cursorData.id = client.id cursorData.user_id = user_id if user_id? diff --git a/services/real-time/test/acceptance/coffee/ClientTrackingTests.coffee b/services/real-time/test/acceptance/coffee/ClientTrackingTests.coffee index a602df52d2..dc00035382 100644 --- a/services/real-time/test/acceptance/coffee/ClientTrackingTests.coffee +++ b/services/real-time/test/acceptance/coffee/ClientTrackingTests.coffee @@ -15,22 +15,28 @@ describe "clientTracking", -> (cb) => FixturesManager.setUpProject { privilegeLevel: "owner" - project: { name: "Test Project" } + project: { name: "Test Project" } }, (error, {@user_id, @project_id}) => cb() + (cb) => + FixturesManager.setUpDoc @project_id, {@lines, @version, @ops}, (e, {@doc_id}) => + cb(e) + (cb) => @clientA = RealTimeClient.connect() - @clientA.on "connect", cb + @clientA.on "connectionAccepted", cb (cb) => @clientB = RealTimeClient.connect() - - @clientB.on "connect", cb + @clientB.on "connectionAccepted", cb (cb) => @clientA.emit "joinProject", { project_id: @project_id }, cb + + (cb) => + @clientA.emit "joinDoc", @doc_id, cb (cb) => @clientB.emit "joinProject", { @@ -45,7 +51,7 @@ describe "clientTracking", -> @clientA.emit "clientTracking.updatePosition", { row: @row = 42 column: @column = 36 - doc_id: @doc_id = "mock-doc-id" + doc_id: @doc_id }, (error) -> throw error if error? setTimeout cb, 300 # Give the message a chance to reach client B. @@ -85,9 +91,14 @@ describe "clientTracking", -> publicAccess: "readAndWrite" }, (error, {@user_id, @project_id}) => cb() + (cb) => + FixturesManager.setUpDoc @project_id, {@lines, @version, @ops}, (e, {@doc_id}) => + cb(e) + (cb) => @clientA = RealTimeClient.connect() - @clientA.on "connect", cb + @clientA.on "connectionAccepted", cb + (cb) => @clientA.emit "joinProject", { project_id: @project_id @@ -98,12 +109,15 @@ describe "clientTracking", -> (cb) => @anonymous = RealTimeClient.connect() - @anonymous.on "connect", cb + @anonymous.on "connectionAccepted", cb (cb) => @anonymous.emit "joinProject", { project_id: @project_id }, cb + + (cb) => + @anonymous.emit "joinDoc", @doc_id, cb (cb) => @updates = [] @@ -113,7 +127,7 @@ describe "clientTracking", -> @anonymous.emit "clientTracking.updatePosition", { row: @row = 42 column: @column = 36 - doc_id: @doc_id = "mock-doc-id" + doc_id: @doc_id }, (error) -> throw error if error? setTimeout cb, 300 # Give the message a chance to reach client B. diff --git a/services/real-time/test/acceptance/coffee/JoinProjectTests.coffee b/services/real-time/test/acceptance/coffee/JoinProjectTests.coffee index 920330b395..91b0c7102f 100644 --- a/services/real-time/test/acceptance/coffee/JoinProjectTests.coffee +++ b/services/real-time/test/acceptance/coffee/JoinProjectTests.coffee @@ -83,8 +83,7 @@ describe "joinProject", -> ], done it "should return an error", -> - # We don't return specific errors - @error.message.should.equal "Something went wrong" + @error.message.should.equal "not authorized" it "should not have joined the project room", (done) -> RealTimeClient.getConnectedClient @client.socket.sessionid, (error, client) =>