Account for ranges in large json payloads and add line-count limit
This commit is contained in:
@@ -15,6 +15,7 @@ describe "HttpController", ->
|
||||
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() }
|
||||
"./HealthChecker": {}
|
||||
@res = { send: sinon.stub(), json: sinon.stub(), setHeader:sinon.stub() }
|
||||
@res.status = sinon.stub().returns(@res)
|
||||
@req = { query:{}}
|
||||
@next = sinon.stub()
|
||||
@project_id = "mock-project-id"
|
||||
@@ -292,6 +293,20 @@ describe "HttpController", ->
|
||||
.calledWith(400)
|
||||
.should.equal true
|
||||
|
||||
describe "when the doc body is too large", ->
|
||||
beforeEach ->
|
||||
@req.body =
|
||||
lines: @lines = Array(2049).fill('a'.repeat(1024))
|
||||
version: @version = 42
|
||||
ranges: @ranges = { changes: "mock" }
|
||||
@HttpController.updateDoc @req, @res, @next
|
||||
|
||||
it "should return a 413 (too large) response", ->
|
||||
sinon.assert.calledWith(@res.status, 413)
|
||||
|
||||
it "should report that the document body is too large", ->
|
||||
sinon.assert.calledWith(@res.send, "document body too large")
|
||||
|
||||
describe "deleteDoc", ->
|
||||
beforeEach ->
|
||||
@req.params =
|
||||
|
||||
Reference in New Issue
Block a user