Comparing changes

v1.2.0 v1.3.0
48 commits 21 files changed

Commits

45f85f6 feat: drop ruby 2.5 and 2.6 mo khan 2022-03-30 20:58:34
23585d7 chore(deps): bump activemodel from 6.1.4.7 to 6.1.5 dependabot[bot] 2022-03-11 21:14:42
0a4025b chore(deps-dev): bump rspec from 3.10.0 to 3.11.0 dependabot[bot] 2022-02-09 21:07:07
876a4c3 Bump ffaker from 2.19.0 to 2.20.0 dependabot[bot] 2021-12-15 20:13:17
20b708e Bump activemodel from 6.1.4.1 to 6.1.4.2 dependabot[bot] 2021-12-14 21:07:35
4a960a6 Bump nokogiri from 1.11.7 to 1.12.5 dependabot[bot] 2021-09-27 21:52:53
c9db6ae Bump bundler-audit from 0.8.0 to 0.9.0.1 dependabot[bot] 2021-08-31 21:05:49
d87035e Bump activemodel from 6.1.4 to 6.1.4.1 dependabot[bot] 2021-08-19 21:06:14
b7fea78 Bump ffaker from 2.18.0 to 2.19.0 dependabot[bot] 2021-08-17 21:06:46
d18d4be Bump webmock from 3.13.0 to 3.14.0 dependabot[bot] 2021-08-05 21:06:19
b62170b Bump addressable from 2.7.0 to 2.8.0 dependabot[bot] 2021-07-13 02:42:14
bf879c7 Bump rake from 13.0.3 to 13.0.6 dependabot[bot] 2021-07-09 21:06:29
0004df6 Bump bundler-audit from 0.7.0.1 to 0.8.0 dependabot[bot] 2021-06-10 05:53:12
33c530c Bump webmock from 3.11.2 to 3.13.0 dependabot[bot] 2021-06-09 22:05:46
9083f79 Bump ruby-prof from 1.4.2 to 1.4.3 dependabot[bot] 2021-06-09 22:04:12
963e6d3 Bump ffaker from 2.17.0 to 2.18.0 dependabot[bot] 2021-06-09 22:02:01
c0b7c06 chore: enable dependabot mo khan 2021-06-09 22:01:14
1bfad5e Bump nokogiri from 1.11.1 to 1.11.7 dependabot[bot] 2021-06-09 21:56:02
b138a59 Bump rexml from 3.2.4 to 3.2.5 dependabot[bot] 2021-04-30 22:02:55
.github/workflows/ci.yml
@@ -2,43 +2,35 @@
 name: Continuous Integration
 on:
   push:
-    branches: [main]
   pull_request:
-    branches: [main]
 jobs:
   test:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        ruby-version: ['2.5', '2.6', '2.7']
+        ruby-version: ['2.7', '3.0', '3.1']
     steps:
       - uses: actions/checkout@v2
-      - name: Set up Ruby
-        uses: ruby/setup-ruby@v1
+      - uses: ruby/setup-ruby@v1
         with:
           ruby-version: ${{ matrix.ruby-version }}
           bundler-cache: true
-      - name: Running tests…
-        run: sh bin/test
+      - run: sh bin/test
   style:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v2
-      - name: Set up Ruby
-        uses: ruby/setup-ruby@v1
+      - uses: ruby/setup-ruby@v1
         with:
           ruby-version: '2.7'
           bundler-cache: true
-      - name: Running style checks…
-        run: sh bin/style
+      - run: sh bin/style
   audit:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v2
-      - name: Set up Ruby
-        uses: ruby/setup-ruby@v1
+      - uses: ruby/setup-ruby@v1
         with:
           ruby-version: '2.7'
           bundler-cache: true
-      - name: Running audit…
-        run: sh bin/audit
+      - run: sh bin/audit
.github/dependabot.yml
@@ -0,0 +1,9 @@
+---
+version: 2
+updates:
+  - package-ecosystem: "bundler"
+    directory: "/"
+    schedule:
+      interval: "daily"
+    assignees:
+      - "xlgmokha"
lib/saml/kit/concerns/buildable.rb
@@ -9,20 +9,20 @@ module Saml
       extend ActiveSupport::Concern
 
       class_methods do
-        def build(*args)
-          builder(*args) do |builder|
+        def build(*args, **kwargs)
+          builder(*args, **kwargs) do |builder|
             yield builder if block_given?
           end.build
         end
 
-        def build_xml(*args)
-          builder(*args) do |builder|
+        def build_xml(*args, **kwargs)
+          builder(*args, **kwargs) do |builder|
             yield builder if block_given?
           end.to_xml
         end
 
-        def builder(*args)
-          builder_class.new(*args).tap do |builder|
+        def builder(*args, **kwargs)
+          builder_class.new(*args, **kwargs).tap do |builder|
             yield builder if block_given?
           end
         end
