summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2015-07-13 08:26:41 +0000
committerintrigeri <intrigeri@boum.org>2015-07-13 08:26:41 +0000
commitcacd5a4c737829fa2a3793bc305deab5ab82943a (patch)
tree7b11ede31916ba2e0c120c3b72092d0388c15a42
parent21ee302def27b3d7ee998d1e83327f1790b791d4 (diff)
parent70971ee887a7b553a1f2b984cf06deaf0e388863 (diff)
Merge remote-tracking branch 'kytv/test/9668-whois' into devel
Fix-committed: #9668
-rw-r--r--features/step_definitions/common_steps.rb12
-rw-r--r--features/step_definitions/pidgin.rb8
-rw-r--r--features/step_definitions/torified_gnupg.rb30
-rw-r--r--features/step_definitions/torified_misc.rb26
4 files changed, 49 insertions, 27 deletions
diff --git a/features/step_definitions/common_steps.rb b/features/step_definitions/common_steps.rb
index ecaf49a..08f66e2 100644
--- a/features/step_definitions/common_steps.rb
+++ b/features/step_definitions/common_steps.rb
@@ -1060,7 +1060,11 @@ When /^I open a page on the LAN web server in the (.*)$/ do |browser|
step "I open the address \"#{@web_server_url}\" in the #{browser}"
end
-Then /^I force Tor to use a new circuit( in Vidalia)?$/ do |with_vidalia|
+def force_new_tor_circuit(with_vidalia=nil)
+ assert(!@new_circuit_tries.nil? && @new_circuit_tries >= 0,
+ '@new_circuit_tries was not initialized before it was used')
+ @new_circuit_tries += 1
+ STDERR.puts "Forcing new Tor circuit... (attempt ##{@new_circuit_tries})" if $config["DEBUG"]
if with_vidalia
assert_equal('gnome', @theme, "Vidalia is not available in the #{@theme} theme.")
begin
@@ -1091,3 +1095,9 @@ Then /^I force Tor to use a new circuit( in Vidalia)?$/ do |with_vidalia|
@vm.execute_successfully('. /usr/local/lib/tails-shell-library/tor.sh; tor_control_send "signal NEWNYM"')
end
end
+
+Then /^I force Tor to use a new circuit( in Vidalia)?$/ do |with_vidalia|
+ next if @skip_steps_while_restoring_background
+ @new_circuit_tries = 1 if @new_circuit_tries.nil?
+ force_new_tor_circuit(with_vidalia)
+end
diff --git a/features/step_definitions/pidgin.rb b/features/step_definitions/pidgin.rb
index 7407d8c..cbfbea1 100644
--- a/features/step_definitions/pidgin.rb
+++ b/features/step_definitions/pidgin.rb
@@ -296,8 +296,8 @@ end
Then /^Pidgin successfully connects to the "([^"]+)" account$/ do |account|
next if @skip_steps_while_restoring_background
expected_channel_entry = chan_image(account, default_chan(account), 'roster')
- tries = 0
- until tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
+ @new_circuit_tries = 0
+ until @new_circuit_tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
# Sometimes the OFTC welcome notice window pops up over the buddy list one...
begin
@vm.focus_window('Buddy List')
@@ -313,9 +313,7 @@ Then /^Pidgin successfully connects to the "([^"]+)" account$/ do |account|
@screen.wait(expected_channel_entry, 60)
break
rescue FindFailed
- tries += 1
- STDERR.puts "Forcing new Tor circuit... (attempt ##{tries})" if $config["DEBUG"]
- step "I force Tor to use a new circuit"
+ force_new_tor_circuit
@screen.wait_and_click('PidginReconnect.png', 20)
end
end
diff --git a/features/step_definitions/torified_gnupg.rb b/features/step_definitions/torified_gnupg.rb
index fe27ebd..51eb4da 100644
--- a/features/step_definitions/torified_gnupg.rb
+++ b/features/step_definitions/torified_gnupg.rb
@@ -50,20 +50,18 @@ When /^I fetch the "([^"]+)" OpenPGP key using the GnuPG CLI( without any signat
else
importopts = ''
end
- tries = 0
- until tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
+ @new_circuit_tries = 0
+ until @new_circuit_tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
begin
@gnupg_recv_key_res = @vm.execute_successfully(
"gpg --batch #{importopts} --recv-key '#{keyid}'",
LIVE_USER)
break
rescue ExecutionFailedInVM
- tries += 1
- STDERR.puts "Forcing new Tor circuit... (attempt ##{tries})" if $config["DEBUG"]
- step 'I force Tor to use a new circuit'
+ force_new_tor_circuit
end
end
- assert(tries <= $config["MAX_NEW_TOR_CIRCUIT_RETRIES"], "Fetching keys with the GnuPG CLI did not succeed after retrying #{tries} times")
+ assert(@new_circuit_tries < $config["MAX_NEW_TOR_CIRCUIT_RETRIES"], "Fetching keys with the GnuPG CLI did not succeed after retrying #{@new_circuit_tries} times")
end
When /^the GnuPG fetch is successful$/ do
@@ -112,8 +110,8 @@ end
Then /^I synchronize keys in Seahorse$/ do
next if @skip_steps_while_restoring_background
- tries = 0
- until tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
+ @new_circuit_tries = 0
+ until @new_circuit_tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
begin
step 'process "seahorse" is running'
@screen.wait_and_click("SeahorseWindow.png", 10)
@@ -124,7 +122,7 @@ Then /^I synchronize keys in Seahorse$/ do
seahorse_wait_helper('SeahorseWindow.png', 5*60)
break
rescue OpenPGPKeyserverCommunicationError
- tries += 1
+ force_new_tor_circuit
@screen.wait_and_click('GnomeCloseButton.png', 20)
if @screen.exists('SeahorseSynchronizing.png')
# Seahorse is likely to segfault if we end up here.
@@ -132,11 +130,9 @@ Then /^I synchronize keys in Seahorse$/ do
@screen.type(Sikuli::Key.ESC)
end
seahorse_wait_helper('SeahorseWindow.png')
- STDERR.puts "Forcing new Tor circuit... (attempt ##{tries})" if $config["DEBUG"]
- step 'I force Tor to use a new circuit'
end
end
- assert(tries <= $config["MAX_NEW_TOR_CIRCUIT_RETRIES"], "Syncing keys in Seahorse did not succeed after retrying #{tries} times")
+ assert(@new_circuit_tries < $config["MAX_NEW_TOR_CIRCUIT_RETRIES"], "Syncing keys in Seahorse did not succeed after retrying #{@new_circuit_tries} times")
end
When /^I fetch the "([^"]+)" OpenPGP key using Seahorse( via the Tails OpenPGP Applet)?$/ do |keyid, withgpgapplet|
@@ -147,8 +143,8 @@ When /^I fetch the "([^"]+)" OpenPGP key using Seahorse( via the Tails OpenPGP A
step "I start Seahorse"
end
step "Seahorse has opened"
- tries = 0
- until tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
+ @new_circuit_tries = 0
+ until @new_circuit_tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
begin
@screen.wait_and_click("SeahorseWindow.png", 10)
seahorse_menu_click_helper('SeahorseRemoteMenu.png', 'SeahorseRemoteMenuFind.png', 'seahorse')
@@ -169,15 +165,13 @@ When /^I fetch the "([^"]+)" OpenPGP key using Seahorse( via the Tails OpenPGP A
@screen.click("SeahorseImport.png")
break
rescue OpenPGPKeyserverCommunicationError
- tries += 1
+ force_new_tor_circuit
@screen.wait_and_click('GnomeCloseButton.png', 20)
@screen.type(Sikuli::Key.ESC)
@screen.type("w", Sikuli::KeyModifier.CTRL)
- STDERR.puts "Forcing new Tor circuit... (attempt ##{tries})" if $config["DEBUG"]
- step 'I force Tor to use a new circuit'
end
end
- assert(tries <= $config["MAX_NEW_TOR_CIRCUIT_RETRIES"], "Fetching keys in Seahorse did not succeed after retrying #{tries} times")
+ assert(@new_circuit_tries < $config["MAX_NEW_TOR_CIRCUIT_RETRIES"], "Fetching keys in Seahorse did not succeed after retrying #{@new_circuit_tries} times")
end
Then /^Seahorse is configured to use the correct keyserver$/ do
diff --git a/features/step_definitions/torified_misc.rb b/features/step_definitions/torified_misc.rb
index 610234f..bd4cd0b 100644
--- a/features/step_definitions/torified_misc.rb
+++ b/features/step_definitions/torified_misc.rb
@@ -1,8 +1,28 @@
+class WhoisLookupFailure < StandardError
+end
+
When /^I query the whois directory service for "([^"]+)"$/ do |domain|
next if @skip_steps_while_restoring_background
- @vm_execute_res = @vm.execute(
- "whois '#{domain}'",
- LIVE_USER)
+ @new_circuit_tries = 0
+ until @new_circuit_tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
+ begin
+ @vm_execute_res = @vm.execute("whois '#{domain}'", LIVE_USER)
+ if !@vm_execute_res.success? || @vm_execute_res.stdout['LIMIT EXCEEDED']
+ raise WhoisLookupFailure
+ end
+ break
+ rescue WhoisLookupFailure
+ if @vm_execute_res.stderr['Timeout'] || \
+ @vm_execute_res.stderr['Unable to resolve'] || \
+ @vm_execute_res.stdout['LIMIT EXCEEDED']
+ force_new_tor_circuit
+ end
+ end
+ end
+ assert(@new_circuit_tries < $config["MAX_NEW_TOR_CIRCUIT_RETRIES"],
+ "Looking up whois info for #{domain} did not succeed after retrying #{@new_circuit_tries} times.\n" +
+ "The output of the last command contains:\n" +
+ "#{@vm_execute_res.stdout}\n" + "#{@vm_execute_res.stderr}")
end
When /^I wget "([^"]+)" to stdout(?:| with the '([^']+)' options)$/ do |url, options|