Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rends message de réponse conforme aux règles de validation #4

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 48 additions & 5 deletions src/ebms/reponseVerificationSysteme.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ReponseVerificationSysteme extends Message {
return `<query:QueryResponse
xmlns:query="urn:oasis:names:tc:ebxml-regrep:xsd:query:4.0"
xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:4.0"
xmlns:sdg="http://data.europa.eu/p4s"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
status="urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success"
Expand All @@ -46,15 +47,57 @@ class ReponseVerificationSysteme extends Message {
</rim:SlotValue>
</rim:Slot>

<rim:Slot name="EvidenceProvider"><!-- … --></rim:Slot>
<rim:Slot name="EvidenceRequester"><!-- … --></rim:Slot>
<rim:Slot name="EvidenceProvider">
<rim:SlotValue xsi:type="rim:CollectionValueType">
<rim:Element xsi:type="rim:AnyValueType">
<sdg:Agent>
<sdg:Identifier schemeID="urn:oasis:names:tc:ebcore:partyid-type:unregistered:FR"></sdg:Identifier>
<sdg:Name></sdg:Name>
<sdg:Classification>EP</sdg:Classification>
</sdg:Agent>
</rim:Element>
</rim:SlotValue>
</rim:Slot>

<rim:Slot name="EvidenceRequester">
<rim:SlotValue xsi:type="rim:AnyValueType">
<sdg:Agent>
<sdg:Identifier schemeID="urn:cef.eu:names:identifier:EAS:0096"></sdg:Identifier>
<sdg:Name></sdg:Name>
</sdg:Agent>
</rim:SlotValue>
</rim:Slot>

<rim:RegistryObjectList>
<rim:RegistryObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="rim:ExtrinsicObjectType" id="urn:uuid:0c37ed98-5774-407a-a056-21eeffe66712">
<rim:Slot name="EvidenceMetadata">
<sdg:Distribution>
<sdg:Format>application/pdf</sdg:Format>
</sdg:Distribution>
<rim:SlotValue xsi:type="rim:AnyValueType">
<sdg:Evidence>
<sdg:Identifier>${this.adaptateurUUID?.genereUUID()}</sdg:Identifier>
<sdg:IsAbout>
<sdg:NaturalPerson>
<sdg:Identifier schemeID='eidas'>DK/DE/123123123</sdg:Identifier>
<sdg:FamilyName></sdg:FamilyName>
<sdg:GivenName></sdg:GivenName>
<sdg:DateOfBirth>1970-03-01</sdg:DateOfBirth>
</sdg:NaturalPerson>
</sdg:IsAbout>
<sdg:IssuingAuthority>
<sdg:Identifier schemeID="urn:oasis:names:tc:ebcore:partyid-type:unregistered:FR"></sdg:Identifier>
<sdg:Name></sdg:Name>
</sdg:IssuingAuthority>
<sdg:IsConformantTo>
<sdg:EvidenceTypeClassification>
https://sr.oots.tech.ec.europa.eu/evidencetypeclassifications/FR/12345678-1234-1234-1234-1234567890ab
</sdg:EvidenceTypeClassification>
<sdg:Title lang="EN"></sdg:Title>
</sdg:IsConformantTo>
<sdg:IssuingDate>1970-03-03</sdg:IssuingDate>
<sdg:Distribution>
<sdg:Format>application/pdf</sdg:Format>
</sdg:Distribution>
</sdg:Evidence>
</rim:SlotValue>
</rim:Slot>
<rim:RepositoryItemRef xlink:href="${this.pieceJointe.identifiant}" xlink:title="Evidence"/>
</rim:RegistryObject>
Expand Down
70 changes: 70 additions & 0 deletions test/ebms/reponseVerificationSysteme.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { parseXML, valeurSlot, verifiePresenceSlot } = require('./utils');
const ReponseVerificationSysteme = require('../../src/ebms/reponseVerificationSysteme');
const PointAcces = require('../../src/ebms/pointAcces');

Expand All @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion test/ebms/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Loading