spec/rails/auth/x509/middleware_spec.rb in rails-auth-2.1.4 vs spec/rails/auth/x509/middleware_spec.rb in rails-auth-2.2.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require "logger" RSpec.describe Rails::Auth::X509::Middleware do let(:request) { Rack::MockRequest.env_for("https://www.example.com") } let(:app) { ->(env) { [200, env, "Hello, world!"] } } @@ -47,13 +49,15 @@ let(:example_key) { "javax.servlet.request.X509Certificate" } let(:cert_filter) { :java } let(:java_cert) do ruby_cert = OpenSSL::X509::Certificate.new(valid_cert_pem) - Java::SunSecurityX509::X509CertImpl.new(ruby_cert.to_der.to_java_bytes) + input_stream = Java::JavaIO::ByteArrayInputStream.new(ruby_cert.to_der.to_java_bytes) + java_cert_klass = Java::JavaSecurityCert::CertificateFactory.getInstance("X.509") + java_cert_klass.generateCertificate(input_stream) end - it "extracts Rails::Auth::Credential::X509 from a Java::SunSecurityX509::X509CertImpl" do + it "extracts Rails::Auth::Credential::X509 from a java.security.cert.Certificate" do skip "JRuby only" unless defined?(JRUBY_VERSION) _response, env = middleware.call(request.merge(example_key => [java_cert])) credential = Rails::Auth.credentials(env).fetch("x509")