diff options
| author | mo khan <mo@mokhan.ca> | 2022-03-30 14:58:34 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2022-03-30 16:21:56 -0600 |
| commit | 45f85f64115cf522e43569451f3f4f7977c862c1 (patch) | |
| tree | 102637e5bf8332a35b4b668bae9b9af51cc1c662 | |
| parent | 6e457e266ddb0e587aaf9b4fb84b292003ba38a9 (diff) | |
feat: drop ruby 2.5 and 2.6v1.3.0
fix: upgrade to Ruby 2.7+ *args syntax.
* https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
fix: resolve deprecation warnings
* https://github.com/rails/rails/pull/32313
| -rw-r--r-- | .github/workflows/ci.yml | 22 | ||||
| -rw-r--r-- | .rubocop.yml | 2 | ||||
| -rw-r--r-- | CHANGELOG.md | 16 | ||||
| -rw-r--r-- | Gemfile.lock | 12 | ||||
| -rw-r--r-- | lib/saml/kit.rb | 1 | ||||
| -rw-r--r-- | lib/saml/kit/assertion.rb | 2 | ||||
| -rw-r--r-- | lib/saml/kit/composite_metadata.rb | 4 | ||||
| -rw-r--r-- | lib/saml/kit/concerns/buildable.rb | 12 | ||||
| -rw-r--r-- | lib/saml/kit/concerns/translatable.rb | 2 | ||||
| -rw-r--r-- | lib/saml/kit/concerns/trustable.rb | 2 | ||||
| -rw-r--r-- | lib/saml/kit/concerns/validatable.rb | 25 | ||||
| -rw-r--r-- | lib/saml/kit/document.rb | 2 | ||||
| -rw-r--r-- | lib/saml/kit/metadata.rb | 4 | ||||
| -rw-r--r-- | lib/saml/kit/null_assertion.rb | 2 | ||||
| -rw-r--r-- | lib/saml/kit/response.rb | 5 | ||||
| -rw-r--r-- | lib/saml/kit/signature.rb | 2 | ||||
| -rw-r--r-- | lib/saml/kit/version.rb | 2 | ||||
| -rw-r--r-- | saml-kit.gemspec | 2 | ||||
| -rw-r--r-- | spec/saml/kit/bindings/http_redirect_spec.rb | 4 | ||||
| -rw-r--r-- | spec/saml/kit/response_spec.rb | 2 |
20 files changed, 77 insertions, 48 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e86976c..358e9dd 100644 --- a/.github/workflows/ci.yml +++ b/.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 diff --git a/.rubocop.yml b/.rubocop.yml index 877c622..6ecb1c2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,7 +12,7 @@ AllCops: - 'spec/examples/**/*' - 'tmp/**/*' - 'vendor/**/*' - TargetRubyVersion: 2.5 + TargetRubyVersion: 2.7 Layout/ArgumentAlignment: EnforcedStyle: with_fixed_indentation diff --git a/CHANGELOG.md b/CHANGELOG.md index cda0c27..48bb5ff 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/Gemfile.lock b/Gemfile.lock index 7e2b3ed..0f3a67d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - saml-kit (1.2.0) + saml-kit (1.3.0) activemodel (>= 5.1, < 8.0) net-hippie (>= 0.1, < 2.0) xml-kit (~> 0.4) @@ -27,7 +27,7 @@ GEM bundler-audit (0.9.0.1) bundler (>= 1.2.0, < 3) thor (~> 1.0) - concurrent-ruby (1.1.9) + concurrent-ruby (1.1.10) crack (0.4.5) rexml diff-lcs (1.5.0) @@ -36,17 +36,17 @@ GEM hashdiff (1.0.1) i18n (1.10.0) concurrent-ruby (~> 1.0) - mini_portile2 (2.6.1) + mini_portile2 (2.8.0) minitest (5.15.0) net-hippie (1.1.1) - nokogiri (1.12.5) - mini_portile2 (~> 2.6.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.6) regexp_parser (2.0.3) diff --git a/lib/saml/kit.rb b/lib/saml/kit.rb index bf7f264..75edba1 100644 --- a/lib/saml/kit.rb +++ b/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' diff --git a/lib/saml/kit/assertion.rb b/lib/saml/kit/assertion.rb index 6099fb0..eff28c2 100644 --- a/lib/saml/kit/assertion.rb +++ b/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 diff --git a/lib/saml/kit/composite_metadata.rb b/lib/saml/kit/composite_metadata.rb index 2c61a29..113f7e3 100644 --- a/lib/saml/kit/composite_metadata.rb +++ b/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 diff --git a/lib/saml/kit/concerns/buildable.rb b/lib/saml/kit/concerns/buildable.rb index 32e26e2..ccbe1a2 100644 --- a/lib/saml/kit/concerns/buildable.rb +++ b/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 diff --git a/lib/saml/kit/concerns/translatable.rb b/lib/saml/kit/concerns/translatable.rb index b35f31b..38e94ba 100644 --- a/lib/saml/kit/concerns/translatable.rb +++ b/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 diff --git a/lib/saml/kit/concerns/trustable.rb b/lib/saml/kit/concerns/trustable.rb index 127570b..f6eb6c9 100644 --- a/lib/saml/kit/concerns/trustable.rb +++ b/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 diff --git a/lib/saml/kit/concerns/validatable.rb b/lib/saml/kit/concerns/validatable.rb new file mode 100644 index 0000000..26e6706 --- /dev/null +++ b/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 diff --git a/lib/saml/kit/document.rb b/lib/saml/kit/document.rb index 77b3cc3..ea0b0e7 100644 --- a/lib/saml/kit/document.rb +++ b/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 diff --git a/lib/saml/kit/metadata.rb b/lib/saml/kit/metadata.rb index cdd68cc..a3d810e 100644 --- a/lib/saml/kit/metadata.rb +++ b/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 diff --git a/lib/saml/kit/null_assertion.rb b/lib/saml/kit/null_assertion.rb index ab10619..d7a56b2 100644 --- a/lib/saml/kit/null_assertion.rb +++ b/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 diff --git a/lib/saml/kit/response.rb b/lib/saml/kit/response.rb index 31907ca..baf7df7 100644 --- a/lib/saml/kit/response.rb +++ b/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 diff --git a/lib/saml/kit/signature.rb b/lib/saml/kit/signature.rb index 395b5f2..6ec92ab 100644 --- a/lib/saml/kit/signature.rb +++ b/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 diff --git a/lib/saml/kit/version.rb b/lib/saml/kit/version.rb index 1fa1732..5a59ff1 100644 --- a/lib/saml/kit/version.rb +++ b/lib/saml/kit/version.rb @@ -2,6 +2,6 @@ module Saml module Kit - VERSION = '1.2.0' + VERSION = '1.3.0' end end diff --git a/saml-kit.gemspec b/saml-kit.gemspec index ad10e1d..52bf0a8 100644 --- a/saml-kit.gemspec +++ b/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| ( diff --git a/spec/saml/kit/bindings/http_redirect_spec.rb b/spec/saml/kit/bindings/http_redirect_spec.rb index 210e832..f37b9a3 100644 --- a/spec/saml/kit/bindings/http_redirect_spec.rb +++ b/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 diff --git a/spec/saml/kit/response_spec.rb b/spec/saml/kit/response_spec.rb index 299064b..8675ccb 100644 --- a/spec/saml/kit/response_spec.rb +++ b/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 |
