Skip to content

Commit

Permalink
[Internal] Upgrade to lerna v8 (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
LoicPoullain committed Apr 25, 2024
1 parent c798cae commit 2f03539
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('The session store', () => {

beforeEach(() => {
// Use ".." to remove the "build/" directory.
Config.set('settings.session.store', './../node_modules/@foal/redis');
Config.set('settings.session.store', './../../../node_modules/@foal/redis');
Config.set('settings.session.secret', 'secret');
Config.set('settings.redis.uri', 'redis://localhost:6380');
serviceManager = new ServiceManager();
Expand Down
2 changes: 1 addition & 1 deletion packages/acceptance-tests/src/additional/typestack.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BaseEntity, Column, Entity, DataSource, PrimaryGeneratedColumn } from '
// FoalTS
import { Context, createApp, HttpResponseCreated, Post } from '@foal/core';
import { ValidateBody } from '@foal/typestack';
import { IsNumber, IsString } from '@foal/typestack/node_modules/class-validator';
import { IsNumber, IsString } from 'class-validator';
import { createAndInitializeDataSource } from '../common';

describe('ValidateBody hook', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ describe('Feature: Returning a response', () => {
.get('/')
.expect(200)
.then(response => {
strictEqual(response.get('Set-Cookie')[0].startsWith('sessionID=xxxx; Max-Age=3600; Domain=example.com; Path=/; '), true);
strictEqual(response.get('Set-Cookie')[0].endsWith('; HttpOnly; Secure; SameSite=Lax'), true);
strictEqual(response.get('Set-Cookie')?.[0].startsWith('sessionID=xxxx; Max-Age=3600; Domain=example.com; Path=/; '), true);
strictEqual(response.get('Set-Cookie')?.[0].endsWith('; HttpOnly; Secure; SameSite=Lax'), true);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('Feature: Signing cookies', () => {
.get('/set-cookie')
.expect(200)
.then(response => {
cookie1 = readCookie(response.get('Set-Cookie'), 'cookie1').value;
cookie1 = readCookie(response.get('Set-Cookie') || [], 'cookie1').value;
});

// Check that the value is signed (see cookie-parser spec.)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('Feature: Authenticating users in a stateful SPA using cookies', () =>
});

function setCookieInBrowser(response: request.Response): void {
token = readCookie(response.get('Set-Cookie'), cookieName).value;
token = readCookie(response.get('Set-Cookie') || [], cookieName).value;
}

beforeEach(() => response = undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe('Feature: Authenticating users in a statefull SSR application using coo
});

function setCookieInBrowser(response: request.Response): void {
token = readCookie(response.get('Set-Cookie'), cookieName).value;
token = readCookie(response.get('Set-Cookie') || [], cookieName).value;
}

beforeEach(() => response = undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe('Feature: Authenticating users in a stateless SPA using cookies', () =>
function setCookieInBrowser(response: request.Response): void {
try {
// There may not be a cookie in the response.
token = readCookie(response.get('Set-Cookie'), cookieName).value;
token = readCookie(response.get('Set-Cookie') || [], cookieName).value;
} catch {}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ describe('Feature: Adding authentication and access control', () => {
.set('Cookie', writeCookie('sessionID', session.getToken()))
.expect(401)
.then(response => {
const { value } = readCookie(response.get('Set-Cookie'), 'user');
const { value } = readCookie(response.get('Set-Cookie') || [], 'user');
strictEqual(value, 'null');
});

Expand All @@ -358,7 +358,7 @@ describe('Feature: Adding authentication and access control', () => {
{ id: product2.id }
])
.then(response => {
const { value } = readCookie(response.get('Set-Cookie'), 'user');
const { value } = readCookie(response.get('Set-Cookie') || [], 'user');
strictEqual(
value,
encodeURIComponent(JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('Feature: Do not Auto-Create the Session when using sessions with cooki
.expect(200);

strictEqual(alreadyExists, false);
strictEqual(response.get('Set-Cookie').length, 1);
strictEqual(response.get('Set-Cookie')?.length, 1);
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ describe('Feature: Overriding the cookie options', async () => {
.get('/')
.expect(200);

strictEqual(response.get('Set-Cookie')[0].startsWith('xxx='), true);
strictEqual(response.get('Set-Cookie')[0].includes('Domain=example.com'), true);
strictEqual(response.get('Set-Cookie')[0].includes('httpOnly'), false);
strictEqual(response.get('Set-Cookie')[0].includes('Path=/foo'), true);
strictEqual(response.get('Set-Cookie')[0].includes('SameSite=Lax'), true);
strictEqual(response.get('Set-Cookie')[0].includes('Secure;'), true);
strictEqual(response.get('Set-Cookie')?.[0].startsWith('xxx='), true);
strictEqual(response.get('Set-Cookie')?.[0].includes('Domain=example.com'), true);
strictEqual(response.get('Set-Cookie')?.[0].includes('httpOnly'), false);
strictEqual(response.get('Set-Cookie')?.[0].includes('Path=/foo'), true);
strictEqual(response.get('Set-Cookie')?.[0].includes('SameSite=Lax'), true);
strictEqual(response.get('Set-Cookie')?.[0].includes('Secure;'), true);
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('Feature: Using cookies', () => {
.get('/api/products')
.expect(200);

const token = readCookie(response.get('Set-Cookie'), cookieName).value;
const token = readCookie(response.get('Set-Cookie') || [], cookieName).value;

notStrictEqual(session, null);
strictEqual((session as unknown as Session).getToken(), token);
Expand All @@ -102,7 +102,7 @@ describe('Feature: Using cookies', () => {
.send({})
.expect(200);

const token2 = readCookie(response2.get('Set-Cookie'), cookieName).value;
const token2 = readCookie(response2.get('Set-Cookie') || [], cookieName).value;
strictEqual(token2, token);

});
Expand Down Expand Up @@ -143,7 +143,7 @@ describe('Feature: Using cookies', () => {
.get('/api/products')
.expect(200);

const token = readCookie(response.get('Set-Cookie'), cookieName).value;
const token = readCookie(response.get('Set-Cookie') || [], cookieName).value;

await request(app)
.get('/api/products')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// 3p
import { Contains, Length } from '@foal/typestack/node_modules/class-validator';
import { Contains, Length } from 'class-validator';
import * as request from 'supertest';

// FoalTS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// 3p
// The "ajv" and "ajv-errors" dependencies must reside in the same "node_modules/" directory.
import ajvErrors from '@foal/core/node_modules/ajv-errors';
import ajvErrors from 'ajv-errors';
import * as request from 'supertest';

// FoalTS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Feature: Disabling CSRF protection on a specific route.', () => {
await request(app)
.get('/')
.then(response => {
const { value } = readCookie(response.get('Set-Cookie'), 'sessionID');
const { value } = readCookie(response.get('Set-Cookie') || [], 'sessionID');
token = value;
});

Expand Down

0 comments on commit 2f03539

Please sign in to comment.