Skip to content

Commit

Permalink
#4 - Alterado local dos Schemas para validação. Adicionado todos so S…
Browse files Browse the repository at this point in the history
…chemas encontrados para validação.
  • Loading branch information
Brunomm committed Dec 21, 2016
1 parent 8e0178d commit d1293d1
Show file tree
Hide file tree
Showing 143 changed files with 28,175 additions and 9,911 deletions.
98 changes: 0 additions & 98 deletions lib/br_nfe/product/xml/v1_00/XSD/xmldsig-core-schema_v1.01.xsd

This file was deleted.

14 changes: 2 additions & 12 deletions test/br_nfe/product/nfe_consulta_autorizacao_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,13 @@
end

describe "Validação do XML através do XSD" do
let(:schemas_dir) { BrNfe.root+'/lib/br_nfe/product/xml/v3_10/XSD' }
def validate_schema
subject.stubs(:certificate).returns(nil)
Dir.chdir(schemas_dir) do
schema = Nokogiri::XML::Schema(IO.read('consReciNFe_v3.10.xsd'))
document = Nokogiri::XML(subject.xml_builder)
errors = schema.validate(document)
errors.must_be_empty
end
end
it "Deve ser válido em ambiente de produção" do
subject.env = :production
validate_schema
nfe_must_be_valid_by_schema 'consReciNFe_v3.10.xsd'
end
it "Deve ser válido em ambiente de homologação" do
subject.env = :test
validate_schema
nfe_must_be_valid_by_schema 'consReciNFe_v3.10.xsd'
end
end

Expand Down
14 changes: 2 additions & 12 deletions test/br_nfe/product/nfe_consulta_protocolo_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,13 @@
end

describe "Validação do XML através do XSD" do
let(:schemas_dir) { BrNfe.root+'/lib/br_nfe/product/xml/v3_10/XSD' }
def validate_schema
subject.stubs(:certificate).returns(nil)
Dir.chdir(schemas_dir) do
schema = Nokogiri::XML::Schema(IO.read('consSitNFe_v3.10.xsd'))
document = Nokogiri::XML(subject.xml_builder)
errors = schema.validate(document)
errors.must_be_empty
end
end
it "Deve ser válido em ambiente de produção" do
subject.env = :production
validate_schema
nfe_must_be_valid_by_schema 'consSitNFe_v3.10.xsd'
end
it "Deve ser válido em ambiente de homologação" do
subject.env = :test
validate_schema
nfe_must_be_valid_by_schema 'consSitNFe_v3.10.xsd'
end
end

Expand Down
13 changes: 2 additions & 11 deletions test/br_nfe/product/nfe_inutilizacao_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,13 @@
end

describe "Validação do XML através do XSD" do
let(:schemas_dir) { BrNfe.root+'/lib/br_nfe/product/xml/v3_10/XSD' }
def validate_schema
Dir.chdir(schemas_dir) do
schema = Nokogiri::XML::Schema(IO.read('inutNFe_v3.10.xsd'))
document = Nokogiri::XML(subject.xml_builder)
errors = schema.validate(document)
errors.must_be_empty
end
end
it "Deve ser válido em ambiente de produção" do
subject.env = :production
validate_schema
nfe_must_be_valid_by_schema 'inutNFe_v3.10.xsd'
end
it "Deve ser válido em ambiente de homologação" do
subject.env = :test
validate_schema
nfe_must_be_valid_by_schema 'inutNFe_v3.10.xsd'
end
end

Expand Down
26 changes: 4 additions & 22 deletions test/br_nfe/product/nfe_recepcao_evento_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,48 +54,30 @@
before do
gateway.stubs(:version_xml_recepcao_evento).returns(:v1_00)
end
let(:schemas_dir) { BrNfe.root+'/lib/br_nfe/product/xml/v1_00/XSD' }
def validate_schema
Dir.chdir(schemas_dir) do
schema = Nokogiri::XML::Schema(IO.read('envEventoCancNFe_v1.00.xsd'))
document = Nokogiri::XML(subject.xml_builder)
errors = schema.validate(document)
errors.must_be_empty
end
end
it "Deve ser válido em ambiente de produção" do
subject.env = :production
subject.valid?.must_equal true, "#{subject.errors.full_messages}"
validate_schema
nfe_must_be_valid_by_schema 'envEventoCancNFe_v1.00.xsd'
end
it "Deve ser válido em ambiente de homologação" do
subject.env = :test
subject.valid?.must_equal true, "#{subject.errors.full_messages}"
validate_schema
nfe_must_be_valid_by_schema 'envEventoCancNFe_v1.00.xsd'
end
end
context "Para emissores que utilizam a versão 3.10" do
before do
gateway.stubs(:version_xml_recepcao_evento).returns(:v3_10)
end
let(:schemas_dir) { BrNfe.root+'/lib/br_nfe/product/xml/v1_00/XSD' }
def validate_schema
Dir.chdir(schemas_dir) do
schema = Nokogiri::XML::Schema(IO.read('envEventoCancNFe_v1.00.xsd'))
document = Nokogiri::XML(subject.xml_builder)
errors = schema.validate(document)
errors.must_be_empty
end
end
it "Deve ser válido em ambiente de produção" do
subject.env = :production
subject.valid?.must_equal true, "#{subject.errors.full_messages}"
validate_schema
nfe_must_be_valid_by_schema 'envEventoCancNFe_v1.00.xsd'
end
it "Deve ser válido em ambiente de homologação" do
subject.env = :test
subject.valid?.must_equal true, "#{subject.errors.full_messages}"
validate_schema
nfe_must_be_valid_by_schema 'envEventoCancNFe_v1.00.xsd'
end
end
end
Expand Down
14 changes: 2 additions & 12 deletions test/br_nfe/product/nfe_status_servico_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,13 @@
end

