server rejects project names over 150 chars

This commit is contained in:
Henry Oswald 2014-10-07 11:14:02 +01:00
parent 28b1e6bfe5
commit b01b05e49b
2 changed files with 9 additions and 0 deletions

View file

@ -109,6 +109,8 @@ module.exports = ProjectController =
renameProject: (req, res)-> renameProject: (req, res)->
project_id = req.params.Project_id project_id = req.params.Project_id
newName = req.body.newProjectName newName = req.body.newProjectName
if newName.length > 150
return res.send 400
editorController.renameProject project_id, newName, (err)-> editorController.renameProject project_id, newName, (err)->
if err? if err?
logger.err err:err, project_id:project_id, newName:newName, "problem renaming project" logger.err err:err, project_id:project_id, newName:newName, "problem renaming project"

View file

@ -252,6 +252,13 @@ describe "ProjectController", ->
done() done()
@ProjectController.renameProject @req, @res @ProjectController.renameProject @req, @res
it "should return an error if the name is over 150 chars", (done)->
@req.body.newProjectName = "EDMUBEEBKBXUUUZERMNSXFFWIBHGSDAWGMRIQWJBXGWSBVWSIKLFPRBYSJEKMFHTRZBHVKJSRGKTBHMJRXPHORFHAKRNPZGGYIOTEDMUBEEBKBXUUUZERMNSXFFWIBHGSDAWGMRIQWJBXGWSBVWSIKLFPRBYSJEKMFHTRZBHVKJSRGKTBHMJRXPHORFHAKRNPZGGYIOT"
@res.send = (code)=>
code.should.equal 400
done()
@ProjectController.renameProject @req, @res
describe "loadEditor", -> describe "loadEditor", ->
beforeEach -> beforeEach ->
@settings.editorIsOpen = true @settings.editorIsOpen = true