Skip to content

Commit 29b61b3

Browse files
committed
Add tests for hiding private field review metadata when listing submissions
1 parent ded8d96 commit 29b61b3

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed

test/common/testData.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,23 @@ const testSubmissionsES = {
182182
type: 'ContestSubmission',
183183
updated: '2018-06-01T07:36:28.178Z',
184184
url: 'https://software.topcoder.com/review/actions/DownloadContestSubmission?uid=123458',
185+
review: [ {
186+
id: 'd24d4180-65aa-42ec-a945-5fd21dec0502',
187+
score: 92,
188+
reviewerId: 'c23a4180-65aa-42ec-a945-5fd21dec0503',
189+
submissionId: 'a12a4180-65aa-42ec-a945-5fd21dec0501',
190+
scoreCardId: 123456789,
191+
status: 'queued',
192+
metadata: {
193+
public: 'public data',
194+
private: 'private data'
195+
},
196+
typeId: 'c56a4180-65aa-42ec-a945-5fd21dec0501',
197+
created: '2018-05-20T07:00:30.123Z',
198+
updated: '2018-06-01T07:36:28.178Z',
199+
createdBy: 'admin',
200+
updatedBy: 'admin'
201+
} ],
185202
memberId: 'b24d4180-65aa-42ec-a945-5fd21dec0503' } },
186203
{ _index: 'submission',
187204
_type: '_doc',
@@ -196,6 +213,23 @@ const testSubmissionsES = {
196213
type: 'ContestSubmission',
197214
updated: '2018-06-01T07:36:28.178Z',
198215
url: 'https://software.topcoder.com/review/actions/DownloadContestSubmission?uid=123456',
216+
review: [ {
217+
id: 'd24d4180-65aa-42ec-a945-5fd21dec0502',
218+
score: 92,
219+
reviewerId: 'c23a4180-65aa-42ec-a945-5fd21dec0503',
220+
submissionId: 'a12a4180-65aa-42ec-a945-5fd21dec0501',
221+
scoreCardId: 123456789,
222+
status: 'queued',
223+
metadata: {
224+
public: 'public data',
225+
private: 'private data'
226+
},
227+
typeId: 'c56a4180-65aa-42ec-a945-5fd21dec0501',
228+
created: '2018-05-20T07:00:30.123Z',
229+
updated: '2018-06-01T07:36:28.178Z',
230+
createdBy: 'admin',
231+
updatedBy: 'admin'
232+
} ],
199233
memberId: 'b24d4180-65aa-42ec-a945-5fd21dec0501' } },
200234
{ _index: 'submission',
201235
_type: '_doc',
@@ -210,6 +244,23 @@ const testSubmissionsES = {
210244
type: 'ContestSubmission',
211245
updated: '2018-06-01T07:36:28.178Z',
212246
url: 'https://software.topcoder.com/review/actions/DownloadContestSubmission?uid=123457',
247+
review: [ {
248+
id: 'd24d4180-65aa-42ec-a945-5fd21dec0502',
249+
score: 92,
250+
reviewerId: 'c23a4180-65aa-42ec-a945-5fd21dec0503',
251+
submissionId: 'a12a4180-65aa-42ec-a945-5fd21dec0501',
252+
scoreCardId: 123456789,
253+
status: 'queued',
254+
metadata: {
255+
public: 'public data',
256+
private: 'private data'
257+
},
258+
typeId: 'c56a4180-65aa-42ec-a945-5fd21dec0501',
259+
created: '2018-05-20T07:00:30.123Z',
260+
updated: '2018-06-01T07:36:28.178Z',
261+
createdBy: 'admin',
262+
updatedBy: 'admin'
263+
} ],
213264
memberId: 'b24d4180-65aa-42ec-a945-5fd21dec0502' } },
214265
{ _index: 'submission',
215266
_type: '_doc',
@@ -224,6 +275,23 @@ const testSubmissionsES = {
224275
type: 'ContestSubmission',
225276
updated: '2018-06-01T07:36:28.178Z',
226277
url: 'https://software.topcoder.com/review/actions/DownloadContestSubmission?uid=123460',
278+
review: [ {
279+
id: 'd24d4180-65aa-42ec-a945-5fd21dec0502',
280+
score: 92,
281+
reviewerId: 'c23a4180-65aa-42ec-a945-5fd21dec0503',
282+
submissionId: 'a12a4180-65aa-42ec-a945-5fd21dec0501',
283+
scoreCardId: 123456789,
284+
status: 'queued',
285+
metadata: {
286+
public: 'public data',
287+
private: 'private data'
288+
},
289+
typeId: 'c56a4180-65aa-42ec-a945-5fd21dec0501',
290+
created: '2018-05-20T07:00:30.123Z',
291+
updated: '2018-06-01T07:36:28.178Z',
292+
createdBy: 'admin',
293+
updatedBy: 'admin'
294+
} ],
227295
memberId: 'b24d4180-65aa-42ec-a945-5fd21dec0505' } },
228296
{ _index: 'submission',
229297
_type: '_doc',
@@ -238,6 +306,23 @@ const testSubmissionsES = {
238306
type: 'ContestSubmission',
239307
updated: '2018-06-01T07:36:28.178Z',
240308
url: 'https://software.topcoder.com/review/actions/DownloadContestSubmission?uid=123459',
309+
review: [ {
310+
id: 'd24d4180-65aa-42ec-a945-5fd21dec0502',
311+
score: 92,
312+
reviewerId: 'c23a4180-65aa-42ec-a945-5fd21dec0503',
313+
submissionId: 'a12a4180-65aa-42ec-a945-5fd21dec0501',
314+
scoreCardId: 123456789,
315+
status: 'queued',
316+
metadata: {
317+
public: 'public data',
318+
private: 'private data'
319+
},
320+
typeId: 'c56a4180-65aa-42ec-a945-5fd21dec0501',
321+
created: '2018-05-20T07:00:30.123Z',
322+
updated: '2018-06-01T07:36:28.178Z',
323+
createdBy: 'admin',
324+
updatedBy: 'admin'
325+
} ],
241326
memberId: 'b24d4180-65aa-42ec-a945-5fd21dec0504' } } ]
242327