describe "Validação do XML através do XSD" do
let(:schemas_dir) { BrNfe.root+'/lib/br_nfe/product/xml/v3_10/XSD' }
def validate_schema
subject.stubs(:certificate).returns(nil)
Dir.chdir(schemas_dir) do
schema = Nokogiri::XML::Schema(IO.read('consStatServ_v3.10.xsd'))
document = Nokogiri::XML(subject.xml_builder)
errors = schema.validate(document)
errors.must_be_empty
end
end
it "Deve ser válido em ambiente de produção" do
subject.env = :production
validate_schema
nfe_must_be_valid_by_schema 'consStatServ_v3.10.xsd'
end
it "Deve ser válido em ambiente de homologação" do
subject.env = :test
validate_schema
nfe_must_be_valid_by_schema 'consStatServ_v3.10.xsd'
end
end

Expand Down
25 changes: 25 additions & 0 deletions test/fixtures/product/response/v3.10/nfe_autorizacao/success.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<nfeCabecMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeAutorizacao">
<cUF>42</cUF>
<versaoDados>3.10</versaoDados>
</nfeCabecMsg>
</soap:Header>
<soap:Body>
<nfeAutorizacaoLoteResult xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeAutorizacao">
<retEnviNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="3.10">
<tpAmb>2</tpAmb>
<verAplic>SVRS201603081012</verAplic>
<cStat>103</cStat>
<xMotivo>Lote recebido com sucesso</xMotivo>
<cUF>42</cUF>
<dhRecbto>2016-12-20T10:50:44-02:00</dhRecbto>
<infRec>
<nRec>423002169442281</nRec>
<tMed>1</tMed>
</infRec>
</retEnviNFe>
</nfeAutorizacaoLoteResult>
</soap:Body>
</soap:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<nfeCabecMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeRetAutorizacao">
<cUF>42</cUF>
<versaoDados>3.10</versaoDados>
</nfeCabecMsg>
</soap:Header>
<soap:Body>
<nfeRetAutorizacaoLoteResult xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeRetAutorizacao">
<retConsReciNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="3.10">
<tpAmb>2</tpAmb>
<verAplic>SVRS201611281548</verAplic>
<nRec>423002169476281</nRec>
<cStat>104</cStat>
<xMotivo>Lote processado</xMotivo>
<cUF>42</cUF>
<dhRecbto>2016-12-20T14:29:28-02:00</dhRecbto>
<protNFe versao="3.10">
<infProt>
<tpAmb>2</tpAmb>
<verAplic>SVRS201611281548</verAplic>
<chNFe>42161223020443000140550010000000011201601011</chNFe>
<dhRecbto>2016-12-20T14:29:28-02:00</dhRecbto>
<digVal>hBKuDGD3gRtlFDO5bT9VH/UWKBQ=</digVal>
<cStat>209</cStat>
<xMotivo>Rejeicao: IE do emitente invalida</xMotivo>
</infProt>
</protNFe>
</retConsReciNFe>
</nfeRetAutorizacaoLoteResult>
</soap:Body>
</soap:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<nfeCabecMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeRetAutorizacao">
<cUF>42</cUF>
<versaoDados>3.10</versaoDados>
</nfeCabecMsg>
</soap:Header>
<soap:Body>
<nfeRetAutorizacaoLoteResult xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeRetAutorizacao">
<retConsReciNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="3.10">
<tpAmb>2</tpAmb>
<verAplic>SVRS201611281548</verAplic>
<nRec>423002169484138</nRec>
<cStat>104</cStat>
<xMotivo>Lote processado</xMotivo>
<cUF>42</cUF>
<dhRecbto>2016-12-20T16:11:28-02:00</dhRecbto>
<protNFe versao="3.10">
<infProt>
<tpAmb>2</tpAmb>
<verAplic>SVRS201611281548</verAplic>
<chNFe>42161208897094000155550010000000011201601016</chNFe>
<dhRecbto>2016-12-20T16:11:28-02:00</dhRecbto>
<nProt>342160000785247</nProt>
<digVal>AcoglfmS7KCjv/XaaYO0T9ohlqM=</digVal>
<cStat>100</cStat>
<xMotivo>Autorizado o uso da NF-e</xMotivo>
</infProt>
</protNFe>
</retConsReciNFe>
</nfeRetAutorizacaoLoteResult>
</soap:Body>
</soap:Envelope>
11 changes: 11 additions & 0 deletions test/fixtures/product/schemas/CCe_v1.00.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- 03-03-2011 - correcao do nome da tag raiz -->
<!-- PL_006CC CCe 16/06/2010 -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteCCe_v1.00.xsd"/>
<xs:element name="evento" type="TEvento">
<xs:annotation>
<xs:documentation>Schema XML de validação do evento Carta de Correção</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
9 changes: 9 additions & 0 deletions test/fixtures/product/schemas/EPEC_v1.00.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteEPEC_v1.00.xsd"/>
<xs:element name="evento" type="TEvento">
<xs:annotation>
<xs:documentation>Schema XML de validação do Evento Prévio de Emissão em Contingência</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
Loading

0 comments on commit d1293d1

Please sign in to comment.