frameworks-capybara 0.2.34 → 0.3.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +0 -6
- data/Gemfile.lock +50 -60
- data/README.rdoc +3 -22
- data/frameworks-capybara.gemspec +4 -17
- data/lib/frameworks/capybara.rb +13 -63
- data/lib/frameworks/cucumber.rb +25 -84
- data/lib/monkey-patches/capybara-mechanize-patches.rb +9 -36
- data/lib/monkey-patches/capybara-patches.rb +1 -7
- data/lib/monkey-patches/cucumber-patches.rb +1 -5
- data/lib/monkey-patches/mechanize-patches.rb +2 -123
- data/lib/monkey-patches/webdriver-patches.rb +2 -31
- data/lib/tasks/frameworks-tasks.rb +1 -1
- data/lib/version.rb +2 -1
- data/spec/frameworks_capybara_spec.rb +22 -191
- data/spec/frameworks_cucumber_spec.rb +3 -160
- data/spec/spec_helper.rb +0 -2
- metadata +37 -153
- data/.travis.yml +0 -8
- data/CHANGES +0 -47
- data/lib/monkey-patches/net-http-persistent-patches.rb +0 -72
- data/spec/capybara_mechanize_patches_spec.rb +0 -124
- data/spec/mock.default/prefs.js +0 -10
- data/spec/profiles.ini +0 -8
- data/spec/unit_test_monkeypatches.rb +0 -17
@@ -7,11 +7,7 @@ module Cucumber
|
|
7
7
|
@project_name = ENV['PROJECT_NAME'] || ''
|
8
8
|
unless @project_name.empty? then @project_name += ' - ' end
|
9
9
|
|
10
|
-
|
11
|
-
@step_count = features.step_count # cucumber >=1.3.0
|
12
|
-
else
|
13
|
-
@step_count = get_step_count(features) # cucumber <1.3.0
|
14
|
-
end
|
10
|
+
@step_count = get_step_count(features)
|
15
11
|
|
16
12
|
# <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
17
13
|
@builder.declare!(
|
@@ -4,9 +4,9 @@ require 'mechanize'
|
|
4
4
|
#we check after response and it may be the last response we need it to clear here.
|
5
5
|
class Mechanize::CookieJar
|
6
6
|
alias_method :old_add, :add
|
7
|
-
def add(
|
7
|
+
def add(uri, cookie)
|
8
8
|
cleanup
|
9
|
-
old_add(
|
9
|
+
old_add(uri, cookie)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
#This patch may still be required, think it is only not needed now because we don't run
|
@@ -57,124 +57,3 @@ end
|
|
57
57
|
end
|
58
58
|
=end
|
59
59
|
|
60
|
-
# This patch prevents Mechanize from raising a Mechanize::ResponseCodeError
|
61
|
-
# when the HTTP Response Code is in `allowed_error_codes`.
|
62
|
-
# https://github.com/tenderlove/mechanize/pull/248
|
63
|
-
class Mechanize::HTTP::Agent
|
64
|
-
attr_accessor :allowed_error_codes
|
65
|
-
|
66
|
-
alias_method :old_initialize, :initialize
|
67
|
-
def initialize
|
68
|
-
@allowed_error_codes = []
|
69
|
-
old_initialize
|
70
|
-
end
|
71
|
-
|
72
|
-
def fetch uri, method = :get, headers = {}, params = [],
|
73
|
-
referer = current_page, redirects = 0
|
74
|
-
referer_uri = referer ? referer.uri : nil
|
75
|
-
|
76
|
-
uri = resolve uri, referer
|
77
|
-
|
78
|
-
uri, params = resolve_parameters uri, method, params
|
79
|
-
|
80
|
-
request = http_request uri, method, params
|
81
|
-
|
82
|
-
connection = connection_for uri
|
83
|
-
|
84
|
-
request_auth request, uri
|
85
|
-
|
86
|
-
disable_keep_alive request
|
87
|
-
enable_gzip request
|
88
|
-
|
89
|
-
request_language_charset request
|
90
|
-
request_cookies request, uri
|
91
|
-
request_host request, uri
|
92
|
-
request_referer request, uri, referer_uri
|
93
|
-
request_user_agent request
|
94
|
-
request_add_headers request, headers
|
95
|
-
|
96
|
-
pre_connect request
|
97
|
-
|
98
|
-
# Consult robots.txt
|
99
|
-
if robots && uri.is_a?(URI::HTTP)
|
100
|
-
robots_allowed?(uri) or raise Mechanize::RobotsDisallowedError.new(uri)
|
101
|
-
end
|
102
|
-
|
103
|
-
# Add If-Modified-Since if page is in history
|
104
|
-
page = visited_page(uri)
|
105
|
-
|
106
|
-
if (page = visited_page(uri)) and page.response['Last-Modified']
|
107
|
-
request['If-Modified-Since'] = page.response['Last-Modified']
|
108
|
-
end if(@conditional_requests)
|
109
|
-
|
110
|
-
# Specify timeouts if given
|
111
|
-
connection.open_timeout = @open_timeout if @open_timeout
|
112
|
-
connection.read_timeout = @read_timeout if @read_timeout
|
113
|
-
|
114
|
-
request_log request
|
115
|
-
|
116
|
-
response_body_io = nil
|
117
|
-
|
118
|
-
# Send the request
|
119
|
-
begin
|
120
|
-
response = connection.request(uri, request) { |res|
|
121
|
-
response_log res
|
122
|
-
|
123
|
-
response_body_io = response_read res, request, uri
|
124
|
-
|
125
|
-
res
|
126
|
-
}
|
127
|
-
rescue Mechanize::ChunkedTerminationError => e
|
128
|
-
raise unless @ignore_bad_chunking
|
129
|
-
|
130
|
-
response = e.response
|
131
|
-
response_body_io = e.body_io
|
132
|
-
end
|
133
|
-
|
134
|
-
hook_content_encoding response, uri, response_body_io
|
135
|
-
|
136
|
-
response_body_io = response_content_encoding response, response_body_io if
|
137
|
-
request.response_body_permitted?
|
138
|
-
|
139
|
-
post_connect uri, response, response_body_io
|
140
|
-
|
141
|
-
page = response_parse response, response_body_io, uri
|
142
|
-
|
143
|
-
response_cookies response, uri, page
|
144
|
-
|
145
|
-
meta = response_follow_meta_refresh response, uri, page, redirects
|
146
|
-
|
147
|
-
return meta if meta
|
148
|
-
|
149
|
-
case response
|
150
|
-
when Net::HTTPSuccess
|
151
|
-
if robots && page.is_a?(Mechanize::Page)
|
152
|
-
page.parser.noindex? and raise Mechanize::RobotsDisallowedError.new(uri)
|
153
|
-
end
|
154
|
-
|
155
|
-
page
|
156
|
-
when Mechanize::FileResponse
|
157
|
-
page
|
158
|
-
when Net::HTTPNotModified
|
159
|
-
log.debug("Got cached page") if log
|
160
|
-
visited_page(uri) || page
|
161
|
-
when Net::HTTPRedirection
|
162
|
-
response_redirect response, method, page, redirects, headers, referer
|
163
|
-
when Net::HTTPUnauthorized
|
164
|
-
response_authenticate(response, page, uri, request, headers, params,
|
165
|
-
referer)
|
166
|
-
else
|
167
|
-
# BEGIN PATCH
|
168
|
-
if @allowed_error_codes.any? {|code| code.to_s == page.code} then
|
169
|
-
if robots && page.is_a?(Mechanize::Page)
|
170
|
-
page.parser.noindex? and raise Mechanize::RobotsDisallowedError.new(uri)
|
171
|
-
end
|
172
|
-
|
173
|
-
page
|
174
|
-
else
|
175
|
-
raise Mechanize::ResponseCodeError.new(page, 'unhandled response')
|
176
|
-
end
|
177
|
-
# END PATCH
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
@@ -7,6 +7,7 @@ module Selenium
|
|
7
7
|
module WebDriver
|
8
8
|
module Remote
|
9
9
|
class Capabilities
|
10
|
+
|
10
11
|
def custom_capabilities(opts)
|
11
12
|
@custom_capabilities = opts
|
12
13
|
end
|
@@ -14,6 +15,7 @@ module Selenium
|
|
14
15
|
#hopefuly this alias approach will mean we capture changes in the webdriver method
|
15
16
|
alias_method :old_as_json, :as_json
|
16
17
|
def as_json(opts = nil)
|
18
|
+
|
17
19
|
hash = old_as_json
|
18
20
|
if @custom_capabilities
|
19
21
|
@custom_capabilities.each do |key, value|
|
@@ -22,40 +24,9 @@ module Selenium
|
|
22
24
|
end
|
23
25
|
hash
|
24
26
|
end
|
25
|
-
end
|
26
|
-
end
|
27
27
|
|
28
|
-
class Options
|
29
|
-
def delete_cookies_in_domain(domain)
|
30
|
-
delete_all_cookies #proxy to this method as WebDriver only deletes
|
31
|
-
#by domain
|
32
28
|
end
|
33
29
|
end
|
34
30
|
end
|
35
31
|
end
|
36
32
|
|
37
|
-
#Workaround for http://code.google.com/p/selenium/issues/detail?id=4007
|
38
|
-
module Selenium
|
39
|
-
module WebDriver
|
40
|
-
module Remote
|
41
|
-
module Http
|
42
|
-
class Default
|
43
|
-
def new_http_client
|
44
|
-
if @proxy
|
45
|
-
unless @proxy.respond_to?(:http) && url = @proxy.http
|
46
|
-
raise Error::WebDriverError, "expected HTTP proxy, got #{@proxy.inspect}"
|
47
|
-
end
|
48
|
-
|
49
|
-
proxy = URI.parse(url)
|
50
|
-
|
51
|
-
clazz = Net::HTTP::Proxy(proxy.host, proxy.port, proxy.user, proxy.password)
|
52
|
-
clazz.new(server_url.host, server_url.port)
|
53
|
-
else
|
54
|
-
Net::HTTP.new server_url.host, server_url.port
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -24,7 +24,7 @@ class RakeHelpers
|
|
24
24
|
f = File.open('config/cucumber.yml', 'r')
|
25
25
|
linenum = 0
|
26
26
|
@profiles = {}
|
27
|
-
f.
|
27
|
+
f.read.each do |line|
|
28
28
|
line.scan(/.*?: /) do |match|
|
29
29
|
linenum += 1
|
30
30
|
puts color(linenum.to_s + '. ', :color => :yellow) + color(match.gsub(':',''), :color => :green)
|
data/lib/version.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'securerandom'
|
3
2
|
##
|
4
3
|
#Monkey Patch
|
5
4
|
#This is required because Capybara has module methods (singletons) which create
|
@@ -19,6 +18,7 @@ shared_examples_for "Selenium Driver Options Array" do
|
|
19
18
|
it "should contain no nil values for unset options" do
|
20
19
|
#TODO: Test for nil elements in options - there shouldn't be any that we insert
|
21
20
|
#i.e. anything in our ENV options should not end up being nil in Selenium
|
21
|
+
|
22
22
|
Capybara.current_session.driver.options[:environment].should == nil
|
23
23
|
Capybara.current_session.driver.options[:proxy].should == nil
|
24
24
|
Capybara.current_session.driver.options[:proxy_on].should == nil
|
@@ -27,7 +27,6 @@ shared_examples_for "Selenium Driver Options Array" do
|
|
27
27
|
Capybara.current_session.driver.options[:version].should == nil
|
28
28
|
Capybara.current_session.driver.options[:job_name].should == nil
|
29
29
|
Capybara.current_session.driver.options[:chrome_switches].should == nil
|
30
|
-
Capybara.current_session.driver.options[:firefox_prefs].should == nil
|
31
30
|
Capybara.current_session.driver.options[:max_duration].should == nil
|
32
31
|
Capybara.current_session.driver.options[:profile].should_not be_a_kind_of String
|
33
32
|
Capybara.current_session.driver.options[:browser].should_not be_a_kind_of String
|
@@ -117,7 +116,7 @@ describe CapybaraSetup do
|
|
117
116
|
before do
|
118
117
|
ENV['BROWSER'] = 'firefox'
|
119
118
|
ENV['FIREFOX_PROFILE'] = 'BBC_INTERNAL'
|
120
|
-
ENV['HTTP_PROXY'] = 'http://example.cache.co.uk:80
|
119
|
+
ENV['HTTP_PROXY'] = 'http://example.cache.co.uk:80'
|
121
120
|
ENV['PROXY_ON'] = 'false'
|
122
121
|
end
|
123
122
|
|
@@ -128,7 +127,7 @@ describe CapybaraSetup do
|
|
128
127
|
Capybara.current_session.driver.options[:browser].should == :firefox
|
129
128
|
Capybara.current_session.driver.options[:profile].should be_a_kind_of Selenium::WebDriver::Firefox::Profile
|
130
129
|
Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['network.proxy.type'].should == 1
|
131
|
-
Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['network.proxy.no_proxies_on'].should == '*.sandbox.dev.bbc.co.uk
|
130
|
+
Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['network.proxy.no_proxies_on'].should == '*.sandbox.dev.bbc.co.uk'
|
132
131
|
Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['network.proxy.http'].should == 'example.cache.co.uk'
|
133
132
|
Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['network.proxy.http_port'].should == 80
|
134
133
|
Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['network.proxy.ssl'].should == 'example.cache.co.uk'
|
@@ -137,6 +136,24 @@ describe CapybaraSetup do
|
|
137
136
|
it_behaves_like "Selenium Driver Options Array"
|
138
137
|
end
|
139
138
|
|
139
|
+
|
140
|
+
context "with Selenium driver and programtically created profile with referer disabled" do
|
141
|
+
before do
|
142
|
+
ENV['BROWSER'] = 'firefox'
|
143
|
+
ENV['FIREFOX_PROFILE'] = 'DISABLED_REFERER'
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should be initialized correctly" do
|
147
|
+
Capybara.delete_session
|
148
|
+
CapybaraSetup.new.driver.should == :selenium
|
149
|
+
Capybara.current_session.driver.should be_a_kind_of Capybara::Selenium::Driver
|
150
|
+
Capybara.current_session.driver.options[:browser].should == :firefox
|
151
|
+
Capybara.current_session.driver.options[:profile].should be_a_kind_of Selenium::WebDriver::Firefox::Profile
|
152
|
+
Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['network.http.sendRefererHeader'].should == 0
|
153
|
+
end
|
154
|
+
it_behaves_like "Selenium Driver Options Array"
|
155
|
+
end
|
156
|
+
|
140
157
|
context "with Selenium driver and custom chrome options" do
|
141
158
|
before do
|
142
159
|
ENV['BROWSER'] = 'chrome'
|
@@ -217,7 +234,7 @@ describe CapybaraSetup do
|
|
217
234
|
Capybara.current_session.driver.options[:browser].should == :remote
|
218
235
|
Capybara.current_session.driver.options[:desired_capabilities].instance_variable_get(:@capabilities)[:firefox_profile].should be_a_kind_of Selenium::WebDriver::Firefox::Profile
|
219
236
|
Capybara.current_session.driver.options[:desired_capabilities].instance_variable_get(:@capabilities)[:firefox_profile].instance_variable_get(:@additional_prefs)['network.proxy.type'].should == 1
|
220
|
-
Capybara.current_session.driver.options[:desired_capabilities].instance_variable_get(:@capabilities)[:firefox_profile].instance_variable_get(:@additional_prefs)['network.proxy.no_proxies_on'].should == '*.sandbox.dev.bbc.co.uk
|
237
|
+
Capybara.current_session.driver.options[:desired_capabilities].instance_variable_get(:@capabilities)[:firefox_profile].instance_variable_get(:@additional_prefs)['network.proxy.no_proxies_on'].should == '*.sandbox.dev.bbc.co.uk'
|
221
238
|
Capybara.current_session.driver.options[:desired_capabilities].instance_variable_get(:@capabilities)[:firefox_profile].instance_variable_get(:@additional_prefs)['network.proxy.http'].should == 'example.cache.co.uk'
|
222
239
|
Capybara.current_session.driver.options[:desired_capabilities].instance_variable_get(:@capabilities)[:firefox_profile].instance_variable_get(:@additional_prefs)['network.proxy.http_port'].should == 80
|
223
240
|
Capybara.current_session.driver.options[:desired_capabilities].instance_variable_get(:@capabilities)[:firefox_profile].instance_variable_get(:@additional_prefs)['network.proxy.ssl'].should == 'example.cache.co.uk'
|
@@ -258,62 +275,6 @@ describe CapybaraSetup do
|
|
258
275
|
it_behaves_like "Selenium Driver Options Array"
|
259
276
|
end
|
260
277
|
|
261
|
-
context "with Selenium driver and hardcoded bbc internal profile and additional firefox preferences" do
|
262
|
-
before do
|
263
|
-
ENV['BROWSER'] = 'firefox'
|
264
|
-
ENV['HTTP_PROXY'] = 'http://example.cache.co.uk:80'
|
265
|
-
ENV['FIREFOX_PROFILE'] = 'BBC_INTERNAL'
|
266
|
-
ENV['FIREFOX_PREFS'] = '{"javascript.enabled":false}'
|
267
|
-
end
|
268
|
-
|
269
|
-
it "should be initialized correctly" do
|
270
|
-
Capybara.delete_session
|
271
|
-
CapybaraSetup.new.driver.should == :selenium
|
272
|
-
Capybara.current_session.driver.should be_a_kind_of Capybara::Selenium::Driver
|
273
|
-
Capybara.current_session.driver.options[:browser].should == :firefox
|
274
|
-
Capybara.current_session.driver.options[:profile].should be_a_kind_of Selenium::WebDriver::Firefox::Profile
|
275
|
-
Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['javascript.enabled'].should == false
|
276
|
-
end
|
277
|
-
it_behaves_like "Selenium Driver Options Array"
|
278
|
-
end
|
279
|
-
|
280
|
-
|
281
|
-
context "with Selenium driver and additional firefox preferences" do
|
282
|
-
before do
|
283
|
-
ENV['BROWSER'] = 'firefox'
|
284
|
-
ENV['FIREFOX_PROFILE'] = 'default'
|
285
|
-
ENV['FIREFOX_PREFS'] = '{"javascript.enabled":false}'
|
286
|
-
end
|
287
|
-
|
288
|
-
it "should be initialized correctly" do
|
289
|
-
Capybara.delete_session
|
290
|
-
CapybaraSetup.new.driver.should == :selenium
|
291
|
-
Capybara.current_session.driver.should be_a_kind_of Capybara::Selenium::Driver
|
292
|
-
Capybara.current_session.driver.options[:browser].should == :firefox
|
293
|
-
Capybara.current_session.driver.options[:profile].should be_a_kind_of Selenium::WebDriver::Firefox::Profile
|
294
|
-
Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['javascript.enabled'].should == false
|
295
|
-
end
|
296
|
-
it_behaves_like "Selenium Driver Options Array"
|
297
|
-
end
|
298
|
-
|
299
|
-
|
300
|
-
context "with Selenium driver and new profile and custom prefs" do
|
301
|
-
before do
|
302
|
-
ENV['BROWSER'] = 'firefox'
|
303
|
-
ENV['FIREFOX_PREFS'] = '{"javascript.enabled":false}'
|
304
|
-
end
|
305
|
-
|
306
|
-
it "should be initialized correctly" do
|
307
|
-
Capybara.delete_session
|
308
|
-
CapybaraSetup.new.driver.should == :selenium
|
309
|
-
Capybara.current_session.driver.should be_a_kind_of Capybara::Selenium::Driver
|
310
|
-
Capybara.current_session.driver.options[:browser].should == :firefox
|
311
|
-
Capybara.current_session.driver.options[:profile].should be_a_kind_of Selenium::WebDriver::Firefox::Profile
|
312
|
-
Capybara.current_session.driver.options[:profile].instance_variable_get(:@additional_prefs)['javascript.enabled'].should == false
|
313
|
-
end
|
314
|
-
it_behaves_like "Selenium Driver Options Array"
|
315
|
-
end
|
316
|
-
|
317
278
|
context "with Remote Selenium driver and specified Chrome Switches" do
|
318
279
|
before do
|
319
280
|
ENV['BROWSER'] = 'remote'
|
@@ -449,137 +410,7 @@ describe CapybaraSetup do
|
|
449
410
|
end
|
450
411
|
end
|
451
412
|
|
452
|
-
context "integration tests for update_firefox_profile_with_certificates() method" do
|
453
|
-
before do
|
454
|
-
def write_random_data(file_path)
|
455
|
-
file_data = SecureRandom.hex
|
456
|
-
File.open(file_path, "w") { |a_file|
|
457
|
-
a_file.write(file_data)
|
458
|
-
}
|
459
|
-
file_data
|
460
|
-
end
|
461
|
-
|
462
|
-
def compare_file_data(profile_path, file_name, expected_data)
|
463
|
-
profile_file = profile_path + File::SEPARATOR + file_name
|
464
|
-
actual_data = nil
|
465
|
-
File.open(profile_file, "r") { |a_file|
|
466
|
-
actual_data = a_file.read
|
467
|
-
}
|
468
|
-
expected_data.should == actual_data
|
469
|
-
end
|
470
|
-
|
471
|
-
ENV['BROWSER'] = 'firefox'
|
472
|
-
ENV['ENVIRONMENT'] = 'test'
|
473
|
-
ENV['HTTP_PROXY'] = 'http://example.cache.co.uk:80'
|
474
|
-
@cert_dir = Dir.mktmpdir
|
475
|
-
@cert8_db = @cert_dir + File::SEPARATOR + 'cert8.db'
|
476
|
-
@key3_db = @cert_dir + File::SEPARATOR + 'key3.db'
|
477
|
-
@secmod_db = @cert_dir + File::SEPARATOR + 'secmod.db'
|
478
|
-
end
|
479
|
-
|
480
|
-
after do
|
481
|
-
FileUtils.remove_entry @cert_dir
|
482
|
-
end
|
483
|
-
|
484
|
-
it "should raise an exception if the cert8.db file is missing in the source directory" do
|
485
|
-
profile = Selenium::WebDriver::Firefox::Profile.new
|
486
|
-
|
487
|
-
key3_data = write_random_data(@key3_db)
|
488
|
-
secmod_data = write_random_data(@secmod_db)
|
489
|
-
|
490
|
-
an_exception = nil
|
491
|
-
begin
|
492
|
-
CapybaraSetup.new.instance_exec(profile, @cert_dir) { |profile, certificate_path|
|
493
|
-
update_firefox_profile_with_certificates(profile, certificate_path)
|
494
|
-
}
|
495
|
-
rescue RuntimeError => e
|
496
|
-
an_exception = e
|
497
|
-
end
|
498
|
-
|
499
|
-
an_exception.should_not be_nil
|
500
|
-
end
|
501
|
-
|
502
|
-
it "should raise an exception if the key3.db file is missing in the source directory" do
|
503
|
-
profile = Selenium::WebDriver::Firefox::Profile.new
|
504
|
-
|
505
|
-
cert8_data = write_random_data(@cert8_db)
|
506
|
-
secmod_data = write_random_data(@secmod_db)
|
507
|
-
|
508
|
-
an_exception = nil
|
509
|
-
begin
|
510
|
-
CapybaraSetup.new.instance_exec(profile, @cert_dir) { |profile, certificate_path|
|
511
|
-
update_firefox_profile_with_certificates(profile, certificate_path)
|
512
|
-
}
|
513
|
-
rescue RuntimeError => e
|
514
|
-
an_exception = e
|
515
|
-
end
|
516
|
-
|
517
|
-
an_exception.should_not be_nil
|
518
|
-
end
|
519
|
-
|
520
|
-
it "should raise an exception if the secmod.db file is missing in the source directory" do
|
521
|
-
profile = Selenium::WebDriver::Firefox::Profile.new
|
522
|
-
|
523
|
-
cert8_data = write_random_data(@cert8_db)
|
524
|
-
key3_data = write_random_data(@key3_db)
|
525
|
-
|
526
|
-
an_exception = nil
|
527
|
-
begin
|
528
|
-
CapybaraSetup.new.instance_exec(profile, @cert_dir) { |profile, certificate_path|
|
529
|
-
update_firefox_profile_with_certificates(profile, certificate_path)
|
530
|
-
}
|
531
|
-
rescue RuntimeError => e
|
532
|
-
an_exception = e
|
533
|
-
end
|
534
|
-
|
535
|
-
an_exception.should_not be_nil
|
536
|
-
end
|
537
|
-
|
538
|
-
it "should update a firefox profile with valid references to certificate db files" do
|
539
|
-
|
540
|
-
profile = Selenium::WebDriver::Firefox::Profile.new
|
541
|
-
|
542
|
-
cert8_data = write_random_data(@cert8_db)
|
543
|
-
key3_data = write_random_data(@key3_db)
|
544
|
-
secmod_data = write_random_data(@secmod_db)
|
545
|
-
|
546
|
-
setup = CapybaraSetup.new
|
547
|
-
result = setup.instance_exec(profile, @cert_dir) { |profile, certificate_path|
|
548
|
-
update_firefox_profile_with_certificates(profile, certificate_path)
|
549
|
-
}
|
550
|
-
profile_path = result.layout_on_disk
|
551
|
-
compare_file_data(profile_path, 'cert8.db', cert8_data)
|
552
|
-
compare_file_data(profile_path, 'key3.db', key3_data)
|
553
|
-
compare_file_data(profile_path, 'secmod.db', secmod_data)
|
554
|
-
end
|
555
|
-
|
556
|
-
it "should update a firefox profile with references to certificate db files with prefixes" do
|
557
|
-
|
558
|
-
profile = Selenium::WebDriver::Firefox::Profile.new
|
559
|
-
cert_prefix = 'a'
|
560
|
-
@cert8_db = @cert_dir + File::SEPARATOR + cert_prefix + 'cert8.db'
|
561
|
-
@key3_db = @cert_dir + File::SEPARATOR + cert_prefix + 'key3.db'
|
562
|
-
@secmod_db = @cert_dir + File::SEPARATOR + cert_prefix + 'secmod.db'
|
563
|
-
|
564
|
-
cert8_data = write_random_data(@cert8_db)
|
565
|
-
key3_data = write_random_data(@key3_db)
|
566
|
-
secmod_data = write_random_data(@secmod_db)
|
567
|
-
|
568
|
-
setup = CapybaraSetup.new
|
569
|
-
result = setup.instance_exec(profile, @cert_dir, cert_prefix) { |profile, certificate_path, certificate_prefix, result|
|
570
|
-
update_firefox_profile_with_certificates(profile, certificate_path, certificate_prefix)
|
571
|
-
}
|
572
|
-
profile_path = result.layout_on_disk
|
573
|
-
compare_file_data(profile_path, 'cert8.db', cert8_data)
|
574
|
-
compare_file_data(profile_path, 'key3.db', key3_data)
|
575
|
-
compare_file_data(profile_path, 'secmod.db', secmod_data)
|
576
|
-
end
|
577
|
-
|
578
|
-
end
|
579
|
-
|
580
413
|
end
|
581
|
-
|
582
|
-
|
583
414
|
end
|
584
415
|
end
|
585
416
|
end
|