From ff8f70fe70964008cdc4deab5c1bcf676dd443dc Mon Sep 17 00:00:00 2001 From: Fabien Lamarque Date: Thu, 16 May 2024 14:25:38 +0000 Subject: [PATCH] Feature-flippe la route de destruction de session --- src/routes/routesAuth.js | 26 +++++++++++++++----------- test/routes/routesAuth.spec.js | 11 +++++++++++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/routes/routesAuth.js b/src/routes/routesAuth.js index 4a5ff81..8674a1b 100644 --- a/src/routes/routesAuth.js +++ b/src/routes/routesAuth.js @@ -55,17 +55,21 @@ const routesAuth = (config) => { deconnexionFCPlus(requete, reponse) )); - routes.get('/fcplus/destructionSession', (...args) => middleware.renseigneUtilisateurCourant(...args), (requete, reponse) => ( - destructionSessionFCPlus( - { - adaptateurChiffrement, - adaptateurEnvironnement, - adaptateurFranceConnectPlus, - }, - requete, - reponse, - ) - )); + routes.get('/fcplus/destructionSession', (...args) => middleware.renseigneUtilisateurCourant(...args), (requete, reponse) => { + if (adaptateurEnvironnement.avecConnexionFCPlus()) { + destructionSessionFCPlus( + { + adaptateurChiffrement, + adaptateurEnvironnement, + adaptateurFranceConnectPlus, + }, + requete, + reponse, + ); + } else { + reponse.status(501).send('Not Implemented Yet!'); + } + }); routes.get('/fcplus/creationSession', (requete, reponse) => { if (adaptateurEnvironnement.avecConnexionFCPlus()) { diff --git a/test/routes/routesAuth.spec.js b/test/routes/routesAuth.spec.js index f3c601c..7c1f914 100644 --- a/test/routes/routesAuth.spec.js +++ b/test/routes/routesAuth.spec.js @@ -118,6 +118,17 @@ describe('Le serveur des routes `/auth`', () => { .then((reponse) => expect(reponse.request.path).toContain('id_token_hint=abcdef')) .catch(leveErreur); }); + + it('retourne une erreur 501 si le feature-flipping est désactivé', () => { + expect.assertions(1); + + serveur.adaptateurEnvironnement().avecConnexionFCPlus = () => false; + + return axios.get(`http://localhost:${port}/auth/fcplus/creationSession`) + .catch(({ response }) => { + expect(response.status).toEqual(501); + }); + }); }); describe('sur GET /auth/fcplus/creationSession', () => {