spec/net-ssh-simple.rb in net-ssh-simple-1.5.9 vs spec/net-ssh-simple.rb in net-ssh-simple-1.6.0
- old
+ new
@@ -68,13 +68,30 @@
e.result.timed_out.should == true
end
raised.should == true
end
- it "enforces operation timeout on scp_ul" do
+ it "enforces operation timeout on scp_put" do
raised = false
begin
+ r = Net::SSH::Simple.scp_put('localhost', '/tmp/ssh_test_in0',
+ '/tmp/ssh_test_out0', {:operation_timeout=>1}) \
+ do |sent,total|
+ sleep 5
+ end
+ rescue => e
+ raised = true
+ e.to_s.should match /^execution expired @ .*/
+ e.result.op == :ssh
+ e.result.timed_out.should == true
+ end
+ raised.should == true
+ end
+
+ it "enforces operation timeout on scp_ul [DEPRECATED]" do
+ raised = false
+ begin
r = Net::SSH::Simple.scp_ul('localhost', '/tmp/ssh_test_in0',
'/tmp/ssh_test_out0', {:operation_timeout=>1}) \
do |sent,total|
sleep 5
end
@@ -85,13 +102,30 @@
e.result.timed_out.should == true
end
raised.should == true
end
- it "enforces operation timeout on scp_dl" do
+ it "enforces operation timeout on scp_get" do
raised = false
begin
+ r = Net::SSH::Simple.scp_get('localhost', '/tmp/ssh_test_in0',
+ '/tmp/ssh_test_out0', {:operation_timeout=>1}) \
+ do |sent,total|
+ sleep 5
+ end
+ rescue => e
+ raised = true
+ e.to_s.should match /^execution expired @ .*/
+ e.result.op == :ssh
+ e.result.timed_out.should == true
+ end
+ raised.should == true
+ end
+
+ it "enforces operation timeout on scp_dl [DEPRECATED]" do
+ raised = false
+ begin
r = Net::SSH::Simple.scp_dl('localhost', '/tmp/ssh_test_in0',
'/tmp/ssh_test_out0', {:operation_timeout=>1}) \
do |sent,total|
sleep 5
end
@@ -151,23 +185,43 @@
Net::SSH::Simple.ssh('localhost', 'echo hello 1>&2').stderr.should == "hello\n"
long = Net::SSH::Simple.ssh('localhost', 'seq 1 100000 1>&2').stderr
Digest::MD5.hexdigest(long).should == 'dea9193b768319cbb4ff1a137ac03113'
end
- it "uploads via scp" do
+ it "uploads via scp_put" do
mockback = mock(:progress_callback)
mockback.should_receive(:ping).at_least(:once)
+ r = Net::SSH::Simple.scp_put('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0') do |sent,total|
+ mockback.ping
+ end
+ r.success.should == true
+ Digest::MD5.file('/tmp/ssh_test_in0').should == Digest::MD5.file('/tmp/ssh_test_out0')
+ end
+
+ it "uploads via scp_ul [DEPRECATED]" do
+ mockback = mock(:progress_callback)
+ mockback.should_receive(:ping).at_least(:once)
r = Net::SSH::Simple.scp_ul('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0') do |sent,total|
mockback.ping
end
r.success.should == true
Digest::MD5.file('/tmp/ssh_test_in0').should == Digest::MD5.file('/tmp/ssh_test_out0')
end
- it "downloads via scp" do
+ it "downloads via scp_get" do
mockback = mock(:progress_callback)
mockback.should_receive(:ping).at_least(:once)
+ r = Net::SSH::Simple.scp_get('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0') do |sent,total|
+ mockback.ping
+ end
+ r.success.should == true
+ Digest::MD5.file('/tmp/ssh_test_in0').should == Digest::MD5.file('/tmp/ssh_test_out0')
+ end
+
+ it "downloads via scp_dl [DEPRECATED]" do
+ mockback = mock(:progress_callback)
+ mockback.should_receive(:ping).at_least(:once)
r = Net::SSH::Simple.scp_dl('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0') do |sent,total|
mockback.ping
end
r.success.should == true
Digest::MD5.file('/tmp/ssh_test_in0').should == Digest::MD5.file('/tmp/ssh_test_out0')
@@ -214,24 +268,46 @@
@s.ssh('localhost', 'echo hello 1>&2').stderr.should == "hello\n"
long = @s.ssh('localhost', 'seq 1 100000 1>&2').stderr
Digest::MD5.hexdigest(long).should == 'dea9193b768319cbb4ff1a137ac03113'
end
- it "uploads via scp" do
+ it "uploads via scp_put" do
mockback = mock(:progress_callback)
mockback.should_receive(:ping).at_least(:once)
+ r = @s.scp_put('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0') do |sent,total|
+ mockback.ping
+ end
+ r.success.should == true
+ r.op.should == :scp
+ Digest::MD5.file('/tmp/ssh_test_in0').should == Digest::MD5.file('/tmp/ssh_test_out0')
+ end
+
+ it "uploads via scp_ul [DEPRECATED]" do
+ mockback = mock(:progress_callback)
+ mockback.should_receive(:ping).at_least(:once)
r = @s.scp_ul('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0') do |sent,total|
mockback.ping
end
r.success.should == true
r.op.should == :scp
Digest::MD5.file('/tmp/ssh_test_in0').should == Digest::MD5.file('/tmp/ssh_test_out0')
end
- it "downloads via scp" do
+ it "downloads via scp_get" do
mockback = mock(:progress_callback)
mockback.should_receive(:ping).at_least(:once)
+ r = @s.scp_get('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0') do |sent,total|
+ mockback.ping
+ end
+ r.success.should == true
+ r.op.should == :scp
+ Digest::MD5.file('/tmp/ssh_test_in0').should == Digest::MD5.file('/tmp/ssh_test_out0')
+ end
+
+ it "downloads via scp_dl [DEPRECATED]" do
+ mockback = mock(:progress_callback)
+ mockback.should_receive(:ping).at_least(:once)
r = @s.scp_dl('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0') do |sent,total|
mockback.ping
end
r.success.should == true
r.op.should == :scp
@@ -286,26 +362,50 @@
long = ssh('localhost', 'seq 1 100000 1>&2').stderr
Digest::MD5.hexdigest(long).should == 'dea9193b768319cbb4ff1a137ac03113'
end
end
- it "uploads via scp" do
+ it "uploads via scp_put" do
Net::SSH::Simple.sync do
mockback = mock(:progress_callback)
mockback.should_receive(:ping).at_least(:once)
+ r = scp_put('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0') do |sent,total|
+ mockback.ping
+ end
+ r.success.should == true
+ Digest::MD5.file('/tmp/ssh_test_in0').should == Digest::MD5.file('/tmp/ssh_test_out0')
+ end
+ end
+
+ it "uploads via scp_ul [DEPRECATED]" do
+ Net::SSH::Simple.sync do
+ mockback = mock(:progress_callback)
+ mockback.should_receive(:ping).at_least(:once)
r = scp_ul('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0') do |sent,total|
mockback.ping
end
r.success.should == true
Digest::MD5.file('/tmp/ssh_test_in0').should == Digest::MD5.file('/tmp/ssh_test_out0')
end
end
- it "downloads via scp" do
+ it "downloads via scp_get" do
Net::SSH::Simple.sync do
mockback = mock(:progress_callback)
mockback.should_receive(:ping).at_least(:once)
+ r = scp_get('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0') do |sent,total|
+ mockback.ping
+ end
+ r.success.should == true
+ Digest::MD5.file('/tmp/ssh_test_in0').should == Digest::MD5.file('/tmp/ssh_test_out0')
+ end
+ end
+
+ it "downloads via scp_dl [DEPRECATED]" do
+ Net::SSH::Simple.sync do
+ mockback = mock(:progress_callback)
+ mockback.should_receive(:ping).at_least(:once)
r = scp_dl('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0') do |sent,total|
mockback.ping
end
r.success.should == true
Digest::MD5.file('/tmp/ssh_test_in0').should == Digest::MD5.file('/tmp/ssh_test_out0')
@@ -336,15 +436,15 @@
mockback.should_receive(:ping).at_least(:once)
mockback.should_not_receive(:exception)
begin
r = nil
if 0 == i % 2
- r = scp_dl('localhost', "/tmp/ssh_test_in#{i}", "/tmp/ssh_test_out#{i}") do |sent,total|
+ r = scp_get('localhost', "/tmp/ssh_test_in#{i}", "/tmp/ssh_test_out#{i}") do |sent,total|
mockback.ping
end
else
- r = scp_ul('localhost', "/tmp/ssh_test_in#{i}", "/tmp/ssh_test_out#{i}") do |sent,total|
+ r = scp_put('localhost', "/tmp/ssh_test_in#{i}", "/tmp/ssh_test_out#{i}") do |sent,total|
mockback.ping
end
end
r.success.should == true
ssh('localhost', "echo hello #{i}")
@@ -372,15 +472,15 @@
t[i] = Net::SSH::Simple.async do
mockback = mock(:progress_callback)
mockback.should_receive(:ping).at_least(:once)
r = nil
if 0 == i % 2
- r = scp_dl('localhost', "/tmp/ssh_test_in#{i}", "/tmp/ssh_test_out#{i}") do |sent,total|
+ r = scp_get('localhost', "/tmp/ssh_test_in#{i}", "/tmp/ssh_test_out#{i}") do |sent,total|
mockback.ping
end
else
- r = scp_ul('localhost', "/tmp/ssh_test_in#{i}", "/tmp/ssh_test_out#{i}") do |sent,total|
+ r = scp_put('localhost', "/tmp/ssh_test_in#{i}", "/tmp/ssh_test_out#{i}") do |sent,total|
mockback.ping
end
end
r.success.should == true
ssh('localhost', "echo hello #{i}")
@@ -425,10 +525,23 @@
r = s.ssh('localhost', 'date', {:rekey_packet_limit => 42})
r.op.should == :ssh
r.opts[:timeout].should == 7
r.opts[:rekey_packet_limit].should == 42
+ r = s.scp_get('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0',
+ {:rekey_packet_limit => 42})
+ r.op.should == :scp
+ r.opts[:timeout].should == 7
+ r.opts[:rekey_packet_limit].should == 42
+
+ r = s.scp_put('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0',
+ {:rekey_packet_limit => 42})
+ r.op.should == :scp
+ r.opts[:timeout].should == 7
+ r.opts[:rekey_packet_limit].should == 42
+
+ # also test deprecated scp_dl and scp_ul
r = s.scp_dl('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0',
{:rekey_packet_limit => 42})
r.op.should == :scp
r.opts[:timeout].should == 7
r.opts[:rekey_packet_limit].should == 42
@@ -436,10 +549,11 @@
r = s.scp_ul('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0',
{:rekey_packet_limit => 42})
r.op.should == :scp
r.opts[:timeout].should == 7
r.opts[:rekey_packet_limit].should == 42
+ # /deprecated
s.close
end
it "works with instance syntax + async" do
@@ -448,10 +562,23 @@
r = ssh('localhost', 'date', {:rekey_packet_limit => 42})
r.opts[:timeout].should == 7
r.opts[:rekey_packet_limit].should == 42
r.opts[:operation_timeout].should == 11
+ r = scp_put('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0',
+ {:rekey_packet_limit => 42})
+ r.opts[:timeout].should == 7
+ r.opts[:rekey_packet_limit].should == 42
+ r.opts[:operation_timeout].should == 11
+
+ r = scp_get('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0',
+ {:rekey_packet_limit => 42})
+ r.opts[:timeout].should == 7
+ r.opts[:rekey_packet_limit].should == 42
+ r.opts[:operation_timeout].should == 11
+
+ # also test deprecated scp_dl and scp_ul
r = scp_ul('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0',
{:rekey_packet_limit => 42})
r.opts[:timeout].should == 7
r.opts[:rekey_packet_limit].should == 42
r.opts[:operation_timeout].should == 11
@@ -459,10 +586,12 @@
r = scp_dl('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0',
{:rekey_packet_limit => 42})
r.opts[:timeout].should == 7
r.opts[:rekey_packet_limit].should == 42
r.opts[:operation_timeout].should == 11
+ # /deprecated methods
+
:happy
end
t.value.should == :happy
end
@@ -470,36 +599,61 @@
r = Net::SSH::Simple.sync({:timeout => 7}) do
r = ssh('localhost', 'date', {:rekey_packet_limit => 42})
r.opts[:timeout].should == 7
r.opts[:rekey_packet_limit].should == 42
+ r = scp_put('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0',
+ {:rekey_packet_limit => 42})
+ r.opts[:timeout].should == 7
+ r.opts[:rekey_packet_limit].should == 42
+
+ r = scp_get('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0',
+ {:rekey_packet_limit => 42})
+ r.opts[:timeout].should == 7
+ r.opts[:rekey_packet_limit].should == 42
+
+ # also test deprecated scp_dl and scp_ul
r = scp_ul('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0',
{:rekey_packet_limit => 42})
r.opts[:timeout].should == 7
r.opts[:rekey_packet_limit].should == 42
r = scp_dl('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0',
{:rekey_packet_limit => 42})
r.opts[:timeout].should == 7
r.opts[:rekey_packet_limit].should == 42
+ # /deprecated methods
end
end
it "works with asynchronous block syntax" do
t = Net::SSH::Simple.async({:timeout => 7}) do
r = ssh('localhost', 'date', {:rekey_packet_limit => 42})
r.opts[:timeout].should == 7
r.opts[:rekey_packet_limit].should == 42
+ r = scp_put('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0',
+ {:rekey_packet_limit => 42})
+ r.opts[:timeout].should == 7
+ r.opts[:rekey_packet_limit].should == 42
+
+ r = scp_get('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0',
+ {:rekey_packet_limit => 42})
+ r.opts[:timeout].should == 7
+ r.opts[:rekey_packet_limit].should == 42
+
+ # also test deprecated scp_dl and scp_ul
r = scp_ul('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0',
{:rekey_packet_limit => 42})
r.opts[:timeout].should == 7
r.opts[:rekey_packet_limit].should == 42
r = scp_dl('localhost', '/tmp/ssh_test_in0', '/tmp/ssh_test_out0',
{:rekey_packet_limit => 42})
r.opts[:timeout].should == 7
r.opts[:rekey_packet_limit].should == 42
+ # /deprecated methods
+
:happy
end
t.value.should == :happy
end
end