From 0f8da708b4f913e8a8c4e86f2067299f774e4fa6 Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:21:50 +0900 Subject: [PATCH] Fix tests on Windows and cleanup CI --- .github/workflows/test.yml | 52 +++++++++++++++++++++++++++++++-- CHANGELOG.md | 1 + README.md | 24 ++------------- lib/onelogin/ruby-saml/utils.rb | 24 +++++++++------ 4 files changed, 67 insertions(+), 34 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8181d37a..d90d6231 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,11 +8,57 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04, macos-latest] - ruby-version: [2.1.9, 2.2.10, 2.3.8, 2.4.6, 2.5.8, 2.6.6, 2.7.2, 3.0.1, 3.1, 3.2, jruby-9.1.17.0, jruby-9.2.17.0, jruby-9.3.2.0, jruby-9.4.0.0, truffleruby] + os: + - ubuntu-20.04 + - macos-latest + - windows-latest + ruby-version: + - 2.1 + - 2.2 + - 2.3 + - 2.4 + - 2.5 + - 2.6 + - 2.7 + - 3.0 + - 3.1 + - 3.2 + - 3.3 + - jruby-9.1 + - jruby-9.2 + - jruby-9.3 + - jruby-9.4 + - truffleruby + exclude: + - os: macos-latest + ruby-version: 2.1 + - os: macos-latest + ruby-version: 2.2 + - os: macos-latest + ruby-version: 2.3 + - os: macos-latest + ruby-version: 2.4 + - os: macos-latest + ruby-version: 2.5 + - os: macos-latest + ruby-version: jruby-9.1 + - os: macos-latest + ruby-version: jruby-9.2 + - os: windows-latest + ruby-version: 2.1 + - os: windows-latest + ruby-version: jruby-9.1 + - os: windows-latest + ruby-version: jruby-9.2 + - os: windows-latest + ruby-version: jruby-9.3 + - os: windows-latest + ruby-version: jruby-9.4 + - os: windows-latest + ruby-version: truffleruby runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Ruby ${{ matrix.ruby-version }} uses: ruby/setup-ruby@v1 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index f5e2b1dc..6acaa0de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Ruby SAML Changelog ### 1.17.0 +* [#687](https://github.com/SAML-Toolkits/ruby-saml/pull/687) Add CI coverage for Ruby 3.3 and Windows. * [#673](https://github.com/SAML-Toolkits/ruby-saml/pull/673) Add `Settings#sp_cert_multi` paramter to facilitate SP certificate and key rotation. * [#673](https://github.com/SAML-Toolkits/ruby-saml/pull/673) Support multiple simultaneous SP decryption keys via `Settings#sp_cert_multi` parameter. * [#673](https://github.com/SAML-Toolkits/ruby-saml/pull/673) Deprecate `Settings#certificate_new` parameter. diff --git a/README.md b/README.md index 229799ef..0a855cff 100644 --- a/README.md +++ b/README.md @@ -22,30 +22,10 @@ We created a demo project for Rails 4 that uses the latest version of this libra The following Ruby versions are covered by CI testing: -* 2.1.x -* 2.2.x -* 2.3.x -* 2.4.x -* 2.5.x -* 2.6.x -* 2.7.x -* 3.0.x -* 3.1 -* 3.2 -* JRuby 9.1.x -* JRuby 9.2.x -* JRuby 9.3.X -* JRuby 9.4.0 +* Ruby (MRI) 2.1 to 3.3 +* JRuby 9.1 to 9.4 * TruffleRuby (latest) -In addition, the following may work but are untested: - -* 1.8.7 -* 1.9.x -* 2.0.x -* JRuby 1.7.x -* JRuby 9.0.x - ## Adding Features, Pull Requests * Fork the repository diff --git a/lib/onelogin/ruby-saml/utils.rb b/lib/onelogin/ruby-saml/utils.rb index 5756e696..68ee2ed0 100644 --- a/lib/onelogin/ruby-saml/utils.rb +++ b/lib/onelogin/ruby-saml/utils.rb @@ -69,20 +69,26 @@ def self.parse_duration(duration, timestamp=Time.now.utc) matches = duration.match(DURATION_FORMAT) if matches.nil? - raise Exception.new("Invalid ISO 8601 duration") + raise StandardError.new("Invalid ISO 8601 duration") end sign = matches[1] == '-' ? -1 : 1 durYears, durMonths, durDays, durHours, durMinutes, durSeconds, durWeeks = - matches[2..8].map { |match| match ? sign * match.tr(',', '.').to_f : 0.0 } - - initial_datetime = Time.at(timestamp).utc.to_datetime - final_datetime = initial_datetime.next_year(durYears) - final_datetime = final_datetime.next_month(durMonths) - final_datetime = final_datetime.next_day((7*durWeeks) + durDays) - final_timestamp = final_datetime.to_time.utc.to_i + (durHours * 3600) + (durMinutes * 60) + durSeconds - return final_timestamp + matches[2..8].map do |match| + if match + match = match.tr(',', '.').gsub(/\.0*\z/, '') + sign * (match.include?('.') ? match.to_f : match.to_i) + else + 0 + end + end + + datetime = Time.at(timestamp).utc.to_datetime + datetime = datetime.next_year(durYears) + datetime = datetime.next_month(durMonths) + datetime = datetime.next_day((7*durWeeks) + durDays) + datetime.to_time.utc.to_i + (durHours * 3600) + (durMinutes * 60) + durSeconds end # Return a properly formatted x509 certificate