Skip to content

Commit

Permalink
bug: need to return 401 rather than 403 on OpenRosa submission endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
issa-tseng committed Aug 12, 2020
1 parent 0d7e73f commit 7b13eb7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/resources/submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ module.exports = (service, endpoint) => {
// now we have the information we need to get the correct form; do so
// and make sure we can actually submit to it.
.then((partial) => getForm(auth, params, partial.xmlFormId, Form, partial.version)
// for openrosa endpoints, we must return 401 rather than 403.
.catch(Problem.translate(Problem.user.insufficientRights, Problem.user.authenticationFailed))
.then((form) => Promise.all([
Submission.getById(form.id, partial.instanceId, draft, QueryOptions.extended),
form.def.getBinaryFields()
Expand Down
2 changes: 1 addition & 1 deletion test/integration/api/submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('api: /submission', () => {
service.post('/v1/projects/1/submission')
.set('X-OpenRosa-Version', '1.0')
.attach('xml_submission_file', Buffer.from(testData.instances.simple.one), { filename: 'data.xml' })
.expect(403)));
.expect(401)));

it('should reject if the form is not taking submissions', testService((service) =>
service.login('alice', (asAlice) =>
Expand Down

0 comments on commit 7b13eb7

Please sign in to comment.