spec/signer_spec.rb in signer-1.6.0 vs spec/signer_spec.rb in signer-1.7.0
- old
+ new
@@ -55,11 +55,11 @@
signer = Signer.new(File.read(input_xml_file))
signer.cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
signer.private_key = OpenSSL::PKey::RSA.new(File.read(private_key_file), "test")
signer.digest_algorithm = :sha256
signer.signature_digest_algorithm = :sha256
- signer.signature_algorithm_id = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'
+ signer.signature_algorithm_id = 'http://www.w3.org/2001/04/xmlenc#sha256'
signer.digest!(signer.binary_security_token_node)
signer.sign!
@@ -107,10 +107,11 @@
output_xml_file = File.join(File.dirname(__FILE__), 'fixtures', 'output_2.xml')
signer.to_xml.should == Nokogiri::XML(File.read(output_xml_file), &:noblanks).to_xml(:save_with => 0)
end
+
it "should digest and sign SOAP XML with security node and digested binary token" do
input_xml_file = File.join(File.dirname(__FILE__), 'fixtures', 'input_4_with_nested_signatures.xml')
cert_file = File.join(File.dirname(__FILE__), 'fixtures', 'cert.pem')
private_key_file = File.join(File.dirname(__FILE__), 'fixtures', 'key.pem')
@@ -148,16 +149,43 @@
signer.cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
signer.private_key = OpenSSL::PKey::RSA.new(File.read(private_key_file), "test")
signer.security_node = signer.document.root
signer.security_token_id = ""
signer.ds_namespace_prefix = 'ds'
+
signer.digest!(signer.document.root, :id => "", :enveloped => true)
signer.sign!(:issuer_serial => true)
# File.open(File.join(File.dirname(__FILE__), 'fixtures', 'output_2_with_ds_prefix.xml'), "w") do |f|
# f.write signer.document.to_s
# end
output_xml_file = File.join(File.dirname(__FILE__), 'fixtures', 'output_2_with_ds_prefix.xml')
+
+ signer.to_xml.should == Nokogiri::XML(File.read(output_xml_file), &:noblanks).to_xml(:save_with => 0)
+ end
+
+ it "should partially sign element and simple XML with custom DS namespace prefix when wss is false" do
+ input_xml_file = File.join(File.dirname(__FILE__), 'fixtures', 'input_2.xml')
+ cert_file = File.join(File.dirname(__FILE__), 'fixtures', 'cert.pem')
+ private_key_file = File.join(File.dirname(__FILE__), 'fixtures', 'key.pem')
+
+ signer = Signer.new(File.read(input_xml_file), wss: false)
+ signer.cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
+ signer.private_key = OpenSSL::PKey::RSA.new(File.read(private_key_file), "test")
+ signer.security_node = signer.document.root
+ signer.security_token_id = ""
+ signer.ds_namespace_prefix = 'ds'
+
+ # partially sign element
+ signer.digest!(signer.document.root.children.first, :enveloped => true)
+
+ signer.digest!(signer.document.root, :id => "", :enveloped => true)
+ signer.sign!(:issuer_serial => true)
+
+ # File.open(File.join(File.dirname(__FILE__), 'fixtures', 'output_2_with_ds_prefix.xml'), "w") do |f|
+ # f.write signer.document.to_s
+ # end
+ output_xml_file = File.join(File.dirname(__FILE__), 'fixtures', 'output_2_with_ds_prefix_and_wss_disabled.xml')
signer.to_xml.should == Nokogiri::XML(File.read(output_xml_file), &:noblanks).to_xml(:save_with => 0)
end
it "should digest and sign SOAP XML with security node and digested binary token with noblanks disabled" do