Skip to content

Commit

Permalink
test: verify huge XSD schema works
Browse files Browse the repository at this point in the history
Verifies #44
  • Loading branch information
VanguardaSistemas authored and nikku committed Jan 23, 2025
1 parent 372a2ea commit a884ec4
Show file tree
Hide file tree
Showing 7 changed files with 3,329 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/mdfe-invalid.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><MDFe xmlns="http://www.portalfiscal.inf.br/mdfe"><infMDFe versao="3.00" Id="MDFe42250134475274000159580010000000351178611677"><ide><cUF>42</cUF><tpAmb>2</tpAmb><tpEmit>2</tpEmit><tpTransp></tpTransp><mod>58</mod><serie>1</serie><nMDF>35</nMDF><cMDF>17861167</cMDF><cDV>7</cDV><modal>1</modal><dhEmi>2025-01-21T10:20:11-03:00</dhEmi><tpEmis>1</tpEmis><procEmi>0</procEmi><verProc>v4.7.4</verProc><UFIni>SC</UFIni><UFFim>SC</UFFim><infMunCarrega><cMunCarrega>4202909</cMunCarrega><xMunCarrega>Brusque</xMunCarrega></infMunCarrega><indCarregaPosterior>0</indCarregaPosterior></ide><emit><CNPJ>34475274000159</CNPJ><IE>260188328</IE><xNome>EMPRESA TESTE SISTEMA (NR)</xNome><xFant>EMPRESA TESTE SISTEMA</xFant><enderEmit><xLgr>Rua Fake de Teste</xLgr><nro>999</nro><xBairro>Bairro Fake</xBairro><cMun>4202909</cMun><xMun>Brusque</xMun><CEP>79303061</CEP><UF>SC</UF><fone>47991887700</fone></enderEmit></emit><infModal versaoModal="3.00"><rodo><infANTT><infContratante><CNPJ>34475274000159</CNPJ></infContratante></infANTT><veicTracao><placa>KDJ9910</placa><tara>7500</tara><RENAVAM>12345678901</RENAVAM><capKG>10000</capKG><capM3>500</capM3><condutor><xNome>JOAZINHO DA SILVA</xNome><CPF>52650730439</CPF></condutor><tpRod>01</tpRod><tpCar>01</tpCar><UF>SC</UF></veicTracao></rodo></infModal><infDoc><infMunDescarga><cMunDescarga>4202909</cMunDescarga><xMunDescarga>Brusque</xMunDescarga><infNFe><chNFe>42250134475274000159550010000042471141774520</chNFe></infNFe></infMunDescarga></infDoc><tot><qNFe>1</qNFe><vCarga>1013.25</vCarga><cUnid>01</cUnid><qCarga>200.0000</qCarga></tot><infRespTec><CNPJ>13807373000110</CNPJ><xContato>Joao Maria</xContato><email>[email protected]</email><fone>4733445566</fone></infRespTec></infMDFe><infMDFeSupl><qrCodMDFe>https://dfe-portal.svrs.rs.gov.br/mdfe/qrCode?chMDFe=42250134475274000159580010000000351178611677&amp;tpAmb=2</qrCodMDFe></infMDFeSupl></MDFe>
1 change: 1 addition & 0 deletions test/mdfe.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<MDFe xmlns="http://www.portalfiscal.inf.br/mdfe"><infMDFe versao="3.00" Id="MDFe42250134475274000159580010000000351147050177"><ide><cUF>42</cUF><tpAmb>2</tpAmb><tpEmit>2</tpEmit><mod>58</mod><serie>1</serie><nMDF>35</nMDF><cMDF>14705017</cMDF><cDV>7</cDV><modal>1</modal><dhEmi>2025-01-21T10:20:11-03:00</dhEmi><tpEmis>1</tpEmis><procEmi>0</procEmi><verProc>v4.7.4</verProc><UFIni>SC</UFIni><UFFim>SC</UFFim><infMunCarrega><cMunCarrega>4202909</cMunCarrega><xMunCarrega>Brusque</xMunCarrega></infMunCarrega></ide><emit><CNPJ>34475274000159</CNPJ><IE>260188328</IE><xNome>EMPRESA TESTE SISTEMA (NR)</xNome><xFant>EMPRESA TESTE SISTEMA</xFant><enderEmit><xLgr>Rua Fake de Teste</xLgr><nro>999</nro><xBairro>Bairro Fake</xBairro><cMun>4202909</cMun><xMun>Brusque</xMun><CEP>79303061</CEP><UF>SC</UF><fone>47991778800</fone></enderEmit></emit><infModal versaoModal="3.00"><rodo><infANTT><infContratante><CNPJ>34475274000159</CNPJ></infContratante></infANTT><veicTracao><placa>KDJ9910</placa><RENAVAM>12345678901</RENAVAM><tara>7500</tara><capKG>10000</capKG><capM3>500</capM3><condutor><xNome>JOAOZINHO DA SILVA</xNome><CPF>88548813687</CPF></condutor><tpRod>01</tpRod><tpCar>01</tpCar><UF>SC</UF></veicTracao></rodo></infModal><infDoc><infMunDescarga><cMunDescarga>4202909</cMunDescarga><xMunDescarga>Brusque</xMunDescarga><infNFe><chNFe>42250134475274000159550010000042471141774520</chNFe></infNFe></infMunDescarga></infDoc><tot><qNFe>1</qNFe><vCarga>1013.25</vCarga><cUnid>01</cUnid><qCarga>200.0000</qCarga></tot><infRespTec><CNPJ>15624723000139</CNPJ><xContato>Joao Maria</xContato><email>[email protected]</email><fone>4733445566</fone></infRespTec></infMDFe><infMDFeSupl><qrCodMDFe>https://dfe-portal.svrs.rs.gov.br/mdfe/qrCode?chMDFe=42250134475274000159580010000000351147050177&amp;tpAmb=2</qrCodMDFe></infMDFeSupl><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></CanonicalizationMethod><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></SignatureMethod><Reference URI="#MDFe42250134475274000159580010000000351147050177"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform><Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></Transform></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></DigestMethod><DigestValue>7NxfbV6Yp9lMfKs0zl6YAzPZsOU=</DigestValue></Reference></SignedInfo><SignatureValue>OSR67INwiXfX1fjQUIv+nAieW1JF3+NTgu49kLMlpVm0KIc6OgrnesFxYJnuwsrStaSgaeI9ysh7xj4oKpIzix2JdeuAIXW7M4dENuRcdusqEdKLUkSKZo2I1gzXUxB4cd6bZb7JeROj0WAz/zfHeY4L9JTmxejZ25bi//OC726u/aLQryMUJFmxOmRo/wfMqnKnhfQtQmX7Pn2+vV9jdroYCa75viMEziASxG7SbaijY6BJ4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6CZTcZLsnxw8cvw1XU3G1xr6gLTq4p+NXUSCkY7NvI2JxA3Sl7KUjNpL6XQmoasztbIZRVPXrqOxPGgmDf8OL03urbq3CfILZqgt31kqekkvzQTEwExgXLUi/Pr4UP0+TpEWdded4qxC6f937Y9QiQkO0mF4AQiCu5bPYfpm0WGo76+RDbvLqUqsKd3z6rwhFuvm/yvLkQSpjZMJf5KZjvUvF7Loo5/qKqxfzsWBIvtPzl/J/jef/tY0tk4AxDICxNgSp947jaz47WV0QcyGakjx/ieiv1aGoZ8d0rk0wtuf7Q9lsZWs//FjU/g7PqA+zMWvrgUDX3IWfBwKYR8XHmxJn2Awgd95p9pQ/h0EiC9YdhZNpOV+jpPEXr4Ug1tMCjdj2tfoNL4DI3y8DVccHZ9/IcM1</X509Certificate></X509Data></KeyInfo></Signature></MDFe>
41 changes: 41 additions & 0 deletions test/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,47 @@ describe('validator', function() {

});


describe('should validate example schemata', function() {

const MDFE_SCHEMA = 'test/xsd/mdfe/mdfe_v3.00.xsd';
const VALID_MDFE_FILE = 'test/mdfe.xml';
const INVALID_MDFE_FILE = 'test/mdfe-invalid.xml';


describe('MDFE (recursively expanding schema) in insecure mode', function() {

it('valid', async function() {

// when
const { valid } = await validator.validateXML({ file: VALID_MDFE_FILE }, MDFE_SCHEMA, { insecure: true });

// then
expect(valid).to.be.true;
});


it('invalid', async function() {

let err;

// when
try {
await validator.validateXML({ file: INVALID_MDFE_FILE }, MDFE_SCHEMA, { insecure: true });
} catch (_err) {
err = _err;
}

// then
expect(err).to.exist;
expect(err.valid).to.be.false;
expect(err.result).to.eql('WITH_ERRORS');
});

});

});

});


Expand Down
Loading

0 comments on commit a884ec4

Please sign in to comment.