torified_misc.rb 1.44 KB
Newer Older
1
When /^I query the whois directory service for "([^"]+)"$/ do |domain|
2
  next if @skip_steps_while_restoring_background
anonym's avatar
anonym committed
3
4
5
6
7
8
  retry_tor do
    @vm_execute_res = @vm.execute("whois '#{domain}'", LIVE_USER)
    if @vm_execute_res.failure?
      raise "Looking up whois info for #{domain} failed with:\n" +
            "#{@vm_execute_res.stdout}\n" +
            "#{@vm_execute_res.stderr}"
9
10
    end
  end
11
12
end

13
When /^I wget "([^"]+)" to stdout(?:| with the '([^']+)' options)$/ do |url, options|
14
15
16
  next if @skip_steps_while_restoring_background
  arguments = "-O - '#{url}'"
  arguments = "#{options} #{arguments}" if options
anonym's avatar
anonym committed
17
18
19
20
21
22
  retry_tor do
    @vm_execute_res = @vm.execute("wget #{arguments}", LIVE_USER)
    if @vm_execute_res.failure?
      raise "wget:ing #{url} with options #{options} failed with:\n" +
            "#{@vm_execute_res.stdout}\n" +
            "#{@vm_execute_res.stderr}"
23
24
    end
  end
25
26
27
28
29
30
31
32
33
34
end

Then /^the (wget|whois) command is successful$/ do |command|
  next if @skip_steps_while_restoring_background
  assert(
    @vm_execute_res.success?,
    "#{command} failed:\n" +
    "#{@vm_execute_res.stdout}\n" +
    "#{@vm_execute_res.stderr}"
  )
35
36
37
38
39
40
41
42
43
44
45
end

Then /^the (wget|whois) standard output contains "([^"]+)"$/ do |command, text|
  next if @skip_steps_while_restoring_background
  assert(
    @vm_execute_res.stdout[text],
    "The #{command} standard output does not contain #{text}:\n" +
    "#{@vm_execute_res.stdout}\n" +
    "#{@vm_execute_res.stderr}"
  )
end