Sha256: a024bc598ad97d87d1751c6bfcfd1c483a5e07aeef4d365f1912739b2b5a14df

Contents?: true

Size: 1005 Bytes

Versions: 5

Compression:

Stored size: 1005 Bytes

Contents

require 'spec_helper'

describe Xmlenc::EncryptedDocument do
  let(:plain_xml) { File.read('spec/fixtures/phaos/payment.xml') }
  let(:encrypted_xml) { File.read('spec/fixtures/encrypted_document.xml') }
  let(:private_key) { OpenSSL::PKey::RSA.new(File.read('spec/fixtures/phaos/rsa-priv-key.pem')) }
  subject { described_class.new(encrypted_xml) }

  describe 'document' do
    it 'returns the nokogiri document' do
      expect(subject.document).to be_a(Nokogiri::XML::Document)
    end
  end

  describe 'encrypted_keys' do
    it 'returns the encrypted keys' do
      expect(subject.encrypted_keys.count).to be == 1
    end

    it 'converts the elements to EncryptedKey' do
      all_converted = subject.encrypted_keys.all? { |ek| ek.is_a?(Xmlenc::EncryptedKey) }
      expect(all_converted).to be_true
    end
  end

  describe 'decrypt' do
    it 'replaces the encrypted data with the unencrypted elements' do
      expect(subject.decrypt(private_key).chomp).to be == plain_xml
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
xmlenc-0.1.3 spec/lib/xmlenc/encrypted_document_spec.rb
xmlenc-0.1.2 spec/lib/xmlenc/encrypted_document_spec.rb
xmlenc-0.1.1 spec/lib/xmlenc/encrypted_document_spec.rb
xmlenc-0.1.0 spec/lib/xmlenc/encrypted_document_spec.rb
xmlenc-0.0.1 spec/lib/xmlenc/encrypted_document_spec.rb