From a5d56e3b5443263b53b0487c81125123411bd0cf Mon Sep 17 00:00:00 2001 From: Philip Hands Date: Wed, 11 May 2016 17:11:01 +0200 Subject: move cucumber things under cucumber/ --- .../features/step_definitions/torified_misc.rb | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 cucumber/features/step_definitions/torified_misc.rb (limited to 'cucumber/features/step_definitions/torified_misc.rb') diff --git a/cucumber/features/step_definitions/torified_misc.rb b/cucumber/features/step_definitions/torified_misc.rb new file mode 100644 index 00000000..7112776a --- /dev/null +++ b/cucumber/features/step_definitions/torified_misc.rb @@ -0,0 +1,41 @@ +When /^I query the whois directory service for "([^"]+)"$/ do |domain| + retry_tor do + @vm_execute_res = $vm.execute("whois '#{domain}'", :user => LIVE_USER) + if @vm_execute_res.failure? || @vm_execute_res.stdout['LIMIT EXCEEDED'] + raise "Looking up whois info for #{domain} failed with:\n" + + "#{@vm_execute_res.stdout}\n" + + "#{@vm_execute_res.stderr}" + end + end +end + +When /^I wget "([^"]+)" to stdout(?:| with the '([^']+)' options)$/ do |url, options| + arguments = "-O - '#{url}'" + arguments = "#{options} #{arguments}" if options + retry_tor do + @vm_execute_res = $vm.execute("wget #{arguments}", :user => 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}" + end + end +end + +Then /^the (wget|whois) command is successful$/ do |command| + assert( + @vm_execute_res.success?, + "#{command} failed:\n" + + "#{@vm_execute_res.stdout}\n" + + "#{@vm_execute_res.stderr}" + ) +end + +Then /^the (wget|whois) standard output contains "([^"]+)"$/ do |command, text| + 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 -- cgit v1.2.3-70-g09d2