diff --git a/src/ebms/reponseVerificationSysteme.js b/src/ebms/reponseVerificationSysteme.js index 4deeb7f..54893a2 100644 --- a/src/ebms/reponseVerificationSysteme.js +++ b/src/ebms/reponseVerificationSysteme.js @@ -23,6 +23,7 @@ class ReponseVerificationSysteme extends Message { return ` - - + + + + + + + EP + + + + + + + + + + + + + - - application/pdf - + + + ${this.adaptateurUUID?.genereUUID()} + + + DK/DE/123123123 + + + 1970-03-01 + + + + + + + + + https://sr.oots.tech.ec.europa.eu/evidencetypeclassifications/FR/12345678-1234-1234-1234-1234567890ab + + + + 1970-03-03 + + application/pdf + + + diff --git a/test/ebms/reponseVerificationSysteme.spec.js b/test/ebms/reponseVerificationSysteme.spec.js index 8c62d55..59381cb 100644 --- a/test/ebms/reponseVerificationSysteme.spec.js +++ b/test/ebms/reponseVerificationSysteme.spec.js @@ -1,3 +1,4 @@ +const { parseXML, valeurSlot, verifiePresenceSlot } = require('./utils'); const ReponseVerificationSysteme = require('../../src/ebms/reponseVerificationSysteme'); const PointAcces = require('../../src/ebms/pointAcces'); @@ -12,6 +13,75 @@ describe('Reponse Verification Systeme', () => { horodateur.maintenant = () => ''; }); + it('contient la description des méta-données de la pièce justificative', () => { + const reponse = new ReponseVerificationSysteme(config, donnees); + const xml = parseXML(reponse.corpsMessageEnXML()); + + const scopeRecherche = xml.QueryResponse.RegistryObjectList.RegistryObject; + verifiePresenceSlot('EvidenceMetadata', scopeRecherche); + + const evidence = valeurSlot('EvidenceMetadata', scopeRecherche).Evidence; + expect(evidence).toBeDefined(); + expect(evidence.Identifier).toBeDefined(); + expect(evidence.IsAbout).toBeDefined(); + expect(evidence.IsAbout.NaturalPerson).toBeDefined(); + expect(evidence.IsAbout.NaturalPerson.Identifier).toBeDefined(); // /!\ + expect(evidence.IsAbout.NaturalPerson.Identifier['@_schemeID']).toBe('eidas'); + expect(evidence.IsAbout.NaturalPerson.FamilyName).toBeDefined(); + expect(evidence.IsAbout.NaturalPerson.GivenName).toBeDefined(); + expect(evidence.IsAbout.NaturalPerson.DateOfBirth).toBeDefined(); + expect(evidence.IssuingAuthority).toBeDefined(); + expect(evidence.IssuingAuthority.Identifier).toBeDefined(); // /!\ + expect(evidence.IssuingAuthority.Identifier['@_schemeID']).toBe('urn:oasis:names:tc:ebcore:partyid-type:unregistered:FR'); + expect(evidence.IssuingAuthority.Name).toBeDefined(); + expect(evidence.IsConformantTo).toBeDefined(); + expect(evidence.IsConformantTo.EvidenceTypeClassification).toBeDefined(); + expect(evidence.IsConformantTo.Title).toBeDefined(); + expect(evidence.IsConformantTo.Title['@_lang']).toBe('EN'); + expect(evidence.IssuingDate).toBeDefined(); + expect(evidence.Distribution).toBeDefined(); + }); + + it("contient la description d'un fournisseur de pièces justificatives", () => { + const reponse = new ReponseVerificationSysteme(config, donnees); + const xml = parseXML(reponse.corpsMessageEnXML()); + + const scopeRecherche = xml.QueryResponse; + verifiePresenceSlot('EvidenceProvider', scopeRecherche); + + const fournisseur = valeurSlot('EvidenceProvider', scopeRecherche).Agent; + expect(fournisseur).toBeDefined(); + expect(fournisseur.Identifier).toBeDefined(); + expect(fournisseur.Identifier['@_schemeID']).toBe('urn:oasis:names:tc:ebcore:partyid-type:unregistered:FR'); + expect(fournisseur.Name).toBeDefined(); + expect(fournisseur.Classification).toBeDefined(); + expect(fournisseur.Classification).toBe('EP'); + }); + + it('contient la description du requêteur de la pièce justificative', () => { + const reponse = new ReponseVerificationSysteme(config, donnees); + const xml = parseXML(reponse.corpsMessageEnXML()); + + const scopeRecherche = xml.QueryResponse; + verifiePresenceSlot('EvidenceRequester', scopeRecherche); + + const requeteur = valeurSlot('EvidenceRequester', scopeRecherche).Agent; + expect(requeteur).toBeDefined(); + expect(requeteur.Identifier).toBeDefined(); + expect(requeteur.Identifier['@_schemeID']).toBeDefined(); // /!\ + expect(requeteur.Name).toBeDefined(); + }); + + it('injecte un identifiant unique de pièce justificative', () => { + adaptateurUUID.genereUUID = () => '11111111-1111-1111-1111-111111111111'; + const reponse = new ReponseVerificationSysteme(config, donnees); + const xml = parseXML(reponse.corpsMessageEnXML()); + const scopeRecherche = xml.QueryResponse.RegistryObjectList.RegistryObject; + + const idPiece = valeurSlot('EvidenceMetadata', scopeRecherche).Evidence.Identifier; + expect(idPiece).toEqual('11111111-1111-1111-1111-111111111111'); + }); + it('contient une pièce jointe', () => { adaptateurUUID.genereUUID = () => '12345678-abcd-abcd-abcd-123456789012'; const reponse = new ReponseVerificationSysteme(config, donnees); diff --git a/test/ebms/utils.js b/test/ebms/utils.js index 8f7b50b..4ccbf34 100644 --- a/test/ebms/utils.js +++ b/test/ebms/utils.js @@ -19,7 +19,12 @@ const valeurSlot = (nomSlot, scopeRecherche) => { const sectionSlots = scopeRecherche.Slot; const slots = [].concat(sectionSlots); const slot = slots.find((s) => s['@_name'] === nomSlot).SlotValue; - return (slot['@_type'] === 'rim:AnyValueType') ? slot : slot.Value; + + switch (slot['@_type']) { + case 'rim:AnyValueType': return slot; + case 'rim:CollectionValueType': return slot.Element; + default: return slot.Value; + } }; module.exports = { parseXML, verifiePresenceSlot, valeurSlot };