-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: route de déconnexion (compat. france connect) (#926)
- Loading branch information
1 parent
02215c5
commit 7b85aef
Showing
29 changed files
with
159 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 1 addition & 8 deletions
9
src/domaines/authentification/authentifierUtilisateur.usecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/domaines/authentification/authentifierUtilisateurFranceConnect.usecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/domaines/authentification/deconnecterUtilisateur.usecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { SessionRepository } from '@/domaines/authentification/ports/session.repository'; | ||
import { UtilisateurRepository } from '@/domaines/authentification/ports/utilisateur.repository'; | ||
|
||
export class DeconnecterUtilisateurUsecase { | ||
constructor( | ||
private utilisateurRepository: UtilisateurRepository, | ||
private sessionRepository: SessionRepository, | ||
) {} | ||
|
||
async execute(utilisateurId: string): Promise<void> { | ||
await this.utilisateurRepository.deconnecterUtilisateur(utilisateurId); | ||
this.sessionRepository.deconnecterUtilisateur(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Utilisateur } from '@/domaines/authentification/ports/utilisateur.repository'; | ||
import { Score } from '@/domaines/score/ports/score.repository'; | ||
|
||
export interface SessionRepository { | ||
sauvegarderUtilisateur(utilisateur: Partial<Utilisateur>): void; | ||
|
||
sauvegarderScore(score: Score): void; | ||
|
||
deconnecterUtilisateur(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/domaines/authentification/validerAuthentificationUtilisateur.usecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/domaines/authentification/validerCompteUtilisateur.usecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/domaines/compte/validerOnboardingPostCreationCompte.usecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/domaines/profileUtilisateur/mettreAJourProfileUtilisateurUsecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
tests/authentification/authentifierUtilisateur.usecase.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { AuthentifierUtilisateurUsecase } from '@/domaines/authentification/authentifierUtilisateur.usecase'; | ||
import { SpyUtilisateurRepository } from './adapters/spyUtilisateurRepository'; | ||
import { UtilisateurRepositorySpy } from './adapters/utilisateur.repository.spy'; | ||
|
||
describe("Fichier de tests concernant l'authentification ", () => { | ||
it("Lorsque je passe un email et un mot de passe doit lancer le processus d'authentification", async () => { | ||
// GIVEN | ||
const spyUtilisateurRepository = new SpyUtilisateurRepository(); | ||
const spyUtilisateurRepository = new UtilisateurRepositorySpy(); | ||
const usecase = new AuthentifierUtilisateurUsecase(spyUtilisateurRepository); | ||
// WHEN | ||
await usecase.execute('[email protected]', '123'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
tests/authentification/deconnecterUtilisateur.usecase.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { DeconnecterUtilisateurUsecase } from '@/domaines/authentification/deconnecterUtilisateur.usecase'; | ||
import { UtilisateurRepositorySpy } from './adapters/utilisateur.repository.spy'; | ||
import { SpySauvegarderUtilisateurSessionRepository } from '../compte/sessionRepository.sauvegarderUtilisateur.spy'; | ||
import { expect } from 'vitest'; | ||
|
||
describe("Fichier de tests concernant la déconnexion d'un compte utilisateur", () => { | ||
it("L'utilisateur est déconnecté du service et sa session est terminée", async () => { | ||
// GIVEN | ||
const utilisateurRepository = new UtilisateurRepositorySpy(); | ||
const sessionRepository = SpySauvegarderUtilisateurSessionRepository.avecOnBoardingRealise({ | ||
id: 'id', | ||
mail: 'mail', | ||
prenom: 'prenom', | ||
nom: 'nom', | ||
}); | ||
|
||
// WHEN | ||
const usecase = new DeconnecterUtilisateurUsecase(utilisateurRepository, sessionRepository); | ||
await usecase.execute('utilisateurId'); | ||
|
||
// THEN | ||
expect(sessionRepository.utilisateur).toStrictEqual({ | ||
id: '', | ||
mail: '', | ||
prenom: '', | ||
nom: '', | ||
onboardingAEteRealise: false, | ||
afficherDisclaimerAides: false, | ||
}); | ||
expect(utilisateurRepository.utilisateurAEteDeco).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { Utilisateur } from '@/domaines/authentification/ports/utilisateur.repository'; | ||
import { SpySauvegarderUtilisateurSessionRepository } from '../compte/sessionRepository.sauvegarderUtilisateur.spy'; | ||
import { MockUtilisateurRepository } from './adapters/mockUtilisateurRepository'; | ||
import { UtilisateurRepositoryMock } from './adapters/utilisateur.repository.mock'; | ||
import { AuthentificationResultatPresenterImpl } from '@/domaines/authentification/adapters/authentificationResultatPresenterImpl'; | ||
import { ValiderAuthentificationUtilisateurUsecase } from '@/domaines/authentification/validerAuthentificationUtilisateur.usecase'; | ||
import { RouteComptePath } from '@/router/compte/routes'; | ||
|
@@ -13,14 +13,10 @@ describe("Fichier de tests concernant la validation de l'authentification de l'u | |
// WHEN | ||
const spySessionRepository = SpySauvegarderUtilisateurSessionRepository.sansOnBoardingRealise(); | ||
const usecase = new ValiderAuthentificationUtilisateurUsecase( | ||
new MockUtilisateurRepository(), | ||
new UtilisateurRepositoryMock(), | ||
spySessionRepository, | ||
); | ||
await usecase.execute( | ||
'[email protected]', | ||
'123456', | ||
new AuthentificationResultatPresenterImpl((viewModel: string) => {}), | ||
); | ||
await usecase.execute('[email protected]', '123456', new AuthentificationResultatPresenterImpl(() => {})); | ||
|
||
// THEN | ||
expect(spySessionRepository.utilisateur).toStrictEqual<Utilisateur>({ | ||
|
4 changes: 2 additions & 2 deletions
4
tests/authentification/validerCompteUtilisateur.usecase.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { ValiderCompteUtilisateurUsecase } from '@/domaines/authentification/validerCompteUtilisateur.usecase'; | ||
import { Utilisateur } from '@/domaines/authentification/ports/utilisateur.repository'; | ||
import { SpySauvegarderUtilisateurSessionRepository } from '../compte/sessionRepository.sauvegarderUtilisateur.spy'; | ||
import { MockUtilisateurRepository } from './adapters/mockUtilisateurRepository'; | ||
import { UtilisateurRepositoryMock } from './adapters/utilisateur.repository.mock'; | ||
|
||
describe('Fichier de tests concernant la validation du compte utilisateur', () => { | ||
it('En donnant un mail et un code doit valider le compte puis le sauvegarder en session', async () => { | ||
// GIVEN | ||
// WHEN | ||
const spySessionRepository = SpySauvegarderUtilisateurSessionRepository.sansOnBoardingRealise(); | ||
const usecase = new ValiderCompteUtilisateurUsecase(new MockUtilisateurRepository(), spySessionRepository); | ||
const usecase = new ValiderCompteUtilisateurUsecase(new UtilisateurRepositoryMock(), spySessionRepository); | ||
await usecase.execute('[email protected]', '123456'); | ||
// THEN | ||
expect(spySessionRepository.utilisateur).toStrictEqual<Utilisateur>({ | ||
|
Oops, something went wrong.