Manual test suite: use more precise data when comparing image size.
[tails.git] / features / step_definitions / torified_misc.rb
blob7ccdb227d1ace6f7b7236f60bcdfe5ba7205c4b9
1 require 'resolv'
3 When /^I query the whois directory service for "([^"]+)"$/ do |domain|
4   retry_tor do
5     @vm_execute_res = $vm.execute("whois '#{domain}'", :user => LIVE_USER)
6     if @vm_execute_res.failure? || @vm_execute_res.stdout['LIMIT EXCEEDED']
7       raise "Looking up whois info for #{domain} failed with:\n" +
8             "#{@vm_execute_res.stdout}\n" +
9             "#{@vm_execute_res.stderr}"
10     end
11   end
12 end
14 When /^I wget "([^"]+)" to stdout(?:| with the '([^']+)' options)$/ do |target, options|
15   retry_tor do
16     if target == "some Tails mirror"
17       host = 'dl.amnesia.boum.org'
18       address = Resolv.new.getaddresses(host).sample
19       puts "Resolved #{host} to #{address}"
20       url = "http://#{address}/tails/stable/"
21     else
22       url = target
23     end
24     arguments = "-O - '#{url}'"
25     arguments = "#{options} #{arguments}" if options
26     @vm_execute_res = $vm.execute("wget #{arguments}", :user => LIVE_USER)
27     if @vm_execute_res.failure?
28       raise "wget:ing #{url} with options #{options} failed with:\n" +
29             "#{@vm_execute_res.stdout}\n" +
30             "#{@vm_execute_res.stderr}"
31     end
32   end
33 end
35 Then /^the (wget|whois) command is successful$/ do |command|
36   assert(
37     @vm_execute_res.success?,
38     "#{command} failed:\n" +
39     "#{@vm_execute_res.stdout}\n" +
40     "#{@vm_execute_res.stderr}"
41   )
42 end
44 Then /^the (wget|whois) standard output contains "([^"]+)"$/ do |command, text|
45   assert(
46     @vm_execute_res.stdout[text],
47     "The #{command} standard output does not contain #{text}:\n" +
48     "#{@vm_execute_res.stdout}\n" +
49     "#{@vm_execute_res.stderr}"
50   )
51 end