243328
}
@@ -253,6 +338,10 @@ const testReview = {
253338
submissionId: 'a12a4180-65aa-42ec-a945-5fd21dec0501',
254339
scoreCardId: 123456789,
255340
status: 'queued',
341+
metadata: {
342+
public: 'public data',
343+
private: 'private data'
344+
},
256345
typeId: 'c56a4180-65aa-42ec-a945-5fd21dec0501',
257346
created: '2018-05-20T07:00:30.123Z',
258347
updated: '2018-06-01T07:36:28.178Z',

test/unit/SubmissionService.test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,5 +560,41 @@ describe('Submission Service tests', () => {
560560
done()
561561
})
562562
})
563+
564+
it('Getting submissions with Admin token should include review.metadata.public and review.metadata.private', (done) => {
565+
chai.request(app)
566+
.get(`${config.API_VERSION}/submissions`)
567+
.set('Authorization', `Bearer ${config.ADMIN_TOKEN}`)
568+
.end((err, res) => {
569+
res.should.have.status(200)
570+
res.body.should.have.nested.property('[0].review[0].metdata.public')
571+
res.body.should.have.nested.property('[0].review[0].metdata.private')
572+
done()
573+
})
574+
})
575+
576+
it('Getting submissions with Copilot token should include review.metadata.public and review.metadata.private', (done) => {
577+
chai.request(app)
578+
.get(`${config.API_VERSION}/submissions`)
579+
.set('Authorization', `Bearer ${config.COPILOT_TOKEN}`)
580+
.end((err, res) => {
581+
res.should.have.status(200)
582+
res.body.should.have.nested.property('[0].review[0].metdata.public')
583+
res.body.should.have.nested.property('[0].review[0].metdata.private')
584+
done()
585+
})
586+
})
587+
588+
it('Getting submissions with User token should include review.metadata.public but not review.metadata.private', (done) => {
589+
chai.request(app)
590+
.get(`${config.API_VERSION}/submissions`)
591+
.set('Authorization', `Bearer ${config.USER_TOKEN}`)
592+
.end((err, res) => {
593+
res.should.have.status(200)
594+
res.body.should.have.nested.property('[0].review[0].metdata.public')
595+
res.body.should.not.have.nested.property('[0].review[0].metdata.private')
596+
done()
597+
})
598+
})
563599
})
564600
})

0 commit comments

Comments
 (0)