Skip to content

Commit b2f47d6

Browse files
lego-technixigorissener-lim
authored
fix(api): don't use InMemoryTemporaryStorage for integration tests
rather use RedisTemporaryStorage instead, which is the true infrastructure component used in production. Co-authored-by: Ismael Gorissen <[email protected]> Co-authored-by: LEGO Technix <[email protected]> Co-authored-by: Eric Lim <[email protected]> Co-authored-by: Emmanuelle Bonnemay <emmanuelle.bonnemay@
1 parent 092f6fb commit b2f47d6

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
"test:api": "for testType in 'unit' 'integration' 'acceptance'; do npm run test:api:$testType || status=1 ; done ; exit $status",
160160
"test:api:path": "NODE_ENV=test mocha --exit --recursive --reporter=${MOCHA_REPORTER:-dot}",
161161
"test:api:scripts": "npm run test:api:path -- tests/integration/scripts",
162-
"test:api:unit": "TEST_DATABASE_URL=postgres://should.not.reach.db.in.unit.tests REDIS_URL= npm run test:api:path -- 'tests/**/unit/**/*test.js'",
162+
"test:api:unit": "TEST_DATABASE_URL=postgres://should.not.reach.db.in.unit.tests TEST_REDIS_URL= npm run test:api:path -- 'tests/**/unit/**/*test.js'",
163163
"test:api:integration": "npm run test:api:path -- 'tests/**/integration/**/*test.js'",
164164
"test:api:acceptance": "npm run test:api:path -- 'tests/**/acceptance/**/*test.js'",
165165
"test:api:debug": "NODE_ENV=test mocha --inspect-brk=9229 --recursive --exit --reporter dot tests",

api/src/shared/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ const configuration = (function () {
393393

394394
config.temporaryKey.secret = 'the-password-must-be-at-least-32-characters-long';
395395

396-
config.temporaryStorage.redisUrl = null;
396+
config.temporaryStorage.redisUrl = process.env.TEST_REDIS_URL;
397397

398398
config.saml.accessTokenLifespanMs = 1000;
399399

@@ -448,6 +448,7 @@ const configuration = (function () {
448448
config.logging.enableLogStartingEventDispatch = false;
449449
config.logging.enableLogEndingEventDispatch = false;
450450

451+
// TODO: Rather use config.caching.redisUrl = process.env.TEST_REDIS_URL;
451452
config.caching.redisUrl = null;
452453
config.caching.redisCacheKeyLockTTL = 100;
453454
config.caching.redisCacheLockedWaitBeforeRetry = 1;

api/tests/identity-access-management/integration/domain/services/fwb-oidc-authentication-service_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('Integration | Identity Access Management | Domain | Service | fwb-oidc
3232

3333
// then
3434
const expectedResult = await defaultSessionTemporaryStorage.get(key);
35-
expect(expectedResult).to.be.undefined;
35+
expect(expectedResult).to.be.null;
3636

3737
expect(redirectTarget).to.equal(
3838
'https://logout-url.org/?id_token_hint=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',

api/tests/identity-access-management/integration/domain/services/pole-emploi-oidc-authentication-service_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ describe('Integration | Identity Access Management | Domain | Services | pole-em
8787

8888
// then
8989
const expectedResult = await defaultSessionTemporaryStorage.get(key);
90-
expect(expectedResult).to.be.undefined;
90+
expect(expectedResult).to.be.null;
9191

9292
expect(redirectTarget).to.equal(
9393
'https://logout-url.fr/?id_token_hint=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c&redirect_uri=https%3A%2F%2Fafter-logout.fr',

0 commit comments

Comments
 (0)