Commit fe8e95c
Changed files (4)
lib
saml
kit
spec
saml
builders
xml-kit
lib
xml
spec
lib/saml/kit/assertion.rb
@@ -74,7 +74,8 @@ module Saml
def assertion
@assertion ||=
if encrypted?
- decryptor = ::Xml::Kit::XmlDecryption.new(configuration: configuration)
+ private_keys = configuration.private_keys(use: :encryption)
+ decryptor = ::Xml::Kit::XmlDecryption.new(private_keys: private_keys)
decrypted = decryptor.decrypt(@xml_hash['Response']['EncryptedAssertion'])
Saml::Kit.logger.debug(decrypted)
Hash.from_xml(decrypted)['Assertion']
spec/saml/builders/response_spec.rb
@@ -93,7 +93,7 @@ RSpec.describe Saml::Kit::Builders::Response do
result = Hash.from_xml(subject.to_xml)
expect(result['Response']['EncryptedAssertion']).to be_present
encrypted_assertion = result['Response']['EncryptedAssertion']
- decrypted_assertion = Xml::Kit::XmlDecryption.new(configuration: configuration).decrypt(encrypted_assertion)
+ decrypted_assertion = Xml::Kit::XmlDecryption.new(private_keys: configuration.private_keys(use: :encryption)).decrypt(encrypted_assertion)
decrypted_hash = Hash.from_xml(decrypted_assertion)
expect(decrypted_hash['Assertion']).to be_present
expect(decrypted_hash['Assertion']['Issuer']).to be_present
xml-kit/lib/xml/kit/xml_decryption.rb
@@ -5,8 +5,8 @@ module Xml
# The list of private keys to use to attempt to decrypt the document.
attr_reader :private_keys
- def initialize(configuration: Saml::Kit.configuration)
- @private_keys = configuration.private_keys(use: :encryption)
+ def initialize(private_keys:)
+ @private_keys = private_keys
end
# Decrypts an EncryptedData section of an XML document.
xml-kit/spec/xml/xml_decryption_spec.rb
@@ -39,7 +39,7 @@ RSpec.describe Xml::Kit::XmlDecryption do
}
}
}
- subject = described_class.new(configuration: double(private_keys: [private_key]))
+ subject = described_class.new(private_keys: [private_key])
decrypted = subject.decrypt(data)
expect(decrypted.strip).to eql(secret)
end
@@ -83,7 +83,7 @@ RSpec.describe Xml::Kit::XmlDecryption do
_, other_private_key_pem = generate_key_pair(password)
other_private_key = OpenSSL::PKey::RSA.new(other_private_key_pem, password)
- subject = described_class.new(configuration: double(private_keys: [other_private_key, private_key]))
+ subject = described_class.new(private_keys: [other_private_key, private_key])
decrypted = subject.decrypt(data)
expect(decrypted.strip).to eql(secret)
end
@@ -125,7 +125,7 @@ RSpec.describe Xml::Kit::XmlDecryption do
new_private_key_pem = generate_key_pair(password)[1]
new_private_key = OpenSSL::PKey::RSA.new(new_private_key_pem, password)
- subject = described_class.new(configuration: double(private_keys: [new_private_key]))
+ subject = described_class.new(private_keys: [new_private_key])
expect do
subject.decrypt(data)
end.to raise_error(OpenSSL::PKey::RSAError)