lib/saml/kit/concerns/translatable.rb
@@ -9,7 +9,7 @@ module Saml
       # @!visibility private
       def error_message(attribute, options = {})
         default_options = { scope: "saml/kit.errors.#{name}" }
-        I18n.translate(attribute, default_options.merge(options))
+        I18n.translate(attribute, **default_options.merge(options))
       end
     end
   end
lib/saml/kit/concerns/trustable.rb
@@ -53,7 +53,7 @@ module Saml
         return unless signature.present?
 
         signature.valid?
-        signature.errors.each do |attribute, error|
+        signature.each_error do |attribute, error|
           errors.add(attribute, error)
         end
       end
lib/saml/kit/concerns/validatable.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module Saml
+  module Kit
+    # This module is responsible for
+    # providing an adapter to the ActiveModel::Validations
+    # module.
+    module Validatable
+      extend ActiveSupport::Concern
+      include ActiveModel::Validations
+
+      def each_error
+        if Gem::Requirement.new('>= 6.1').satisfied_by?(ActiveModel.version)
+          errors.each do |error|
+            yield error.attribute, error.message
+          end
+        else
+          errors.each do |attribute, message|
+            yield attribute, message
+          end
+        end
+      end
+    end
+  end
+end
lib/saml/kit/assertion.rb
@@ -126,7 +126,7 @@ module Saml
       def must_have_valid_signature
         return if !signed? || signature.valid?
 
-        signature.errors.each do |attribute, message|
+        signature.each_error do |attribute, message|
           errors.add(attribute, message)
         end
       end
lib/saml/kit/composite_metadata.rb
@@ -51,9 +51,9 @@ module Saml
         @metadatum.each(&block)
       end
 
-      def method_missing(name, *args)
+      def method_missing(name, *args, **kwargs)
         if (target = find { |x| x.respond_to?(name) })
-          target.public_send(name, *args)
+          target.public_send(name, *args, **kwargs)
         else
           super
         end
lib/saml/kit/document.rb
@@ -4,7 +4,7 @@ module Saml
   module Kit
     # This class is a base class for SAML documents.
     class Document
-      include ActiveModel::Validations
+      include Validatable
       include Buildable
       include Translatable
       include Trustable
lib/saml/kit/metadata.rb
@@ -26,7 +26,7 @@ module Saml
     # for a list of options that can be specified.
     # {include:file:spec/examples/metadata_spec.rb}
     class Metadata
-      include ActiveModel::Validations
+      include Validatable
       include Buildable
       include Translatable
       include XmlParseable
@@ -192,7 +192,7 @@ module Saml
       def must_have_valid_signature
         return if !signature.present? || signature.valid?
 
-        signature.errors.each do |attribute, error|
+        signature.each_error do |attribute, error|
           errors.add(attribute, error)
         end
       end
lib/saml/kit/null_assertion.rb
@@ -6,7 +6,7 @@ module Saml
     # Null Object pattern for when a Response
     # is missing an Assertion.
     class NullAssertion
-      include ActiveModel::Validations
+      include Validatable
       include Translatable
       validate :invalid
 
lib/saml/kit/response.rb
@@ -43,9 +43,8 @@ module Saml
 
       def must_be_valid_assertion
         assertion.valid?
-        assertion.errors.each do |attribute, error|
-          attribute = :assertion if attribute == :base
-          errors.add(attribute, error)
+        assertion.each_error do |attribute, error|
+          errors.add(attribute == :base ? :assertion : attribute, error)
         end
       end
 
lib/saml/kit/signature.rb
@@ -6,7 +6,7 @@ module Saml
     # validating an xml digital signature
     # in an xml document.
     class Signature
-      include ActiveModel::Validations
+      include Validatable
       include Translatable
 
       validate :validate_signature
lib/saml/kit/version.rb
@@ -2,6 +2,6 @@
 
 module Saml
   module Kit
-    VERSION = '1.2.0'
+    VERSION = '1.3.0'
   end
 end
lib/saml/kit.rb
@@ -23,6 +23,7 @@ require 'saml/kit/concerns/respondable'
 require 'saml/kit/concerns/serializable'
 require 'saml/kit/concerns/translatable'
 require 'saml/kit/concerns/trustable'
+require 'saml/kit/concerns/validatable'
 require 'saml/kit/concerns/xml_parseable'
 require 'saml/kit/concerns/xml_templatable'
 require 'saml/kit/concerns/xsd_validatable'
spec/saml/kit/bindings/http_redirect_spec.rb
@@ -94,7 +94,7 @@ RSpec.describe Saml::Kit::Bindings::HttpRedirect do
 
     it 'returns an invalid request when the SAMLRequest is invalid' do
       expect do
