Skip to content
Browse files

add mechanize ssl config

  • Loading branch information...
1 parent db1c07a commit 6e491524487c8fd1b25c51c15a9f6d90c29d530c mcrmfc committed Aug 17, 2011
Showing with 6 additions and 8 deletions.
  1. +4 −7 lib/frameworks/capybara.rb
  2. +2 −1 lib/monkey-patches/mechanize-patches.rb
View
11 lib/frameworks/capybara.rb
@@ -17,7 +17,7 @@ class CapybaraSetup
def initialize
- capybara_opts = {:environment => ENV['ENVIRONMENT'], :proxy => ENV['PROXY_URL'], :remote_browser_proxy_url => ENV['REMOTE_BROWSER_PROXY_URL'], :platform => ENV['PLATFORM'], :browser_name => ENV['REMOTE_BROWSER'], :version => ENV['REMOTE_BROWSER_VERSION'], :url => ENV['REMOTE_URL'], :profile => ENV['FIREFOX_PROFILE'], :browser => ENV['BROWSER'], :javascript_enabled => ENV['CELERITY_JS_ENABLED'], :job_name => ENV['SAUCE_JOB_NAME'], :max_duration => ENV['SAUCE_MAX_DURATION'], :proxy_on => ENV['PROXY_ON'], :cert_location => ENV['CERT_LOCATION']}
+ capybara_opts = {:environment => ENV['ENVIRONMENT'], :proxy => ENV['PROXY_URL'], :remote_browser_proxy_url => ENV['REMOTE_BROWSER_PROXY_URL'], :platform => ENV['PLATFORM'], :browser_name => ENV['REMOTE_BROWSER'], :version => ENV['REMOTE_BROWSER_VERSION'], :url => ENV['REMOTE_URL'], :profile => ENV['FIREFOX_PROFILE'], :browser => ENV['BROWSER'], :javascript_enabled => ENV['CELERITY_JS_ENABLED'], :job_name => ENV['SAUCE_JOB_NAME'], :max_duration => ENV['SAUCE_MAX_DURATION'], :proxy_on => ENV['PROXY_ON'], :cert_location => ENV['CERT_LOCATION'], :ca_cert_location => ENV['CA_CERT_LOCATION']}
validate_env_vars(capybara_opts) #validate environment variables set using cucumber.yml or passed via command line
@@ -40,12 +40,9 @@ def initialize
Capybara.default_driver = @driver
- if capybara_opts[:browser] == :mechanize and capybara_opts[:proxy]
- Capybara.current_session.driver.agent.set_proxy(@proxy_host, 80)
- end
-
- if capybara_opts[:browser] == :mechanize and capybara_opts[:cert_location]
- Capybara.current_session.driver.agent.set_ssl_client_certification(ENV['CERT_LOCATION'], ENV['CERT_LOCATION'])
+ if capybara_opts[:browser] == :mechanize
+ Capybara.current_session.driver.agent.set_proxy(@proxy_host, 80) if capybara_opts[:proxy]
+ Capybara.current_session.driver.agent.set_ssl_client_certification(capybara_opts[:cert_location], capybara_opts[:cert_location], capybara_opts[:ca_cert_location]) if capybara_opts[:cert_location]
end
end
View
3 lib/monkey-patches/mechanize-patches.rb
@@ -1,6 +1,7 @@
require 'mechanize'
class Mechanize
- def set_ssl_client_certification(clientcert, clientkey)
+ def set_ssl_client_certification(clientcert, clientkey, cacert)
@cert, @key = clientcert, clientkey
+ @ca_file = cacert if cacert
end
end

0 comments on commit 6e49152

Please sign in to comment.
Something went wrong with that request. Please try again.