James Allen 9 лет назад
Родитель
Сommit
4cff89becc

+ 1 - 1
services/real-time/app/coffee/WebsocketController.coffee

@@ -117,7 +117,7 @@ module.exports = WebsocketController =
 					
 					
 			AuthorizationManager.assertClientCanViewProjectAndDoc client, cursorData.doc_id, (error) ->
 			AuthorizationManager.assertClientCanViewProjectAndDoc client, cursorData.doc_id, (error) ->
 				if 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()
 					return callback()
 				cursorData.id      = client.id
 				cursorData.id      = client.id
 				cursorData.user_id = user_id if user_id?
 				cursorData.user_id = user_id if user_id?

+ 22 - 8
services/real-time/test/acceptance/coffee/ClientTrackingTests.coffee

@@ -15,22 +15,28 @@ describe "clientTracking", ->
 				(cb) =>
 				(cb) =>
 					FixturesManager.setUpProject {
 					FixturesManager.setUpProject {
 						privilegeLevel: "owner"
 						privilegeLevel: "owner"
-						project: { name: "Test Project"	}
+						project: { name: "Test Project" }
 					}, (error, {@user_id, @project_id}) => cb()
 					}, (error, {@user_id, @project_id}) => cb()
 				
 				
+				(cb) =>
+					FixturesManager.setUpDoc @project_id, {@lines, @version, @ops}, (e, {@doc_id}) =>
+						cb(e)
+				
 				(cb) =>
 				(cb) =>
 					@clientA = RealTimeClient.connect()
 					@clientA = RealTimeClient.connect()
-					@clientA.on "connect", cb
+					@clientA.on "connectionAccepted", cb
 					
 					
 				(cb) =>
 				(cb) =>
 					@clientB = RealTimeClient.connect()
 					@clientB = RealTimeClient.connect()
-						
-					@clientB.on "connect", cb	
+					@clientB.on "connectionAccepted", cb
 					
 					
 				(cb) =>
 				(cb) =>
 					@clientA.emit "joinProject", {
 					@clientA.emit "joinProject", {
 						project_id: @project_id
 						project_id: @project_id
 					}, cb
 					}, cb
+				
+				(cb) =>
+					@clientA.emit "joinDoc", @doc_id, cb
 					
 					
 				(cb) =>
 				(cb) =>
 					@clientB.emit "joinProject", {
 					@clientB.emit "joinProject", {
@@ -45,7 +51,7 @@ describe "clientTracking", ->
 					@clientA.emit "clientTracking.updatePosition", {
 					@clientA.emit "clientTracking.updatePosition", {
 						row: @row = 42
 						row: @row = 42
 						column: @column = 36
 						column: @column = 36
-						doc_id: @doc_id = "mock-doc-id"
+						doc_id: @doc_id
 					}, (error) ->
 					}, (error) ->
 						throw error if error?
 						throw error if error?
 						setTimeout cb, 300 # Give the message a chance to reach client B.
 						setTimeout cb, 300 # Give the message a chance to reach client B.
@@ -85,9 +91,14 @@ describe "clientTracking", ->
 						publicAccess: "readAndWrite"
 						publicAccess: "readAndWrite"
 					}, (error, {@user_id, @project_id}) => cb()
 					}, (error, {@user_id, @project_id}) => cb()
 				
 				
+				(cb) =>
+					FixturesManager.setUpDoc @project_id, {@lines, @version, @ops}, (e, {@doc_id}) =>
+						cb(e)
+				
 				(cb) =>
 				(cb) =>
 					@clientA = RealTimeClient.connect()
 					@clientA = RealTimeClient.connect()
-					@clientA.on "connect", cb
+					@clientA.on "connectionAccepted", cb
+
 				(cb) =>
 				(cb) =>
 					@clientA.emit "joinProject", {
 					@clientA.emit "joinProject", {
 						project_id: @project_id
 						project_id: @project_id
@@ -98,12 +109,15 @@ describe "clientTracking", ->
 					
 					
 				(cb) =>
 				(cb) =>
 					@anonymous = RealTimeClient.connect()
 					@anonymous = RealTimeClient.connect()
-					@anonymous.on "connect", cb	
+					@anonymous.on "connectionAccepted", cb	
 					
 					
 				(cb) =>
 				(cb) =>
 					@anonymous.emit "joinProject", {
 					@anonymous.emit "joinProject", {
 						project_id: @project_id
 						project_id: @project_id
 					}, cb
 					}, cb
+				
+				(cb) =>
+					@anonymous.emit "joinDoc", @doc_id, cb
 					
 					
 				(cb) =>
 				(cb) =>
 					@updates = []
 					@updates = []
@@ -113,7 +127,7 @@ describe "clientTracking", ->
 					@anonymous.emit "clientTracking.updatePosition", {
 					@anonymous.emit "clientTracking.updatePosition", {
 						row: @row = 42
 						row: @row = 42
 						column: @column = 36
 						column: @column = 36
-						doc_id: @doc_id = "mock-doc-id"
+						doc_id: @doc_id
 					}, (error) ->
 					}, (error) ->
 						throw error if error?
 						throw error if error?
 						setTimeout cb, 300 # Give the message a chance to reach client B.
 						setTimeout cb, 300 # Give the message a chance to reach client B.

+ 1 - 2
services/real-time/test/acceptance/coffee/JoinProjectTests.coffee

@@ -83,8 +83,7 @@ describe "joinProject", ->
 			], done
 			], done
 		
 		
 		it "should return an error", ->
 		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) ->
 		it "should not have joined the project room", (done) ->
 			RealTimeClient.getConnectedClient @client.socket.sessionid, (error, client) =>
 			RealTimeClient.getConnectedClient @client.socket.sessionid, (error, client) =>