-        subject.deserialize('SAMLRequest' => 'nonsense')
+        subject.deserialize({ 'SAMLRequest' => 'nonsense' })
       end.to raise_error(Zlib::DataError)
     end
 
@@ -115,7 +115,7 @@ RSpec.describe Saml::Kit::Bindings::HttpRedirect do
 
     it 'raises an error when the content is invalid' do
       expect do
-        subject.deserialize('SAMLResponse' => 'nonsense')
+        subject.deserialize({ 'SAMLResponse' => 'nonsense' })
       end.to raise_error(Zlib::DataError)
     end
 
spec/saml/kit/response_spec.rb
@@ -546,7 +546,7 @@ RSpec.describe Saml::Kit::Response do
 
     it 'parses the name id safely (CVE-2017-11428)' do
       raw = IO.read('spec/fixtures/response_node_text_attack.xml.base64')
-      subject = Saml::Kit::Bindings::HttpPost.new(location: '').deserialize('SAMLResponse' => raw)
+      subject = Saml::Kit::Bindings::HttpPost.new(location: '').deserialize({ 'SAMLResponse' => raw })
       expect(subject.name_id).to eql('support@onelogin.com')
       expect(subject.attributes[:surname]).to eql('smith')
     end
.rubocop.yml
@@ -12,7 +12,7 @@ AllCops:
     - 'spec/examples/**/*'
     - 'tmp/**/*'
     - 'vendor/**/*'
-  TargetRubyVersion: 2.5
+  TargetRubyVersion: 2.7
 
 Layout/ArgumentAlignment:
   EnforcedStyle: with_fixed_indentation
CHANGELOG.md
@@ -1,4 +1,4 @@
-Version 1.2.0
+Version 1.3.0
 
 # Changelog
 All notable changes to this project will be documented in this file.
