Skip to content

Commit 39af3ef

Browse files
committed
fix todos from review
1 parent 3b334c1 commit 39af3ef

File tree

4 files changed

+9
-24
lines changed

4 files changed

+9
-24
lines changed

test/e2e/LangsScenario.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ describe('GET api/langs', () => {
3030
it('should throw 403 error API key is absent in the request', async () => {
3131
const res = await chai.request(app).get(`/api/langs`);
3232
expect(res.status).to.equal(403);
33-
// TODO this should be res.body.err maybe? (consistent with other error)
3433
expect(res.body.message).to.equal('No API Key in request');
3534
});
3635

@@ -41,7 +40,6 @@ describe('GET api/langs', () => {
4140
});
4241
expect(res.status).to.equal(403);
4342
expect(res.body.message).to.equal('Invalid API Key');
44-
// maybe 400 error?
4543
});
4644

4745
it('should throw 404 error if POST request is made', async () => {

test/e2e/RunScenario.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ describe('POST api/runs', () => {
4747

4848

4949
it('should throw 403 error if API Key is absent', async () => {
50-
// shouldn't this be bad request 400?
5150

5251
const res = await chai.request(app).post(`/api/runs`);
5352

test/unit/validators/ApiKeyValidator.spec.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
import * as utils from '../../utils/utils';
23
import {checkValidApiKey} from '../../../src/validators/ApiKeyValidators';
34
import {Request} from 'express'
@@ -20,7 +21,6 @@ describe('API Key Validtors', async () => {
2021
afterEach(utils.truncateTables);
2122

2223
it('should reject an invalid api', () => {
23-
// @ts-ignore
2424
const req: Request = {
2525
header(name): any {
2626
if (name === 'Authorization') {
@@ -33,7 +33,6 @@ describe('API Key Validtors', async () => {
3333
});
3434

3535
it('should reject no api', () => {
36-
// @ts-ignore
3736
const req: Request = {
3837
header(name): any {
3938
}
@@ -48,7 +47,6 @@ describe('API Key Validtors', async () => {
4847
{key: currentKey}
4948
]);
5049

51-
// @ts-ignore
5250
const req: Request = {
5351
header(name): any {
5452
if (name === 'Authorization') {
@@ -68,15 +66,13 @@ describe('API Key Validtors', async () => {
6866
{key: currentKey, whitelist_ips: [remoteAddress]}
6967
]);
7068

71-
// @ts-ignore
7269
const req: Request = {
7370
header(name): any {
7471
if (name === 'Authorization') {
7572
return `Bearer ${currentKey}`
7673
}
7774
}
7875
};
79-
// @ts-ignore
8076
req.connection = {
8177
remoteAddress
8278
};
@@ -92,7 +88,6 @@ describe('API Key Validtors', async () => {
9288
whitelist_domains: ['Referer']
9389
});
9490

95-
// @ts-ignore
9691
const req: Request = {
9792
header(name): any {
9893
if (name === 'Authorization') {
@@ -106,7 +101,6 @@ describe('API Key Validtors', async () => {
106101
});
107102

108103
it('should NOT reject api with whitelist ip/domain as "*"', async () => {
109-
// @ts-ignore
110104
const req: Request = {
111105
header(name): any {
112106
if (name === 'Authorization') {

test/unit/validators/RunValidator.spec.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('RunValidator', async () => {
9191
expect(nextSpy.calledOnce).to.be.false;
9292
});
9393

94-
it('should throw an error when mode is missing', async () => {
94+
it('should NOT throw an error when mode is missing', async () => {
9595
const req = {
9696
body: {
9797
source: 'LKJSDFKLMC414CcnBcba12',
@@ -101,10 +101,8 @@ describe('RunValidator', async () => {
101101
};
102102

103103
await runValidator.POST(req, res, nextSpy);
104-
// TODO
105-
// does not throw error for mode missing
104+
106105
expect(nextSpy.calledOnce).to.be.true;
107-
// nextSpy is true === next() was called
108106
});
109107

110108
it('should throw an error when mode is NOT string', async () => {
@@ -118,10 +116,8 @@ describe('RunValidator', async () => {
118116
};
119117

120118
await runValidator.POST(req, res, nextSpy);
121-
// TODO
119+
122120
expect(nextSpy.calledOnce).to.be.false;
123-
// error thrown == " mode" must be one of [sync, callback, poll]
124-
// but should've been "mode" must be string
125121
});
126122

127123
it('should throw an error when mode is not one of "callback, poll, sync"', async () => {
@@ -136,7 +132,7 @@ describe('RunValidator', async () => {
136132

137133

138134
await runValidator.POST(req, res, nextSpy);
139-
// TODO
135+
140136
expect(nextSpy.calledOnce).to.be.false;
141137
expect(sentData.err.message).to.equal('"mode" must be one of [sync, callback, poll]');
142138
});
@@ -193,17 +189,15 @@ describe('RunValidator', async () => {
193189
lang: 'cpp',
194190
mode: 'poll',
195191
stdin: '',
196-
timelimit: '123'
192+
timelimit: 'abc'
197193
}
198194
};
199195

200196
await runValidator.POST(req, res, nextSpy);
201197

202-
// TODO fix this. CODE is wrong
203-
expect(nextSpy.calledOnce).to.be.true;
204-
// expect(sentStatus).to.be.equal(400);
205-
// expect(sentData.err.message).to.equal('"timelimit" must be an integer');
206-
// expect(nextSpy.calledOnce).to.be.false;
198+
expect(sentStatus).to.be.equal(400);
199+
expect(sentData.err.message).to.equal('"timelimit" must be a number');
200+
expect(nextSpy.calledOnce).to.be.false;
207201
});
208202

209203
it('should throw error if mode is callback and callback is missing', async () => {

0 commit comments

Comments
 (0)