spec/rails/auth/x509/middleware_spec.rb in rails-auth-0.0.1 vs spec/rails/auth/x509/middleware_spec.rb in rails-auth-0.1.0
- old
+ new
@@ -20,50 +20,52 @@
)
end
context "certificate types" do
describe "PEM certificates" do
- it "extracts Rails::Auth::Principal::X509 from a PEM certificate in the Rack environment" do
+ it "extracts Rails::Auth::X509::Certificate from a PEM certificate in the Rack environment" do
_response, env = middleware.call(request.merge(example_key => valid_cert_pem))
- principal = Rails::Auth.principals(env).fetch("x509")
- expect(principal).to be_a Rails::Auth::X509::Principal
+ credential = Rails::Auth.credentials(env).fetch("x509")
+ expect(credential).to be_a Rails::Auth::X509::Certificate
end
it "ignores unverified certificates" do
_response, env = middleware.call(request.merge(example_key => bad_cert_pem))
- expect(Rails::Auth.principals(env)).to be_empty
+ expect(Rails::Auth.credentials(env)).to be_empty
end
end
+ # :nocov:
describe "Java certificates" do
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)
end
- it "extracts Rails::Auth::Principal::X509 from a Java::SunSecurityX509::X509CertImpl" do
+ it "extracts Rails::Auth::Credential::X509 from a Java::SunSecurityX509::X509CertImpl" do
skip "JRuby only" unless defined?(JRUBY_VERSION)
_response, env = middleware.call(request.merge(example_key => java_cert))
- principal = Rails::Auth.principals(env).fetch("x509")
- expect(principal).to be_a Rails::Auth::X509::Principal
+ credential = Rails::Auth.credentials(env).fetch("x509")
+ expect(credential).to be_a Rails::Auth::X509::Certificate
end
end
+ # :nocov:
end
describe "require_cert: true" do
let(:cert_required) { true }
it "functions normally for valid certificates" do
_response, env = middleware.call(request.merge(example_key => valid_cert_pem))
- principal = Rails::Auth.principals(env).fetch("x509")
- expect(principal).to be_a Rails::Auth::X509::Principal
+ credential = Rails::Auth.credentials(env).fetch("x509")
+ expect(credential).to be_a Rails::Auth::X509::Certificate
end
it "raises Rails::Auth::X509::CertificateVerifyFailed for unverified certificates" do
expect do
middleware.call(request.merge(example_key => bad_cert_pem))