spec/lib/xmldsig_spec.rb in xmldsig-0.2.7 vs spec/lib/xmldsig_spec.rb in xmldsig-0.2.8

- old
+ new

@@ -13,21 +13,22 @@ it "should be signable an validateable" do Xmldsig::SignedDocument.new(signed_document).validate(certificate).should be == true end - it 'should have a signature element' do - Xmldsig::SignedDocument.new(signed_document).signatures.count.should == 1 + 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 + # 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 end describe "Verify signed documents" do @@ -37,9 +38,20 @@ let(:signed_document) { Xmldsig::SignedDocument.new(signed_xml) } let(:certificate) { OpenSSL::X509::Certificate.new(File.read(document.gsub('.txt', '.cert'))) } it "should be validateable" do signed_document.validate(certificate).should be == true + end + end + end + Dir["spec/fixtures/signed/*.xml"].each do |document| + describe "#{document}" do + let(:signed_xml) { File.read(document) } + let(:signed_document) { Xmldsig::SignedDocument.new(signed_xml) } + let(:certificate) { OpenSSL::X509::Certificate.new(File.read(document.gsub('.xml', '.cert'))) } + + it "should be validateable" do + expect(signed_document.validate(certificate)).to be == true end end end end