Sha256: 824803a15346d7eb3d8280e04fa4f43682f7e59397d33103e8b930ff52ee468a

Contents?: true

Size: 952 Bytes

Versions: 4

Compression:

Stored size: 952 Bytes

Contents

require 'spec_helper'

describe Xmldsig do
  let(:private_key) { OpenSSL::PKey::RSA.new(File.read("spec/fixtures/key.pem")) }
  let(:certificate) { OpenSSL::X509::Certificate.new(File.read("spec/fixtures/certificate.cer")) }

  describe "Sign unsigned documents" do
    Dir["spec/fixtures/unsigned/*.xml"].each do |document|
      describe "#{document}" do
        let(:unsigned_xml) { File.read(document) }
        let(:unsigned_document) { Xmldsig::SignedDocument.new(unsigned_xml) }

        it "should be signable an validateable" do
          signed_document = unsigned_document.sign(private_key)
          Xmldsig::SignedDocument.new(signed_document).validate(certificate).should be_true
        end
        
        it 'should have a signature element' do
          signed_document = unsigned_document.sign(private_key)
          Xmldsig::SignedDocument.new(signed_document).signatures.count.should == 1
        end
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xmldsig-0.2.1 spec/lib/xmldsig_spec.rb
xmldsig-0.2.0 spec/lib/xmldsig_spec.rb
xmldsig-0.1.0 spec/lib/xmldsig_spec.rb
xmldsig-0.0.4 spec/lib/xmldsig_spec.rb