Explorar o código

server rejects rename of entitys over 150 chars

Henry Oswald %!s(int64=12) %!d(string=hai) anos
pai
achega
8789a4bde1

+ 2 - 0
services/web/app/coffee/Features/Editor/EditorHttpController.coffee

@@ -42,6 +42,8 @@ module.exports = EditorHttpController =
 		entity_id   = req.params.entity_id
 		entity_type = req.params.entity_type
 		name = req.body.name
+		if name.length > 150
+			return res.send 400
 		EditorController.renameEntity project_id, entity_id, entity_type, name, (error) ->
 			return next(error) if error?
 			res.send 204

+ 14 - 0
services/web/test/UnitTests/coffee/Editor/EditorHttpControllerTests.coffee

@@ -108,6 +108,20 @@ describe "EditorHttpController", ->
 		it "should send back a success response", ->
 			@res.send.calledWith(204).should.equal true
 
+	describe "renameEntity with long name", ->
+		beforeEach ->
+			@req.params =
+				Project_id: @project_id
+				entity_id: @entity_id = "entity-id-123"
+				entity_type: @entity_type = "entity-type"
+			@req.body =
+				name: @name = "EDMUBEEBKBXUUUZERMNSXFFWIBHGSDAWGMRIQWJBXGWSBVWSIKLFPRBYSJEKMFHTRZBHVKJSRGKTBHMJRXPHORFHAKRNPZGGYIOTEDMUBEEBKBXUUUZERMNSXFFWIBHGSDAWGMRIQWJBXGWSBVWSIKLFPRBYSJEKMFHTRZBHVKJSRGKTBHMJRXPHORFHAKRNPZGGYIOT"
+			@EditorController.renameEntity = sinon.stub().callsArg(4)
+			@EditorHttpController.renameEntity @req, @res
+
+		it "should send back a bad request status code", ->
+			@res.send.calledWith(400).should.equal true
+
 	describe "moveEntity", ->
 		beforeEach ->
 			@req.params =