Permalink
Browse files

Update features for password based tests

  • Loading branch information...
catsby committed Mar 29, 2011
1 parent 62036a8 commit 5901b7d09cf96aa8b42b9f9b38202f41c1683487
Showing with 36 additions and 30 deletions.
  1. +14 −19 features/gt_scp_file.feature
  2. +18 −10 features/step_definitions/gt_scp_steps.rb
  3. +4 −1 features/support/env.rb
@@ -6,27 +6,22 @@ Feature: growl-down downloads a file via scp
So that I can do other things in the meantime
And not have to watch or check the progress

Scenario: Download file assuming ssh keyless authentication
Given I have ssh keyless auth setup on "ctshryock.com"
And specify "growl-down-test/unicorns.zip" as the file name
When I run "download"
Then I should see "Finished!"
And TEST_DIR should contain "unicorns.zip" file

Scenario: Download file assuming ssh keyless auth, but specify a username
Given I have ssh keyless auth setup on "ctshryock.com"
And I specify "clint" as the username before the url
And specify "growl-down-test/unicorns.zip" as the file name
When I run "download"
Then I should see "Finished!"
And TEST_DIR should contain "unicorns.zip" file

# Scenario: Download file assuming ssh keyless authentication
# Given I have ssh keyless auth setup on "ctshryock.com"
# And specify "growl-down-test/unicorns.zip" as the file name
# When I run "download"
# Then TEST_DIR should contain "unicorns.zip" file
#
# Scenario: Download file assuming ssh keyless auth, but specify a username
# Given I have ssh keyless auth setup on "ctshryock.com"
# And I specify "clint" as the username before the url
# And specify "growl-down-test/unicorns.zip" as the file name
# When I run "download"
# Then TEST_DIR should contain "unicorns.zip" file

Scenario: Download file assuming password based auth
Given I have a valid password setup on "ctshryock.com"
Given I have a valid password setup on "clint@ctshryock.com"
And I specify the "-p" option
And specify "growl-down-test/unicorns.zip" as the file name
When I run "download"
Then I should see "Finished!"
And TEST_DIR should contain "unicorns.zip" file

Then TEST_DIR should contain "unicorns.zip" file
@@ -2,12 +2,14 @@
FileUtils.mkdir(TEST_DIR)
Dir.chdir(TEST_DIR)
@remote = []
@options = {}
end

After do
Dir.chdir(TEST_DIR)
FileUtils.rm_rf(TEST_DIR)
@remote.clear
@options.clear
end

class Output
@@ -18,6 +20,10 @@ def messages
def puts(message)
messages << message
end

def write(message)
messages << message
end
end

#
@@ -27,8 +33,8 @@ def output
@output ||= Output.new
end

Given /^I have ssh keyless auth setup on "([^"]*)"$/ do |remote_host|
@remote << remote_host
Given /^I have ssh keyless auth setup on "([^"]*)"$/ do |remote_path|
@remote << remote_path
end

Given /^specify "([^"]*)" as the file name$/ do |remote_path|
@@ -39,23 +45,25 @@ def output
@remote[0] = 'clint' + '@' + @remote[0]
end

Given /^I have a valid password setup on "([^"]*)"$/ do |remote_host|
pending # need server I have password but not keyless auth on @remote << remote_host
Given /^I have a valid password setup on "([^"]*)"$/ do |remote_path|
@remote << remote_path
end

Given /^I specify the "([^"]*)" option$/ do |remote_host|
@remote << remote_host
@options[:password_flag] = '-p'
end

When /^I run "([^"]*)"$/ do |arg1|
GrowlTransfer::DEFAULTS.merge!({'output'=>output})
GrowlTransfer::Download(@remote.join(':'), TEST_DIR)
When /^I run "([^"]*)"$/ do |action|
@options[:from] = @remote.join(':')
@options[:to] = TEST_DIR
puts @options[:from]
run_gt(@options)
end

Then /^I should see "([^"]*)"$/ do |status|
output.messages.should include(status)
end

Then /^TEST_DIR should contain "([^"]*)" file$/ do |arg1|
File.file?([TEST_DIR, arg1].join('/'))
end
(File.file?([TEST_DIR, arg1].join('/'))).should == true
end
@@ -7,7 +7,10 @@
GT_PATH = File.join(ENV['PWD'], 'bin', 'gt')

def run_gt(opts = {})
command = GT_PATH + ' ' + opts
command = GT_PATH + ' '
command << opts[:password_flag] + ' ' unless opts[:password_flag].nil?
command << opts[:from] + ' ' + opts[:to]
# command << " >> /dev/null 2>&1" if opts[:debug].nil?
# pp command
system command
end

0 comments on commit 5901b7d

Please sign in to comment.