-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transfère un jeton utilisateur lors de la récupération de document
- Loading branch information
Showing
6 changed files
with
65 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
const urlOOTS = (adaptateurEnvironnement) => `${adaptateurEnvironnement.urlBaseOOTSFrance()}/requete/pieceJustificative?codeDemarche=00&codePays=FR&idRequeteur=${adaptateurEnvironnement.identifiantRequeteur()}`; | ||
const urlOOTS = (config, requete) => { | ||
const { adaptateurChiffrement, adaptateurEnvironnement } = config; | ||
const { infosUtilisateur } = requete.session; | ||
const clePrivee = adaptateurEnvironnement.clePriveeJWK(); | ||
|
||
return adaptateurChiffrement.genereJWT(infosUtilisateur, clePrivee) | ||
.then((jeton) => { | ||
const requeteur = adaptateurEnvironnement.identifiantRequeteur(); | ||
const urlOOTSFrance = adaptateurEnvironnement.urlBaseOOTSFrance(); | ||
return `${urlOOTSFrance}/requete/pieceJustificative?codeDemarche=00&codePays=FR&idRequeteur=${requeteur}&utilisateur=${jeton}`; | ||
}); | ||
}; | ||
|
||
module.exports = urlOOTS; |
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,25 +1,45 @@ | ||
const urlOOTS = require('../../src/api/urlOOTS'); | ||
|
||
describe("Le constructeur de l'URL de requête OOTS-France", () => { | ||
describe('Le constructeur de l\'URL de requête OOTS-France', () => { | ||
const adaptateurChiffrement = {}; | ||
const adaptateurEnvironnement = {}; | ||
const requete = {}; | ||
|
||
beforeEach(() => { | ||
adaptateurEnvironnement.avecOOTS = () => true; | ||
adaptateurEnvironnement.clePriveeJWK = () => ''; | ||
adaptateurEnvironnement.urlBaseOOTSFrance = () => ''; | ||
adaptateurEnvironnement.identifiantRequeteur = () => ''; | ||
adaptateurChiffrement.genereJWT = () => Promise.resolve(); | ||
requete.session = { infosUtilisateur: {} }; | ||
}); | ||
|
||
it('retourne un lien vers OOTS', () => { | ||
adaptateurEnvironnement.urlBaseOOTSFrance = () => 'http://example.com'; | ||
const url = urlOOTS(adaptateurEnvironnement); | ||
|
||
expect(url).toMatch(/^http:\/\/example\.com.*/); | ||
urlOOTS( | ||
{ adaptateurChiffrement, adaptateurEnvironnement }, | ||
requete, | ||
).then((url) => expect(url).toMatch(/^http:\/\/example\.com.*/)); | ||
}); | ||
|
||
it("contient l'identifiant de requeteur", () => { | ||
it('contient l\'identifiant de requeteur', () => { | ||
adaptateurEnvironnement.identifiantRequeteur = () => 'un-identifiant'; | ||
const url = urlOOTS(adaptateurEnvironnement); | ||
urlOOTS( | ||
{ adaptateurChiffrement, adaptateurEnvironnement }, | ||
requete, | ||
).then((url) => expect(url).toContain('idRequeteur=un-identifiant')); | ||
}); | ||
|
||
it('contient le jeton utilisateur', () => { | ||
requete.session.infosUtilisateur = { prenom: 'Pierre', nom: 'Jax' }; | ||
adaptateurChiffrement.genereJWT = (infosutilisateur) => { | ||
expect(infosutilisateur).toStrictEqual({ prenom: 'Pierre', nom: 'Jax' }); | ||
return Promise.resolve('unJeton'); | ||
}; | ||
|
||
expect(url).toContain('idRequeteur=un-identifiant'); | ||
urlOOTS( | ||
{ adaptateurChiffrement, adaptateurEnvironnement }, | ||
requete, | ||
).then((url) => expect(url).toContain('unJeton')); | ||
}); | ||
}); |
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