Skip to content

Commit

Permalink
fix(api): don't use InMemoryTemporaryStorage for integration tests
Browse files Browse the repository at this point in the history
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@
  • Loading branch information
3 people authored May 22, 2024
1 parent 092f6fb commit b2f47d6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"test:api": "for testType in 'unit' 'integration' 'acceptance'; do npm run test:api:$testType || status=1 ; done ; exit $status",
"test:api:path": "NODE_ENV=test mocha --exit --recursive --reporter=${MOCHA_REPORTER:-dot}",
"test:api:scripts": "npm run test:api:path -- tests/integration/scripts",
"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'",
"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'",
"test:api:integration": "npm run test:api:path -- 'tests/**/integration/**/*test.js'",
"test:api:acceptance": "npm run test:api:path -- 'tests/**/acceptance/**/*test.js'",
"test:api:debug": "NODE_ENV=test mocha --inspect-brk=9229 --recursive --exit --reporter dot tests",
Expand Down
3 changes: 2 additions & 1 deletion api/src/shared/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ const configuration = (function () {

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

config.temporaryStorage.redisUrl = null;
config.temporaryStorage.redisUrl = process.env.TEST_REDIS_URL;

config.saml.accessTokenLifespanMs = 1000;

Expand Down Expand Up @@ -448,6 +448,7 @@ const configuration = (function () {
config.logging.enableLogStartingEventDispatch = false;
config.logging.enableLogEndingEventDispatch = false;

// TODO: Rather use config.caching.redisUrl = process.env.TEST_REDIS_URL;
config.caching.redisUrl = null;
config.caching.redisCacheKeyLockTTL = 100;
config.caching.redisCacheLockedWaitBeforeRetry = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Integration | Identity Access Management | Domain | Service | fwb-oidc

// then
const expectedResult = await defaultSessionTemporaryStorage.get(key);
expect(expectedResult).to.be.undefined;
expect(expectedResult).to.be.null;

expect(redirectTarget).to.equal(
'https://logout-url.org/?id_token_hint=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('Integration | Identity Access Management | Domain | Services | pole-em

// then
const expectedResult = await defaultSessionTemporaryStorage.get(key);
expect(expectedResult).to.be.undefined;
expect(expectedResult).to.be.null;

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

0 comments on commit b2f47d6

Please sign in to comment.