diff --git a/services/web/app/coffee/Features/Editor/EditorHttpController.coffee b/services/web/app/coffee/Features/Editor/EditorHttpController.coffee index 72426b3ca8..846f3048a5 100644 --- a/services/web/app/coffee/Features/Editor/EditorHttpController.coffee +++ b/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 diff --git a/services/web/test/UnitTests/coffee/Editor/EditorHttpControllerTests.coffee b/services/web/test/UnitTests/coffee/Editor/EditorHttpControllerTests.coffee index a18bf61d84..fe00e13cb3 100644 --- a/services/web/test/UnitTests/coffee/Editor/EditorHttpControllerTests.coffee +++ b/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 =