Skip to content

Commit

Permalink
Merge pull request #609 from johnnyshields/drop-eol-ruby-support
Browse files Browse the repository at this point in the history
Drop support for Ruby < 2.6 and JRuby < 9.3
  • Loading branch information
pitbulk committed Mar 7, 2023
2 parents c9685a9 + 25a9493 commit 4620c53
Show file tree
Hide file tree
Showing 23 changed files with 72 additions and 157 deletions.
26 changes: 24 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,27 @@ 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
ruby-version: [2.6, 2.7, 3.0, 3.1, 3.2, jruby-9.3, jruby-9.4, truffleruby]
include:
- os: macos-latest
ruby-version: 2.6
- os: macos-latest
ruby-version: 2.7
- os: macos-latest
ruby-version: 3.0
- os: macos-latest
ruby-version: 3.1
- os: macos-latest
ruby-version: 3.2
- os: macos-latest
ruby-version: jruby-9.3
# 2023/03/07 - JRuby 9.4 on MacOS is skipped for now.
# Seems to be a JRuby-side issue.
# - os: macos-latest
# ruby-version: jruby-9.4
- os: macos-latest
ruby-version: truffleruby
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand All @@ -26,6 +45,9 @@ jobs:

- name: Coveralls
uses: coverallsapp/github-action@master
# 2023/03/07 - Simplecov is not working on TruffleRuby.
# TruffleRuby tests are otherwise passing.
if: ${{ matrix.ruby-version != 'truffleruby' }}
with:
github-token: ${{ secrets.github_token }}
parallel: true
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Ruby SAML Changelog

