eslint: add no-floating-promises
This commit is contained in:
parent
e37184e5ee
commit
a98c06fa92
@ -81,7 +81,8 @@
|
|||||||
{
|
{
|
||||||
"accessibility": "explicit"
|
"accessibility": "explicit"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"@typescript-eslint/no-floating-promises": "error"
|
||||||
},
|
},
|
||||||
"ignorePatterns": [
|
"ignorePatterns": [
|
||||||
"jest.config.js",
|
"jest.config.js",
|
||||||
@ -106,4 +107,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -39,21 +39,19 @@ describe('Test CSRF protection', () => {
|
|||||||
test('no csrf token should be in session at first', (done) => {
|
test('no csrf token should be in session at first', (done) => {
|
||||||
const agent = supertest(app.getExpressApp());
|
const agent = supertest(app.getExpressApp());
|
||||||
agent.post('/')
|
agent.post('/')
|
||||||
.expect(401, (err, res) => {
|
.expect(401)
|
||||||
if (err) return done(err);
|
.then(res => {
|
||||||
|
|
||||||
expect(res.text).toContain(`You weren't assigned any CSRF token.`);
|
expect(res.text).toContain(`You weren't assigned any CSRF token.`);
|
||||||
cookies = res.get('Set-Cookie');
|
cookies = res.get('Set-Cookie');
|
||||||
|
|
||||||
agent.get('/')
|
agent.get('/')
|
||||||
.set('Cookie', cookies)
|
.set('Cookie', cookies)
|
||||||
.expect(200, (err, res) => {
|
.expect(200)
|
||||||
if (err) return done(err);
|
.then(res => {
|
||||||
|
|
||||||
csrf = res.text;
|
csrf = res.text;
|
||||||
done();
|
done();
|
||||||
});
|
}).catch(done.fail);
|
||||||
});
|
}).catch(done.fail);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sending no csrf token should fail', (done) => {
|
test('sending no csrf token should fail', (done) => {
|
||||||
@ -63,12 +61,10 @@ describe('Test CSRF protection', () => {
|
|||||||
agent.post('/')
|
agent.post('/')
|
||||||
.set('Cookie', cookies)
|
.set('Cookie', cookies)
|
||||||
.expect(401)
|
.expect(401)
|
||||||
.end((err, res) => {
|
.then((res) => {
|
||||||
if (err) return done(err);
|
|
||||||
|
|
||||||
expect(res.text).toContain(`You didn't provide any CSRF token.`);
|
expect(res.text).toContain(`You didn't provide any CSRF token.`);
|
||||||
done();
|
done();
|
||||||
});
|
}).catch(done.fail);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sending an invalid csrf token should fail', (done) => {
|
test('sending an invalid csrf token should fail', (done) => {
|
||||||
@ -79,12 +75,11 @@ describe('Test CSRF protection', () => {
|
|||||||
.set('Cookie', cookies)
|
.set('Cookie', cookies)
|
||||||
.set('Content-Type', 'application/json')
|
.set('Content-Type', 'application/json')
|
||||||
.send({csrf: 'not_a_valid_csrf'})
|
.send({csrf: 'not_a_valid_csrf'})
|
||||||
.expect(401, (err, res) => {
|
.expect(401)
|
||||||
if (err) return done(err);
|
.then(res => {
|
||||||
|
|
||||||
expect(res.text).toContain(`Tokens don't match.`);
|
expect(res.text).toContain(`Tokens don't match.`);
|
||||||
done();
|
done();
|
||||||
});
|
}).catch(done.fail);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sending a valid csrf token should success', (done) => {
|
test('sending a valid csrf token should success', (done) => {
|
||||||
@ -95,6 +90,8 @@ describe('Test CSRF protection', () => {
|
|||||||
.set('Cookie', cookies)
|
.set('Cookie', cookies)
|
||||||
.set('Content-Type', 'application/json')
|
.set('Content-Type', 'application/json')
|
||||||
.send({csrf: csrf})
|
.send({csrf: csrf})
|
||||||
.expect(200, done);
|
.expect(200)
|
||||||
|
.then(() => done())
|
||||||
|
.catch(done.fail);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user