Sha256: ff8ef781501287c8cbd0b8e6b73efeb3c30f6427e86e0ce6c739466ba4e41e87

Contents?: true

Size: 790 Bytes

Versions: 9

Compression:

Stored size: 790 Bytes

Contents

require 'spec_helper'

require 'saml_idp/encryptor'

module SamlIdp
  describe Encryptor do
    let (:encryption_opts) do
      {
        cert: Default::X509_CERTIFICATE,
        block_encryption: 'aes256-cbc',
        key_transport: 'rsa-oaep-mgf1p',
      }
    end

    subject { described_class.new encryption_opts }

    it "encrypts XML" do
      raw_xml = '<foo>bar</foo>'
      encrypted_xml = subject.encrypt(raw_xml)
      expect(encrypted_xml).to_not match raw_xml
      encrypted_doc = Nokogiri::XML::Document.parse(encrypted_xml)
      encrypted_data = Xmlenc::EncryptedData.new(encrypted_doc.at_xpath('//xenc:EncryptedData', Xmlenc::NAMESPACES))
      decrypted_xml = encrypted_data.decrypt(subject.encryption_key)
      expect(decrypted_xml).to eq(raw_xml)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
saml_idp-0.16.0 spec/lib/saml_idp/encryptor_spec.rb
saml_idp-0.15.0 spec/lib/saml_idp/encryptor_spec.rb
saml_idp-0.14.0 spec/lib/saml_idp/encryptor_spec.rb
saml_idp-0.12.0 spec/lib/saml_idp/encryptor_spec.rb
saml_idp-0.11.0 spec/lib/saml_idp/encryptor_spec.rb
saml_idp-0.10.0 spec/lib/saml_idp/encryptor_spec.rb
saml_idp-0.9.0 spec/lib/saml_idp/encryptor_spec.rb
saml_idp-0.8.1 spec/lib/saml_idp/encryptor_spec.rb
saml_idp-0.8.0 spec/lib/saml_idp/encryptor_spec.rb