@@ -8,6 +8,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
+## [1.3.0] - 2022-03-30
+### Removed
+
+- Drop support for ruby 2.6
+- Drop support for ruby 2.5
+
+### Changed
+
+- fix: upgrade to Ruby 2.7+ `*args` syntax.
+- fix: resolve deprecation warnings
+
 ## [1.2.0] - 2021-02-04
 ### Changed
 - Use [ActiveModel::Errors#add](https://www.rubydoc.info/docs/rails/ActiveModel%2FErrors:add)
@@ -87,7 +98,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 ### Removed
 - Removed optional SessionNotOnOrAfter attribute from AuthnStatement.
 
-[Unreleased]: https://github.com/xlgmokha/saml-kit/compare/v1.2.0...HEAD
+[Unreleased]: https://github.com/xlgmokha/saml-kit/compare/v1.3.0...HEAD
+[1.3.0]: https://github.com/xlgmokha/saml-kit/compare/v1.2.0...v1.3.0
 [1.2.0]: https://github.com/xlgmokha/saml-kit/compare/v1.1.0...v1.2.0
 [1.1.0]: https://github.com/xlgmokha/saml-kit/compare/v1.0.31...v1.1.0
 [1.0.31]: https://github.com/xlgmokha/saml-kit/compare/v1.0.30...v1.0.31
Gemfile.lock
@@ -1,71 +1,74 @@
 PATH
   remote: .
   specs:
-    saml-kit (1.2.0)
-      activemodel (~> 5.1)
-      net-hippie (~> 0.1)
+    saml-kit (1.3.0)
+      activemodel (>= 5.1, < 8.0)
+      net-hippie (>= 0.1, < 2.0)
       xml-kit (~> 0.4)
 
 GEM
   remote: https://rubygems.org/
   specs:
-    activemodel (5.2.4.4)
-      activesupport (= 5.2.4.4)
-    activesupport (5.2.4.4)
+    activemodel (6.1.5)
+      activesupport (= 6.1.5)
+    activesupport (6.1.5)
       concurrent-ruby (~> 1.0, >= 1.0.2)
-      i18n (>= 0.7, < 2)
-      minitest (~> 5.1)
-      tzinfo (~> 1.1)
-    addressable (2.7.0)
+      i18n (>= 1.6, < 2)
+      minitest (>= 5.1)
+      tzinfo (~> 2.0)
+      zeitwerk (~> 2.3)
+    addressable (2.8.0)
       public_suffix (>= 2.0.2, < 5.0)
     ast (2.4.2)
     benchmark-malloc (0.2.0)
     benchmark-perf (0.6.0)
     benchmark-trend (0.4.0)
     builder (3.2.4)
-    bundler-audit (0.7.0.1)
+    bundler-audit (0.9.0.1)
       bundler (>= 1.2.0, < 3)
-      thor (>= 0.18, < 2)
-    concurrent-ruby (1.1.8)
+      thor (~> 1.0)
+    concurrent-ruby (1.1.10)
     crack (0.4.5)
       rexml
-    diff-lcs (1.4.4)
+    diff-lcs (1.5.0)
     docile (1.3.5)
-    ffaker (2.17.0)
+    ffaker (2.20.0)
     hashdiff (1.0.1)
-    i18n (1.8.8)
+    i18n (1.10.0)
       concurrent-ruby (~> 1.0)
-    minitest (5.14.3)
-    net-hippie (0.3.2)
-    nokogiri (1.11.1-x86_64-linux)
+    mini_portile2 (2.8.0)
+    minitest (5.15.0)
+    net-hippie (1.1.1)
+    nokogiri (1.13.3)
+      mini_portile2 (~> 2.8.0)
       racc (~> 1.4)
     parallel (1.20.1)
     parser (3.0.0.0)
       ast (~> 2.4.1)
     public_suffix (4.0.6)
-    racc (1.5.2)
+    racc (1.6.0)
     rainbow (3.0.0)
-    rake (13.0.3)
+    rake (13.0.6)
     regexp_parser (2.0.3)
-    rexml (3.2.4)
-    rspec (3.10.0)
-      rspec-core (~> 3.10.0)
-      rspec-expectations (~> 3.10.0)
-      rspec-mocks (~> 3.10.0)
+    rexml (3.2.5)
+    rspec (3.11.0)
+      rspec-core (~> 3.11.0)
+      rspec-expectations (~> 3.11.0)
+      rspec-mocks (~> 3.11.0)
     rspec-benchmark (0.6.0)
       benchmark-malloc (~> 0.2)
       benchmark-perf (~> 0.6)
       benchmark-trend (~> 0.4)
       rspec (>= 3.0)
-    rspec-core (3.10.1)
-      rspec-support (~> 3.10.0)
-    rspec-expectations (3.10.1)
+    rspec-core (3.11.0)
+      rspec-support (~> 3.11.0)
+    rspec-expectations (3.11.0)
       diff-lcs (>= 1.2.0, < 2.0)
-      rspec-support (~> 3.10.0)
-    rspec-mocks (3.10.2)
+      rspec-support (~> 3.11.0)
+    rspec-mocks (3.11.0)
       diff-lcs (>= 1.2.0, < 2.0)
-      rspec-support (~> 3.10.0)
-    rspec-support (3.10.2)
+      rspec-support (~> 3.11.0)
+    rspec-support (3.11.0)
     rubocop (0.93.1)
       parallel (~> 1.10)
       parser (>= 2.7.1.5)
@@ -80,7 +83,7 @@ GEM
     rubocop-rspec (1.44.1)
       rubocop (~> 0.87)
       rubocop-ast (>= 0.7.1)
-    ruby-prof (1.4.2)
+    ruby-prof (1.4.3)
     ruby-progressbar (1.11.0)
     simplecov (0.21.2)
       docile (~> 1.1)
@@ -89,13 +92,12 @@ GEM
     simplecov-html (0.12.3)
     simplecov_json_formatter (0.1.2)
     thor (1.1.0)
-    thread_safe (0.3.6)
     tilt (2.0.10)
-    tzinfo (1.2.9)
-      thread_safe (~> 0.1)
+    tzinfo (2.0.4)
+      concurrent-ruby (~> 1.0)
     unicode-display_width (1.7.0)
-    webmock (3.11.2)
-      addressable (>= 2.3.6)
+    webmock (3.14.0)
+      addressable (>= 2.8.0)
       crack (>= 0.3.2)
       hashdiff (>= 0.4.0, < 2.0.0)
     xml-kit (0.5.0)
@@ -106,6 +108,7 @@ GEM
       xmldsig (~> 0.6)
     xmldsig (0.6.6)
       nokogiri (>= 1.6.8, < 2.0.0)
+    zeitwerk (2.5.4)
 
 PLATFORMS
   ruby
saml-kit.gemspec
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
   spec.description   = 'A simple toolkit for working with SAML.'
   spec.homepage      = 'https://github.com/xlgmokha/saml-kit'
   spec.license       = 'MIT'
-  spec.required_ruby_version = '~> 2.5'
+  spec.required_ruby_version = '>= 2.7.0'
 
   spec.files = `git ls-files -z`.split("\x0").reject do |f|
     (
@@ -28,8 +28,8 @@ Gem::Specification.new do |spec|
   spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
   spec.require_paths = ['lib']
 
-  spec.add_dependency 'activemodel', '~> 5.1'
-  spec.add_dependency 'net-hippie', '~> 0.1'
+  spec.add_dependency 'activemodel', '>= 5.1', '< 8.0'
+  spec.add_dependency 'net-hippie', '>= 0.1', '< 2.0'
   spec.add_dependency 'xml-kit', '~> 0.4'
   spec.add_development_dependency 'bundler', '~> 2.0'
   spec.add_development_dependency 'bundler-audit', '~> 0.6'