### 1.15.0 (Jan 04, 2023)
* [#650](https://github.com/SAML-Toolkits/ruby-saml/pull/650) Replace strip! by strip on compute_digest method
* [#638](https://github.com/SAML-Toolkits/ruby-saml/pull/638) Fix dateTime format for the validUntil attribute of the generated metadata
Expand Down
8 changes: 7 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#
# Please keep this file alphabetized and organized
#
source 'https://rubygems.org'

gemspec

gem 'minitest', '~> 5.18', require: false
gem 'mocha', '~> 2.0', require: false
gem 'rake', '~> 13.0'
gem 'simplecov', '~> 0.22', require: false
gem 'simplecov-lcov', '~> 0.8', require: false
gem 'timecop', '~> 0.9', require: false
27 changes: 6 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,16 @@ We created a demo project for Rails 4 that uses the latest version of this libra

### Supported Ruby Versions

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
* 2.6
* 2.7
* 3.0
* 3.1
* 3.2
* JRuby 9.1.x
* JRuby 9.2.x
* JRuby 9.3.X
* JRuby 9.4.0
* JRuby 9.3
* JRuby 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
For older Ruby support, please refer to older major versions of Ruby SAML.

## Adding Features, Pull Requests

Expand Down
6 changes: 0 additions & 6 deletions lib/onelogin/ruby-saml/idp_metadata_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,6 @@ def get_idp_metadata(url, validate_cert)
http.use_ssl = true
# Most IdPs will probably use self signed certs
http.verify_mode = validate_cert ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE

# Net::HTTP in Ruby 1.8 did not set the default certificate store
# automatically when VERIFY_PEER was specified.
if RUBY_VERSION < '1.9' && !http.ca_file && !http.ca_path && !http.cert_store
http.cert_store = OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE
end
end

get = Net::HTTP::Get.new(uri.request_uri)
Expand Down
7 changes: 1 addition & 6 deletions lib/onelogin/ruby-saml/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -973,12 +973,7 @@ def generate_decrypted_document
raise ValidationError.new('An EncryptedAssertion found and no SP private key found on the settings to decrypt it. Be sure you provided the :settings parameter at the initialize method')
end

# Marshal at Ruby 1.8.7 throw an Exception
if RUBY_VERSION < "1.9"
document_copy = XMLSecurity::SignedDocument.new(response, errors)
else
document_copy = Marshal.load(Marshal.dump(document))
end
document_copy = Marshal.load(Marshal.dump(document))

decrypt_assertion_from_document(document_copy)
end
Expand Down
12 changes: 2 additions & 10 deletions lib/onelogin/ruby-saml/utils.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
if RUBY_VERSION < '1.9'
require 'uuid'
else
require 'securerandom'
end
require 'securerandom'
require "openssl"

module OneLogin
Expand All @@ -11,8 +7,6 @@ module RubySaml
# SAML2 Auxiliary class
#
class Utils
@@uuid_generator = UUID.new if RUBY_VERSION < '1.9'

BINDINGS = { :post => "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST".freeze,
:redirect => "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect".freeze }.freeze
DSIG = "http://www.w3.org/2000/09/xmldsig#".freeze
Expand Down Expand Up @@ -56,8 +50,6 @@ def self.is_cert_expired(cert)
# @return [Integer] The new timestamp, after the duration is applied.
#
def self.parse_duration(duration, timestamp=Time.now.utc)
return nil if RUBY_VERSION < '1.9' # 1.8.7 not supported

matches = duration.match(DURATION_FORMAT)

if matches.nil?
Expand Down Expand Up @@ -348,7 +340,7 @@ def self.set_prefix(value)
end

def self.uuid
"#{UUID_PREFIX}" + (RUBY_VERSION < '1.9' ? "#{@@uuid_generator.generate}" : "#{SecureRandom.uuid}")
"#{UUID_PREFIX}#{SecureRandom.uuid}"
end

# Given two strings, attempt to match them as URIs using Rails' parse method. If they can be parsed,
Expand Down
82 changes: 3 additions & 79 deletions ruby-saml.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,85 +20,9 @@ Gem::Specification.new do |s|
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.7}
s.required_ruby_version = '>= 1.8.7'
s.required_ruby_version = '>= 2.6.0'
s.summary = %q{SAML Ruby Tookit}

# Because runtime dependencies are determined at build time, we cannot make
# Nokogiri's version dependent on the Ruby version, even though we would
# have liked to constrain Ruby 1.8.7 to install only the 1.5.x versions.
if defined?(JRUBY_VERSION)
if JRUBY_VERSION < '9.1.7.0'
s.add_runtime_dependency('nokogiri', '>= 1.8.2', '<= 1.8.5')
s.add_runtime_dependency('jruby-openssl', '>= 0.9.8')
s.add_runtime_dependency('json', '< 2.3.0')
elsif JRUBY_VERSION < '9.2.0.0'
s.add_runtime_dependency('nokogiri', '>= 1.9.1', '< 1.10.0')
elsif JRUBY_VERSION < '9.3.2.0'
s.add_runtime_dependency('nokogiri', '>= 1.11.4')
s.add_runtime_dependency('rexml')
else
s.add_runtime_dependency('nokogiri', '>= 1.13.10')
s.add_runtime_dependency('rexml')
end
elsif RUBY_VERSION < '1.9'
s.add_runtime_dependency('uuid')
s.add_runtime_dependency('nokogiri', '<= 1.5.11')
elsif RUBY_VERSION < '2.1'
s.add_runtime_dependency('nokogiri', '>= 1.5.10', '<= 1.6.8.1')
s.add_runtime_dependency('json', '< 2.3.0')
elsif RUBY_VERSION < '2.3'
s.add_runtime_dependency('nokogiri', '>= 1.9.1', '< 1.10.0')
elsif RUBY_VERSION < '2.5'
s.add_runtime_dependency('nokogiri', '>= 1.10.10', '< 1.11.0')
s.add_runtime_dependency('rexml')
elsif RUBY_VERSION < '2.6'
s.add_runtime_dependency('nokogiri', '>= 1.11.4')
s.add_runtime_dependency('rexml')
else
s.add_runtime_dependency('nokogiri', '>= 1.13.10')
s.add_runtime_dependency('rexml')
end

s.add_development_dependency('simplecov', '<0.22.0')
if RUBY_VERSION < '2.4.1'
s.add_development_dependency('simplecov-lcov', '<0.8.0')
else
s.add_development_dependency('simplecov-lcov', '>0.7.0')
end

s.add_development_dependency('minitest', '~> 5.5')
s.add_development_dependency('mocha', '~> 0.14')

if RUBY_VERSION < '2.0'
s.add_development_dependency('rake', '~> 10')
else
s.add_development_dependency('rake', '>= 12.3.3')
end

s.add_development_dependency('shoulda', '~> 2.11')
s.add_development_dependency('systemu', '~> 2')

if RUBY_VERSION < '2.1'
s.add_development_dependency('timecop', '<= 0.6.0')
else
s.add_development_dependency('timecop', '~> 0.9')
end

if defined?(JRUBY_VERSION)
# All recent versions of JRuby play well with pry
s.add_development_dependency('pry')
elsif RUBY_VERSION < '1.9'
# 1.8.7
s.add_development_dependency('ruby-debug', '~> 0.10.4')
elsif RUBY_VERSION < '2.0'
# 1.9.x
s.add_development_dependency('debugger-linecache', '~> 1.2.0')
s.add_development_dependency('debugger', '~> 1.6.4')
elsif RUBY_VERSION < '2.1'
# 2.0.x
s.add_development_dependency('byebug', '~> 2.1.1')
else
# 2.1.x, 2.2.x
s.add_development_dependency('pry-byebug')
end
s.add_dependency('nokogiri', '>= 1.13.10')
s.add_dependency('rexml')
end
2 changes: 1 addition & 1 deletion test/attributes_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
require_relative 'test_helper'

require 'onelogin/ruby-saml/attributes'

Expand Down
5 changes: 1 addition & 4 deletions test/idp_metadata_parser_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
require_relative 'test_helper'

require 'onelogin/ruby-saml/idp_metadata_parser'

Expand Down Expand Up @@ -419,16 +419,13 @@ def initialize; end
end

it "if no ValidUntil but CacheDuration return CacheDuration converted in ValidUntil" do
return if RUBY_VERSION < '1.9'
Timecop.freeze(Time.parse("2020-01-02T10:02:33Z", Time.now.utc)) do
settings = @idp_metadata_parser.parse(idp_metadata_descriptor5)
assert_equal '2020-01-03T10:02:33Z', settings.valid_until
end
end

it "if ValidUntil and CacheDuration return the sooner timestamp" do
return if RUBY_VERSION < '1.9'

Timecop.freeze(Time.parse("2020-01-01T10:12:55Z", Time.now.utc)) do
settings = @idp_metadata_parser.parse(idp_metadata_descriptor6)
assert_equal '2020-01-03T10:12:55Z', settings.valid_until
Expand Down
2 changes: 1 addition & 1 deletion test/logging_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
require_relative 'test_helper'

require 'onelogin/ruby-saml/logging'

Expand Down
2 changes: 1 addition & 1 deletion test/logoutrequest_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
require_relative 'test_helper'

require 'onelogin/ruby-saml/logoutrequest'

Expand Down
2 changes: 1 addition & 1 deletion test/logoutresponse_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
require_relative 'test_helper'

require 'onelogin/ruby-saml/logoutresponse'
require 'logout_responses/logoutresponse_fixtures'
Expand Down
2 changes: 1 addition & 1 deletion test/metadata_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
require_relative 'test_helper'

require 'onelogin/ruby-saml/metadata'

Expand Down
2 changes: 1 addition & 1 deletion test/request_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
require_relative 'test_helper'

require 'onelogin/ruby-saml/authrequest'
require 'onelogin/ruby-saml/setting_error'
Expand Down
2 changes: 1 addition & 1 deletion test/response_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
require_relative 'test_helper'

require 'onelogin/ruby-saml/response'

Expand Down
2 changes: 1 addition & 1 deletion test/saml_message_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
require_relative 'test_helper'

class RubySamlTest < Minitest::Test

Expand Down
2 changes: 1 addition & 1 deletion test/settings_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
require_relative 'test_helper'

require 'onelogin/ruby-saml/settings'
require 'onelogin/ruby-saml/validation_error'
Expand Down
2 changes: 1 addition & 1 deletion test/slo_logoutrequest_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
require_relative 'test_helper'
require 'logout_responses/logoutresponse_fixtures'

require 'onelogin/ruby-saml/slo_logoutrequest'
Expand Down
2 changes: 1 addition & 1 deletion test/slo_logoutresponse_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
require_relative 'test_helper'

require 'onelogin/ruby-saml/slo_logoutresponse'

Expand Down
26 changes: 14 additions & 12 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
require 'simplecov'
require 'simplecov-lcov'

SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
SimpleCov::Formatter::LcovFormatter.config.output_directory = 'coverage'
SimpleCov::Formatter::LcovFormatter.config.lcov_file_name = 'lcov.info'
SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
SimpleCov.start do
add_filter "test/"
add_filter "vendor/"
add_filter "lib/onelogin/ruby-saml/logging.rb"
# 2023/03/07 - Simplecov is not working on TruffleRuby.
unless defined?(TruffleRuby)
require 'simplecov'
require 'simplecov-lcov'
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
SimpleCov::Formatter::LcovFormatter.config.output_directory = 'coverage'
SimpleCov::Formatter::LcovFormatter.config.lcov_file_name = 'lcov.info'
SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
SimpleCov.start do
add_filter "test/"
add_filter "vendor/"
add_filter "lib/onelogin/ruby-saml/logging.rb"
end
end

require 'stringio'
require 'rubygems'
require 'bundler'
require 'minitest/autorun'
require 'mocha/setup'
require 'mocha/minitest'
require 'timecop'

Bundler.require :default, :test
Expand Down

0 comments on commit 4620c53

Please sign in to comment.