From 6d9f39b5a47c9f331c3782c60749a1f68ecddff3 Mon Sep 17 00:00:00 2001
From: vviers <vincent.viers@beta.gouv.fr>
Date: Tue, 22 Oct 2024 17:24:38 +0200
Subject: [PATCH] test: fix tests

---
 test/server/lib/OIDCConfig.ts | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/test/server/lib/OIDCConfig.ts b/test/server/lib/OIDCConfig.ts
index 17014896..1b423249 100644
--- a/test/server/lib/OIDCConfig.ts
+++ b/test/server/lib/OIDCConfig.ts
@@ -753,6 +753,7 @@ describe('OIDCConfig', () => {
 
   describe('getLogoutRedirectUrl', () => {
     const REDIRECT_URL = new URL('http://localhost:8484/docs/signed-out');
+    const STABLE_LOGOUT_URL = new URL('http://localhost:8484/signed-out');
     const URL_RETURNED_BY_CLIENT = 'http://localhost:8484/logout_url_from_issuer';
     const ENV_VALUE_GRIST_OIDC_IDP_END_SESSION_ENDPOINT = 'http://localhost:8484/logout';
     const FAKE_SESSION = {
@@ -778,14 +779,14 @@ describe('OIDCConfig', () => {
         itMsg: 'should call the end session endpoint with the expected parameters',
         expectedUrl: URL_RETURNED_BY_CLIENT,
         expectedLogoutParams: {
-          post_logout_redirect_uri: REDIRECT_URL.href,
+          post_logout_redirect_uri: STABLE_LOGOUT_URL.href,
           id_token_hint: FAKE_SESSION.oidc!.idToken,
         }
       }, {
         itMsg: 'should call the end session endpoint with no idToken if session is missing',
         expectedUrl: URL_RETURNED_BY_CLIENT,
         expectedLogoutParams: {
-          post_logout_redirect_uri: REDIRECT_URL.href,
+          post_logout_redirect_uri: STABLE_LOGOUT_URL.href,
           id_token_hint: undefined,
         },
         session: null
@@ -798,6 +799,9 @@ describe('OIDCConfig', () => {
         clientStub.endSessionUrl.returns(URL_RETURNED_BY_CLIENT);
         const config = await OIDCConfigStubbed.buildWithStub(clientStub.asClient());
         const req = {
+          headers: {
+            host: REDIRECT_URL.host
+          },
           session: 'session' in ctx ? ctx.session : FAKE_SESSION
         } as unknown as RequestWithLogin;
         const url = await config.getLogoutRedirectUrl(req, REDIRECT_URL);