fixed tests and package vulnerabilities
This commit is contained in:
@@ -106,16 +106,6 @@ describe('CSRF Middleware', () => {
|
||||
expect(res.status).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should validate token from query parameters', () => {
|
||||
req.query.csrfToken = 'mock-token-123';
|
||||
|
||||
csrfProtection(req, res, next);
|
||||
|
||||
expect(mockTokensInstance.verify).toHaveBeenCalledWith(process.env.CSRF_SECRET, 'mock-token-123');
|
||||
expect(next).toHaveBeenCalled();
|
||||
expect(res.status).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should prefer header token over body token', () => {
|
||||
req.headers['x-csrf-token'] = 'mock-token-123';
|
||||
req.body.csrfToken = 'different-token';
|
||||
@@ -126,25 +116,6 @@ describe('CSRF Middleware', () => {
|
||||
expect(next).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should prefer header token over query token', () => {
|
||||
req.headers['x-csrf-token'] = 'mock-token-123';
|
||||
req.query.csrfToken = 'different-token';
|
||||
|
||||
csrfProtection(req, res, next);
|
||||
|
||||
expect(mockTokensInstance.verify).toHaveBeenCalledWith(process.env.CSRF_SECRET, 'mock-token-123');
|
||||
expect(next).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should prefer body token over query token', () => {
|
||||
req.body.csrfToken = 'mock-token-123';
|
||||
req.query.csrfToken = 'different-token';
|
||||
|
||||
csrfProtection(req, res, next);
|
||||
|
||||
expect(mockTokensInstance.verify).toHaveBeenCalledWith(process.env.CSRF_SECRET, 'mock-token-123');
|
||||
expect(next).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Missing tokens', () => {
|
||||
|
||||
Reference in New Issue
Block a user