code cleanup: use URLSearchParams instead of querystring

This commit is contained in:
Alice Gaudon 2024-09-21 18:44:09 +02:00
parent aa059527ad
commit 558afedfb6
2 changed files with 6 additions and 9 deletions

View File

@ -1,4 +1,3 @@
import * as querystring from "querystring";
import supertest from "supertest";
import User from "../src/auth/models/User.js";
@ -142,7 +141,7 @@ describe('Register with email (magic_link)', () => {
const cookies = res.get('Set-Cookie') || [];
const csrf = res.text;
await agent.post('/auth/register?' + querystring.stringify({redirect_uri: '/redirect-uri'}))
await agent.post('/auth/register?' + new URLSearchParams({redirect_uri: '/redirect-uri'}).toString())
.set('Cookie', cookies)
.send({
csrf: csrf,
@ -303,7 +302,7 @@ describe('Authenticate with username and password (password)', () => {
expect(res.body.messages?.password?.name).toStrictEqual('InvalidFormatValidationError');
// Authenticate
await agent.post('/auth/login?' + querystring.stringify({redirect_uri: '/redirect-uri'}))
await agent.post('/auth/login?' + new URLSearchParams({redirect_uri: '/redirect-uri'}).toString())
.set('Cookie', cookies)
.send({
csrf: csrf,
@ -447,8 +446,7 @@ describe('Authenticate with email (magic_link)', () => {
await agent.get('/is-auth').set('Cookie', cookies).expect(401);
// Authenticate
// TODO deprecated querystring => URLSearchParams
await agent.post('/auth/login?' + querystring.stringify({redirect_uri: '/redirect-uri'}))
await agent.post('/auth/login?' + new URLSearchParams({redirect_uri: '/redirect-uri'}).toString())
.set('Cookie', cookies)
.send({
csrf: csrf,

View File

@ -1,4 +1,3 @@
import querystring from "querystring";
import supertest from "supertest";
import User from "../src/auth/models/User.js";
@ -66,7 +65,7 @@ describe('Register with email (magic_link)', () => {
const cookies = res.get('Set-Cookie') || [];
const csrf = res.text;
await agent.post('/auth/register?' + querystring.stringify({redirect_uri: '/redirect-uri'}))
await agent.post('/auth/register?' + new URLSearchParams({redirect_uri: '/redirect-uri'}).toString())
.set('Cookie', cookies)
.send({
csrf: csrf,
@ -113,7 +112,7 @@ describe('Authenticate with username and password (password)', () => {
await agent.get('/is-auth').set('Cookie', cookies).expect(401);
// Authenticate
await agent.post('/auth/login?' + querystring.stringify({redirect_uri: '/redirect-uri'}))
await agent.post('/auth/login?' + new URLSearchParams({redirect_uri: '/redirect-uri'}).toString())
.set('Cookie', cookies)
.send({
csrf: csrf,
@ -141,7 +140,7 @@ describe('Authenticate with email (magic_link)', () => {
await agent.get('/is-auth').set('Cookie', cookies).expect(401);
// Authenticate
await agent.post('/auth/login?' + querystring.stringify({redirect_uri: '/redirect-uri'}))
await agent.post('/auth/login?' + new URLSearchParams({redirect_uri: '/redirect-uri'}).toString())
.accept('json')
.set('Cookie', cookies)
.send({