xmldsig 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ spec/reports
16
16
  test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
+ .idea
@@ -20,7 +20,7 @@ module Xmldsig
20
20
  end
21
21
 
22
22
  def signatures
23
- document.xpath("//ds:Signature", NAMESPACES).collect { |node| Signature.new(node) } || []
23
+ document.xpath("//ds:Signature", NAMESPACES).reverse.collect { |node| Signature.new(node) } || []
24
24
  end
25
25
  end
26
26
  end
@@ -2,7 +2,7 @@ module Xmldsig
2
2
  class Transforms < Array
3
3
  class EnvelopedSignature < Transform
4
4
  def transform
5
- node.xpath("descendant::ds:Signature", Xmldsig::NAMESPACES).remove
5
+ node.xpath("descendant::ds:Signature", Xmldsig::NAMESPACES).first.remove
6
6
  node
7
7
  end
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module Xmldsig
2
- VERSION = "0.2.0"
2
+ VERSION = '0.2.1'
3
3
  end
@@ -17,9 +17,16 @@ describe Xmldsig::SignedDocument do
17
17
  end
18
18
 
19
19
  describe "#signatures" do
20
+ let(:unsigned_xml) { File.read("spec/fixtures/unsigned_nested_signature.xml") }
21
+ let(:unsigned_document) { Xmldsig::SignedDocument.new(unsigned_xml) }
22
+
20
23
  it "returns only the signed nodes" do
21
24
  signed_document.signatures.should be_all { |signature| signature.is_a?(Xmldsig::Signature) }
22
25
  end
26
+
27
+ it "returns the nested signatures first" do
28
+ unsigned_document.signatures.first.references.first.reference_uri.should == '#baz'
29
+ end
23
30
  end
24
31
 
25
32
  describe "#signed_nodes" do
@@ -36,7 +43,7 @@ describe Xmldsig::SignedDocument do
36
43
  it "returns false if the certificate is not valid" do
37
44
  signed_document.validate(other_certificate).should be_false
38
45
  end
39
-
46
+
40
47
  it "returns false if there are no signatures and validation is strict" do
41
48
  xml_without_signature = Xmldsig::SignedDocument.new('<foo></foo>')
42
49
  xml_without_signature.validate(certificate).should be_false
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Xmldsig::Transforms::EnvelopedSignature do
4
+ let(:unsigned_xml) { File.read('spec/fixtures/unsigned_nested_signature.xml') }
5
+ let(:unsigned_document) { Xmldsig::SignedDocument.new(unsigned_xml) }
6
+
7
+ it 'only removes the first signature element' do
8
+ node_with_nested_signature = unsigned_document.signatures.last.references.first.referenced_node
9
+
10
+ described_class.new(node_with_nested_signature, nil).transform
11
+
12
+ remaining_signatures = node_with_nested_signature.xpath('descendant::ds:Signature', Xmldsig::NAMESPACES)
13
+ remaining_signatures.count.should == 1
14
+ signature = Xmldsig::Signature.new(remaining_signatures.first)
15
+
16
+ signature.references.first.reference_uri.should == '#baz'
17
+ end
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xmldsig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-30 00:00:00.000000000 Z
12
+ date: 2013-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -69,6 +69,7 @@ files:
69
69
  - spec/lib/xmldsig/reference_spec.rb
70
70
  - spec/lib/xmldsig/signature_spec.rb
71
71
  - spec/lib/xmldsig/signed_document_spec.rb
72
+ - spec/lib/xmldsig/transforms/enveloped_signature_spec.rb
72
73
  - spec/lib/xmldsig/transforms/transform_spec.rb
73
74
  - spec/lib/xmldsig_spec.rb
74
75
  - spec/spec_helper.rb
@@ -115,6 +116,7 @@ test_files:
115
116
  - spec/lib/xmldsig/reference_spec.rb
116
117
  - spec/lib/xmldsig/signature_spec.rb
117
118
  - spec/lib/xmldsig/signed_document_spec.rb
119
+ - spec/lib/xmldsig/transforms/enveloped_signature_spec.rb
118
120
  - spec/lib/xmldsig/transforms/transform_spec.rb
119
121
  - spec/lib/xmldsig_spec.rb
120
122
  - spec/spec_helper.rb