Module: Rails::Auth::RSpec::HelperMethods
- Defined in:
- lib/rails/auth/rspec/helper_methods.rb
Overview
RSpec helper methods
Instance Method Summary collapse
-
#x509_certificate(cn: nil, ou: nil) ⇒ Object
Creates an Rails::Auth::X509::Certificate instance double.
-
#x509_certificate_hash(**args) ⇒ Object
Creates a certificates hash containing a single X.509 certificate instance double.
Instance Method Details
#x509_certificate(cn: nil, ou: nil) ⇒ Object
Creates an Rails::Auth::X509::Certificate instance double
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rails/auth/rspec/helper_methods.rb', line 7 def x509_certificate(cn: nil, ou: nil) subject = "" subject << "CN=#{cn}" if cn subject << "OU=#{ou}" if ou instance_double(Rails::Auth::X509::Certificate, subject, cn: cn, ou: ou).tap do |certificate| allow(certificate).to receive(:[]) do |key| { "CN" => cn, "OU" => ou }[key.to_s.upcase] end end end |
#x509_certificate_hash(**args) ⇒ Object
Creates a certificates hash containing a single X.509 certificate instance double
23 24 25 |
# File 'lib/rails/auth/rspec/helper_methods.rb', line 23 def x509_certificate_hash(**args) { "x509" => x509_certificate(**args) } end |