Commit 1ad8d91
Changed files (4)
lib
xml
kit
spec
xml
kit
lib/xml/kit/templates/key_info.builder
@@ -1,6 +1,7 @@
xml.KeyInfo xmlns: ::Xml::Kit::Namespaces::XMLDSIG do
xml.KeyName key_name if key_name
render(key_value, xml: xml) if @key_value
+ render(retrieval_method, xml: xml) if @retrieval_method
xml.EncryptedKey xmlns: ::Xml::Kit::Namespaces::XMLENC do
xml.EncryptionMethod Algorithm: algorithm
xml.CipherData do
lib/xml/kit/templates/retrieval_method.builder
@@ -0,0 +1,1 @@
+xml.RetrievalMethod xmlns: ::Xml::Kit::Namespaces::XMLDSIG, URI: uri, Type: type
lib/xml/kit/key_info.rb
@@ -14,6 +14,10 @@ module Xml
end
end
+ class RetrievalMethod
+ attr_accessor :uri, :type
+ end
+
class KeyInfo
include Templatable
attr_reader :algorithm, :cipher_value
@@ -27,6 +31,10 @@ module Xml
def key_value
@key_value ||= KeyValue.new
end
+
+ def retrieval_method
+ @retrieval_method ||= RetrievalMethod.new
+ end
end
end
end
spec/xml/kit/key_info_spec.rb
@@ -37,5 +37,19 @@ RSpec.describe Xml::Kit::KeyInfo do
specify { expect(result['KeyInfo']['KeyValue']['RSAKeyValue']['Modulus']).to eql(modulus) }
specify { expect(result['KeyInfo']['KeyValue']['RSAKeyValue']['Exponent']).to eql(exponent) }
end
+
+ context "with retrieval method" do
+ let(:result) { Hash.from_xml(subject.to_xml) }
+ let(:uri) { Xml::Kit::Id.generate }
+ let(:type) { "http://www.w3.org/2001/04/xmlenc#EncryptedKey" }
+
+ before do
+ subject.retrieval_method.uri = uri
+ subject.retrieval_method.type = type
+ end
+
+ specify { expect(result['KeyInfo']['RetrievalMethod']['URI']).to eql(uri) }
+ specify { expect(result['KeyInfo']['RetrievalMethod']['Type']).to eql(type) }
+ end
end
end