spec/lib/xmldsig_spec.rb in xmldsig-0.2.10 vs spec/lib/xmldsig_spec.rb in xmldsig-0.3.0

- old
+ new

@@ -16,19 +16,10 @@ end it 'should have at least 1 signature element' do Xmldsig::SignedDocument.new(signed_document).signatures.count.should >= 1 end - - # TODO: remove this verification step when library matures - # it 'matches the result from xmlsec1' do - # result = `xmlsec1 --sign --id-attr:ID http://example.com/foo#:Foo --privkey-pem spec/fixtures/key.pem #{document}` - # result.gsub!("\n", '') - # signed_document.gsub!("\n", '') - # puts result - # result.should == signed_document - # end end end end describe "Verify signed documents" do @@ -52,10 +43,20 @@ it "should be validateable" do expect(signed_document.validate(certificate)).to be == true end end end + + context "with invalid xsd signature elemements" do + let(:signed_xml) { File.read('spec/fixtures/signed-with-xsd-error.xml') } + let(:signed_document) { Xmldsig::SignedDocument.new(signed_xml) } + let(:certificate) { OpenSSL::X509::Certificate.new(File.read('spec/fixtures/certificate.cer')) } + + it "raises schema error" do + expect{ signed_document.validate(certificate) }.to raise_error(Xmldsig::SchemaError) + end + end end describe "Allows specifying a custom id attribute" do context "an unsigned document" do let(:unsigned_xml) { File.read("spec/fixtures/unsigned_custom_attribute_id.xml") } @@ -67,18 +68,9 @@ end it 'should have a signature element' do Xmldsig::SignedDocument.new(signed_document, :id_attr => 'MyID').signatures.count.should == 1 end - - # TODO: remove this verification step when library matures - # it 'matches the result from xmlsec1' do - # document = "spec/fixtures/unsigned_custom_attribute_id.xml" - # result = `xmlsec1 --sign --privkey-pem spec/fixtures/key.pem --id-attr:MyID Foo #{document}` - # result.gsub!("\n", '') - # signed_document.gsub!("\n", '') - # result.should == signed_document - # end end context "a signed document" do let(:signed_xml) { File.read("spec/fixtures/signed_custom_attribute_id.xml") } let(:signed_document) { Xmldsig::SignedDocument.new(signed_xml, :id_attr => 'MyID') }