Skip to content

Commit 8d9345b

Browse files
committed
Allow submission delete for members
1 parent 35b3da8 commit 8d9345b

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/routes/SubmissionRoutes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module.exports = {
5050
controller: 'SubmissionController',
5151
method: 'deleteSubmission',
5252
auth: 'jwt',
53-
access: ['Administrator'],
53+
access: ['Topcoder User', 'Administrator', 'Copilot'],
5454
scopes: ['delete:submission', 'all:submission'],
5555
blockByIp: true
5656
}

test/unit/SubmissionService.test.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -470,16 +470,15 @@ describe('Submission Service tests', () => {
470470
})
471471
})
472472

473-
it('Deleting submission with user token should throw 403', (done) => {
473+
it('Deleting submission with User token should get succeeded', (done) => {
474474
chai.request(app)
475475
.delete(`${config.API_VERSION}/submissions/${testSubmission.Item.id}`)
476476
.set('Authorization', `Bearer ${config.USER_TOKEN}`)
477477
.end((err, res) => {
478-
res.should.have.status(403)
479-
res.body.message.should.be.eql('You are not allowed to perform this action!')
478+
res.should.have.status(204)
480479
done()
481480
})
482-
})
481+
}).timeout(10000)
483482

484483
it('Deleting non-existent submission should throw 404', (done) => {
485484
chai.request(app)
@@ -492,6 +491,16 @@ describe('Submission Service tests', () => {
492491
})
493492
})
494493

494+
it('Deleting submission with Copilot token should get succeeded', (done) => {
495+
chai.request(app)
496+
.delete(`${config.API_VERSION}/submissions/${testSubmission.Item.id}`)
497+
.set('Authorization', `Bearer ${config.COPILOT_TOKEN}`)
498+
.end((err, res) => {
499+
res.should.have.status(204)
500+
done()
501+
})
502+
}).timeout(10000)
503+
495504
it('Deleting submission with Admin token should get succeeded', (done) => {
496505
chai.request(app)
497506
.delete(`${config.API_VERSION}/submissions/${testSubmission.Item.id}`)

0 commit comments

Comments
 (0)