Class: EVSS::Configuration
Instance Attribute Summary
#base_request_headers, #open_timeout, #read_timeout, #request_types, #user_agent
Instance Method Summary
collapse
#base_path, #breakers_error_threshold, #breakers_exception_handler, #breakers_matcher, #breakers_service, #create_new_breakers_service, #current_module, #request_options, #service_exception, #service_name
Instance Method Details
#cert? ⇒ Boolean
38
39
40
41
42
43
|
# File 'lib/evss/configuration.rb', line 38
def cert?
Settings.evss.cert_path.present? ||
Settings.evss.key_path.present? ||
Settings.evss.root_cert_path.present?
end
|
#client_cert ⇒ Object
11
12
13
|
# File 'lib/evss/configuration.rb', line 11
def client_cert
OpenSSL::X509::Certificate.new File.read(Settings.evss.cert_path)
end
|
#client_key ⇒ Object
15
16
17
|
# File 'lib/evss/configuration.rb', line 15
def client_key
OpenSSL::PKey::RSA.new File.read(Settings.evss.key_path)
end
|
#connection ⇒ Object
58
59
60
61
62
|
# File 'lib/evss/configuration.rb', line 58
def connection
@conn ||= Faraday.new(base_path, request: request_options, ssl: ssl_options) do |faraday|
set_evss_middlewares(faraday)
end
end
|
#mock_enabled? ⇒ Boolean
64
65
66
67
|
# File 'lib/evss/configuration.rb', line 64
def mock_enabled?
false
end
|
#root_ca ⇒ Object
19
20
21
|
# File 'lib/evss/configuration.rb', line 19
def root_ca
Settings.evss.root_cert_path
end
|
#set_evss_middlewares(faraday, snakecase: true) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/evss/configuration.rb', line 45
def set_evss_middlewares(faraday, snakecase: true)
faraday.use :breakers
faraday.use EVSS::ErrorMiddleware
faraday.use Faraday::Response::RaiseError
faraday.response :betamocks if mock_enabled?
faraday.response :snakecase, symbolize: false if snakecase
faraday.response :json, content_type: /\bjson$/
faraday.use :immutable_headers
faraday.adapter Faraday.default_adapter
end
|
#ssl_options ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/evss/configuration.rb', line 23
def ssl_options
return { verify: false } if !cert? && (Rails.env.development? || Rails.env.test?)
if cert?
{
version: :TLSv1_2,
verify: true,
client_cert:,
client_key:,
ca_file: root_ca
}
end
end
|