Skip to content

Commit

Permalink
Feature-flippe la route de destruction de session
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabinout committed May 16, 2024
1 parent 499bdaa commit ff8f70f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/routes/routesAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
11 changes: 11 additions & 0 deletions test/routes/routesAuth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit ff8f70f

Please sign in to comment.