From ef8827a8d731cc14c5ef361ca8f22cc25880a407 Mon Sep 17 00:00:00 2001 From: Sixto Martin Date: Mon, 13 Jan 2025 23:03:22 +0100 Subject: [PATCH 1/2] Skip sporadic Zlib::BufError failures in JRuby tests --- test/response_test.rb | 2 +- test/slo_logoutrequest_test.rb | 2 +- test/test_helper.rb | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/test/response_test.rb b/test/response_test.rb index a6920bc8..eedbe074 100644 --- a/test/response_test.rb +++ b/test/response_test.rb @@ -1160,7 +1160,7 @@ def generate_audience_error(expected, actual) it "optionally allows for clock drift on NotOnOrAfter" do # Java Floats behave differently than MRI - java = defined?(RUBY_ENGINE) && %w[jruby truffleruby].include?(RUBY_ENGINE) + java = jruby? || truffleruby? settings.soft = true diff --git a/test/slo_logoutrequest_test.rb b/test/slo_logoutrequest_test.rb index 0415f20f..cd2b5f12 100644 --- a/test/slo_logoutrequest_test.rb +++ b/test/slo_logoutrequest_test.rb @@ -211,7 +211,7 @@ class RubySamlTest < Minitest::Test it "optionally allows for clock drift" do # Java Floats behave differently than MRI - java = defined?(RUBY_ENGINE) && %w[jruby truffleruby].include?(RUBY_ENGINE) + java = jruby? || truffleruby? logout_request.soft = true logout_request.document.root.attributes['NotOnOrAfter'] = '2011-06-14T18:31:01.516Z' diff --git a/test/test_helper.rb b/test/test_helper.rb index 1a0427f8..af0ec521 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -30,6 +30,22 @@ OneLogin::RubySaml::Logging.logger = TEST_LOGGER class Minitest::Test + def self.jruby? + defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' + end + + def jruby? + self.class.jruby? + end + + def self.truffleruby? + defined?(RUBY_ENGINE) && RUBY_ENGINE == 'truffleruby' + end + + def truffleruby? + self.class.truffleruby? + end + def fixture(document, base64 = true) response = Dir.glob(File.join(File.dirname(__FILE__), "responses", "#{document}*")).first if base64 && response =~ /\.xml$/ @@ -365,3 +381,19 @@ def downcased_escape(str) CGI.escape(str).gsub(/%[A-Fa-f0-9]{2}/) { |match| match.downcase } end end + +# Remove after https://github.com/jruby/jruby/issues/6613 is fixed +if Minitest::Test.jruby? + module JRubyZlibTestExtension + @@jruby_zlib_failures = 0 + + def run + super + rescue Zlib::BufError => e + raise e unless (@@jruby_zlib_failures += 1) < 10 + skip "Skipping Zlib::BufError in JRuby, see https://github.com/jruby/jruby/issues/6613" + end + end + + Minitest::Test.prepend(JRubyZlibTestExtension) +end \ No newline at end of file From eb146447eda9a1561197340f4972f10930ae6e94 Mon Sep 17 00:00:00 2001 From: Sixto Martin Date: Mon, 13 Jan 2025 23:22:25 +0100 Subject: [PATCH 2/2] Add implicit dependencies required for Ruby >= 3.4.0 --- ruby-saml.gemspec | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ruby-saml.gemspec b/ruby-saml.gemspec index 2ddce136..3cfd3e7c 100644 --- a/ruby-saml.gemspec +++ b/ruby-saml.gemspec @@ -59,6 +59,12 @@ Gem::Specification.new do |s| s.add_runtime_dependency('rexml') end + if RUBY_VERSION >= '3.4.0' + s.add_runtime_dependency("logger") + s.add_runtime_dependency("base64") + s.add_runtime_dependency('mutex_m') + end + s.add_development_dependency('simplecov', '<0.22.0') if RUBY_VERSION < '2.4.1' s.add_development_dependency('simplecov-lcov', '<0.8.0')