Comparing changes

v1.0.12 v1.0.13
8 commits 9 files changed

Commits

9aeb052 bump version. mo 2018-03-07 00:29:24
3c0ac38 update xml-kit dependency. mo 2018-03-07 00:28:53
a836be8 fix rubocop errors. mo 2018-03-07 00:09:16
8c235fa fix rubocop error. mo 2018-03-07 00:05:20
681a7ed fix rubocop errors. mo 2018-03-07 00:03:37
ae0f8ba make name public. mo 2018-03-04 20:46:41
lib/saml/kit/document.rb
@@ -18,6 +18,7 @@ module Saml
         'xmlenc' => ::Xml::Kit::Namespaces::XMLENC,
       }.freeze
       attr_accessor :registry
+      attr_reader :name
       validates_presence_of :content
       validates_presence_of :id
       validate :must_match_xsd
@@ -58,7 +59,7 @@ module Saml
 
       # Returns the SAML document returned as a Hash.
       def to_h
-        @xml_hash ||= Hash.from_xml(content) || {}
+        @to_h ||= Hash.from_xml(content) || {}
       end
 
       # Returns the SAML document as an XML string.
@@ -76,7 +77,7 @@ module Saml
 
       # @!visibility private
       def to_nokogiri
-        @nokogiri ||= Nokogiri::XML(content)
+        @to_nokogiri ||= Nokogiri::XML(content)
       end
 
       # @!visibility private
@@ -137,7 +138,7 @@ module Saml
 
       private
 
-      attr_reader :content, :name, :configuration
+      attr_reader :content, :configuration
 
       def must_match_xsd
         matches_xsd?(PROTOCOL_XSD)
lib/saml/kit/metadata.rb
@@ -148,7 +148,7 @@ module Saml
 
       # Returns the XML document converted to a Hash.
       def to_h
-        @xml_hash ||= Hash.from_xml(to_xml)
+        @to_h ||= Hash.from_xml(to_xml)
       end
 
       # Returns the XML document as a String.
@@ -210,7 +210,7 @@ module Saml
 
       # @!visibility private
       def to_nokogiri
-        @nokogiri ||= Nokogiri::XML(xml)
+        @to_nokogiri ||= Nokogiri::XML(xml)
       end
 
       def at_xpath(xpath)
lib/saml/kit/signature.rb
@@ -26,7 +26,7 @@ module Saml
       # Returns true when the fingerprint of the certificate matches one of the certificates registered in the metadata.
       def trusted?(metadata)
         return false if metadata.nil?
-        metadata.matches?(certificate.fingerprint, use: :signing)
+        metadata.matches?(certificate.fingerprint, use: :signing).present?
       end
 
       def digest_value
@@ -62,11 +62,11 @@ module Saml
 
       # Returns the XML Hash.
       def to_h
-        @xml_hash ||= present? ? Hash.from_xml(to_xml)['Signature'] : {}
+        @to_h ||= present? ? Hash.from_xml(to_xml)['Signature'] : {}
       end
 
       def present?
-        node
+        node.present?
       end
 
       def to_xml(pretty: false)
lib/saml/kit/version.rb
@@ -2,6 +2,6 @@
 
 module Saml
   module Kit
-    VERSION = '1.0.12'.freeze
+    VERSION = '1.0.13'.freeze
   end
 end
lib/saml/kit.rb
@@ -51,7 +51,7 @@ module Saml
   module Kit
     class << self
       def configuration
-        @config ||= Saml::Kit::Configuration.new
+        @configuration ||= Saml::Kit::Configuration.new
       end
 
       def configure
spec/saml/kit/authentication_request_spec.rb
@@ -24,6 +24,7 @@ RSpec.describe Saml::Kit::AuthenticationRequest do
     end
   end
 
+  specify { expect(subject.name).to eql('AuthnRequest') }
   specify { expect(subject.issuer).to eql(issuer) }
   specify { expect(subject.id).to eql(id) }
   specify { expect(subject.assertion_consumer_service_url).to eql(assertion_consumer_service_url) }
spec/saml/kit/signature_spec.rb
@@ -102,7 +102,7 @@ RSpec.describe Saml::Kit::Signature do
 
     context 'when a signature is present' do
       it 'returns true' do
-        expect(subject).to be_present
+        expect(subject.present?).to be(true)
       end
     end
   end
@@ -117,4 +117,18 @@ RSpec.describe Saml::Kit::Signature do
       expect(subject.expected_digest_value).to eql(expected_digest)
     end
   end
+
+  describe '#trusted?' do
+    context 'when trusted' do
+      let(:metadata) { instance_double(Saml::Kit::Metadata, matches?: Object.new) }
+
+      specify { expect(subject.trusted?(metadata)).to be(true) }
+    end
+
+    context 'when untrusted' do
+      let(:metadata) { instance_double(Saml::Kit::Metadata, matches?: nil) }
+
+      specify { expect(subject.trusted?(metadata)).to be(false) }
+    end
+  end
 end
.rubocop.yml
@@ -76,7 +76,10 @@ Style/EachWithObject:
 Style/StringLiterals:
   EnforcedStyle: 'single_quotes'
 
-Style/TrailingCommaInLiteral:
+Style/TrailingCommaInArrayLiteral:
+  Enabled: false
+
+Style/TrailingCommaInHashLiteral:
   Enabled: false
 
 RSpec/ExampleLength:
saml-kit.gemspec
@@ -1,7 +1,6 @@
-
 # frozen_string_literal: true
 
-lib = File.expand_path('../lib', __FILE__)
+lib = File.expand_path('lib', __dir__)
 $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
 require 'saml/kit/version'
 
@@ -30,7 +29,7 @@ Gem::Specification.new do |spec|
   spec.require_paths = ['lib']
 
   spec.add_dependency 'activemodel', '>= 4.2.0'
-  spec.add_dependency 'xml-kit', '>= 0.1.12', '<= 1.0.0'
+  spec.add_dependency 'xml-kit', '>= 0.1.13', '<= 1.0.0'
   spec.add_development_dependency 'bundler', '~> 1.15'
   spec.add_development_dependency 'bundler-audit', '~> 0.6'
   spec.add_development_dependency 'ffaker', '~> 2.7'