net-scp 1.2.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
metadata CHANGED
@@ -1,108 +1,104 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-scp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
5
- prerelease:
4
+ version: 2.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jamis Buck
9
8
  - Delano Mandelbaum
9
+ - Miklós Fazekas
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain:
13
- - !binary |-
14
- LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUROakNDQWg2Z0F3SUJB
15
- Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREJCTVE4d0RRWURWUVFEREFaa1pX
16
- eGgKYm04eEdUQVhCZ29Ka2lhSmsvSXNaQUVaRmdsemIyeDFkR2x2ZFhNeEV6
17
- QVJCZ29Ka2lhSmsvSXNaQUVaRmdOagpiMjB3SGhjTk1UUXdORE13TVRjek5q
18
- STJXaGNOTVRVd05ETXdNVGN6TmpJMldqQkJNUTh3RFFZRFZRUUREQVprClpX
19
- eGhibTh4R1RBWEJnb0praWFKay9Jc1pBRVpGZ2x6YjJ4MWRHbHZkWE14RXpB
20
- UkJnb0praWFKay9Jc1pBRVoKRmdOamIyMHdnZ0VpTUEwR0NTcUdTSWIzRFFF
21
- QkFRVUFBNElCRHdBd2dnRUtBb0lCQVFEZGJlRmpNNjcrVHhycQorOEhhRDR3
22
- S0VpYWNSb0I4cHMxN1Z6dDlUQlV5b01NajVLVHRGaXB0ci8rWlR1Zy9ZZFlC
23
- cXVNcHJQc0tsWU0yCk5vRzZCenZEY3ZRSzF6cmRIbnlWb3NJREtBSGsyd255
24
- Ti9wc1ppa1MxYm85blVIQ1M1aEpkUEVuUVp4L014VFoKK0dqdVJzaUJ4UFlC
25
- WG5xT2JMaFI4M0xCZVdzYXVXVHV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Taqhq3wq/JJRghq8fJUqWN5aBtMQb/61z5J3mKAUJsUN2/VdDph2fRPDpECa
32
+ uWREKzWwXbaB96/ZyzoyP7FsQBLgdDL++g2nF0neCENc5Wj5IlQZiH0a2+X3jAgm
33
+ 7UnoE3CP9Tk5GHVUina5gPyzl0VI4s4pYCPehQ==
34
+ -----END CERTIFICATE-----
35
+ date: 2019-03-20 00:00:00.000000000 Z
42
36
  dependencies:
43
37
  - !ruby/object:Gem::Dependency
44
38
  name: net-ssh
45
39
  requirement: !ruby/object:Gem::Requirement
46
- none: false
47
40
  requirements:
48
- - - ! '>='
41
+ - - ">="
49
42
  - !ruby/object:Gem::Version
50
43
  version: 2.6.5
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: 6.0.0
51
47
  type: :runtime
52
48
  prerelease: false
53
49
  version_requirements: !ruby/object:Gem::Requirement
54
- none: false
55
50
  requirements:
56
- - - ! '>='
51
+ - - ">="
57
52
  - !ruby/object:Gem::Version
58
53
  version: 2.6.5
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: 6.0.0
59
57
  - !ruby/object:Gem::Dependency
60
58
  name: test-unit
61
59
  requirement: !ruby/object:Gem::Requirement
62
- none: false
63
60
  requirements:
64
- - - ! '>='
61
+ - - ">="
65
62
  - !ruby/object:Gem::Version
66
63
  version: '0'
67
64
  type: :development
68
65
  prerelease: false
69
66
  version_requirements: !ruby/object:Gem::Requirement
70
- none: false
71
67
  requirements:
72
- - - ! '>='
68
+ - - ">="
73
69
  - !ruby/object:Gem::Version
74
70
  version: '0'
75
71
  - !ruby/object:Gem::Dependency
76
72
  name: mocha
77
73
  requirement: !ruby/object:Gem::Requirement
78
- none: false
79
74
  requirements:
80
- - - ! '>='
75
+ - - ">="
81
76
  - !ruby/object:Gem::Version
82
77
  version: '0'
83
78
  type: :development
84
79
  prerelease: false
85
80
  version_requirements: !ruby/object:Gem::Requirement
86
- none: false
87
81
  requirements:
88
- - - ! '>='
82
+ - - ">="
89
83
  - !ruby/object:Gem::Version
90
84
  version: '0'
91
85
  description: A pure Ruby implementation of the SCP client protocol
92
- email: net-ssh@solutious.com
86
+ email:
87
+ - net-ssh@solutious.com
93
88
  executables: []
94
89
  extensions: []
95
90
  extra_rdoc_files:
96
91
  - LICENSE.txt
97
92
  - README.rdoc
98
93
  files:
99
- - .travis.yml
94
+ - ".gitignore"
95
+ - ".travis.yml"
100
96
  - CHANGES.txt
97
+ - Gemfile
101
98
  - LICENSE.txt
102
99
  - Manifest
103
100
  - README.rdoc
104
101
  - Rakefile
105
- - gem-public_cert.pem
106
102
  - lib/net/scp.rb
107
103
  - lib/net/scp/download.rb
108
104
  - lib/net/scp/errors.rb
@@ -110,36 +106,31 @@ files:
110
106
  - lib/net/scp/version.rb
111
107
  - lib/uri/open-scp.rb
112
108
  - lib/uri/scp.rb
109
+ - net-scp-public_cert.pem
113
110
  - net-scp.gemspec
114
111
  - setup.rb
115
- - test/common.rb
116
- - test/test_all.rb
117
- - test/test_download.rb
118
- - test/test_scp.rb
119
- - test/test_upload.rb
120
112
  homepage: https://github.com/net-ssh/net-scp
121
113
  licenses:
122
114
  - MIT
115
+ metadata: {}
123
116
  post_install_message:
124
117
  rdoc_options: []
125
118
  require_paths:
126
119
  - lib
127
120
  required_ruby_version: !ruby/object:Gem::Requirement
128
- none: false
129
121
  requirements:
130
- - - ! '>='
122
+ - - ">="
131
123
  - !ruby/object:Gem::Version
132
124
  version: '0'
133
125
  required_rubygems_version: !ruby/object:Gem::Requirement
134
- none: false
135
126
  requirements:
136
- - - ! '>='
127
+ - - ">="
137
128
  - !ruby/object:Gem::Version
138
129
  version: '0'
139
130
  requirements: []
140
- rubyforge_project: net-scp
141
- rubygems_version: 1.8.23
131
+ rubyforge_project:
132
+ rubygems_version: 2.6.8
142
133
  signing_key:
143
134
  specification_version: 3
144
- summary: A pure Ruby implementation of the SCP client protocol
135
+ summary: A pure Ruby implementation of the SCP client protocol.
145
136
  test_files: []
metadata.gz.sig CHANGED
Bin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
17
- /Ci++ZEh/QR9qy11AHciEIXnNkytidyZtLr4MWhtbV468y6shpPYdKU/uCINSgvt
18
- FpMAM5Nit8L8nHwf3IIUPg7lsMCRzOkQ/FD87BI3V3SnFNoTCdGgnGj3jfW4zRlL
19
- iFyareFPA84btQ==
20
- -----END CERTIFICATE-----
@@ -1,153 +0,0 @@
1
- require 'test/unit'
2
- require 'mocha/setup'
3
-
4
- begin
5
- gem 'net-ssh', ">= 2.0.0"
6
- require 'net/ssh'
7
- rescue LoadError
8
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../net-ssh/lib"
9
-
10
- begin
11
- require 'net/ssh'
12
- require 'net/ssh/version'
13
- raise LoadError, "wrong version" unless Net::SSH::Version::STRING >= '1.99.0'
14
- rescue LoadError => e
15
- abort "could not load net/ssh v2 (#{e.inspect})"
16
- end
17
- end
18
-
19
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
20
-
21
- require 'net/scp'
22
- require 'net/ssh/test'
23
-
24
- class Net::SSH::Test::Channel
25
- def gets_ok
26
- gets_data "\0"
27
- end
28
-
29
- def sends_ok
30
- sends_data "\0"
31
- end
32
- end
33
-
34
- class Net::SCP::TestCase < Test::Unit::TestCase
35
- include Net::SSH::Test
36
-
37
- def default_test
38
- # do nothing, this is just a hacky-hack to work around Test::Unit's
39
- # insistence that all TestCase subclasses have at least one test
40
- # method defined.
41
- end
42
-
43
- protected
44
-
45
- def prepare_file(path, contents="", mode=0666, mtime=Time.now, atime=Time.now)
46
- entry = FileEntry.new(path, contents, mode, mtime, atime)
47
- entry.stub!
48
- entry
49
- end
50
-
51
- def prepare_directory(path, mode=0777, mtime=Time.now, atime=Time.now)
52
- directory = DirectoryEntry.new(path, mode, mtime, atime)
53
- yield directory if block_given?
54
- directory.stub!
55
- end
56
-
57
- # The POSIX spec unfortunately allows all characters in file names except
58
- # ASCII 0x00(NUL) and 0x2F(/)
59
- #
60
- # Ideally, we should be testing filenames with newlines, but Mocha doesn't
61
- # like this at all, so we leave them out. However, the Shellwords module
62
- # handles newlines just fine, so we can be reasonably confident that they
63
- # will work in practice
64
- def awful_file_name
65
- (((0x00..0x7f).to_a - [0x00, 0x0a, 0x2f]).map { |n| n.chr }).join + '.txt'
66
- end
67
-
68
- def escaped_file_name
69
- "\\\001\\\002\\\003\\\004\\\005\\\006\\\a\\\b\\\t\\\v\\\f\\\r\\\016\\\017\\\020\\\021\\\022\\\023\\\024\\\025\\\026\\\027\\\030\\\031\\\032\\\e\\\034\\\035\\\036\\\037\\ \\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+,-.0123456789:\\;\\<\\=\\>\\?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\[\\\\\\]\\^_\\`abcdefghijklmnopqrstuvwxyz\\{\\|\\}\\~\\\177.txt"
70
- end
71
-
72
- class FileEntry
73
- attr_reader :path, :contents, :mode, :mtime, :atime, :io
74
-
75
- def initialize(path, contents, mode=0666, mtime=Time.now, atime=Time.now)
76
- @path, @contents, @mode = path, contents, mode
77
- @mtime, @atime = mtime, atime
78
- end
79
-
80
- def name
81
- @name ||= File.basename(path)
82
- end
83
-
84
- def stub!
85
- stat = Mocha::Mock.new("file::stat")
86
- stat.stubs(:size => contents.length, :mode => mode, :mtime => mtime, :atime => atime, :directory? => false)
87
-
88
- File.stubs(:stat).with(path).returns(stat)
89
- File.stubs(:directory?).with(path).returns(false)
90
- File.stubs(:file?).with(path).returns(true)
91
- File.stubs(:open).with(path, "rb").returns(StringIO.new(contents))
92
-
93
- @io = StringIO.new
94
- File.stubs(:new).with(path, "wb", mode).returns(io)
95
- end
96
- end
97
-
98
- class DirectoryEntry
99
- attr_reader :path, :mode, :mtime, :atime
100
- attr_reader :entries
101
-
102
- def initialize(path, mode=0777, mtime=Time.now, atime=Time.now)
103
- @path, @mode = path, mode
104
- @mtime, @atime = mtime, atime
105
- @entries = []
106
- end
107
-
108
- def name
109
- @name ||= File.basename(path)
110
- end
111
-
112
- def file(name, *args)
113
- (entries << FileEntry.new(File.join(path, name), *args)).last
114
- end
115
-
116
- def directory(name, *args)
117
- entry = DirectoryEntry.new(File.join(path, name), *args)
118
- yield entry if block_given?
119
- (entries << entry).last
120
- end
121
-
122
- def stub!
123
- Dir.stubs(:mkdir).with { |*a| a.first == path }
124
-
125
- stat = Mocha::Mock.new("file::stat")
126
- stat.stubs(:size => 1024, :mode => mode, :mtime => mtime, :atime => atime, :directory? => true)
127
-
128
- File.stubs(:stat).with(path).returns(stat)
129
- File.stubs(:directory?).with(path).returns(true)
130
- File.stubs(:file?).with(path).returns(false)
131
- Dir.stubs(:entries).with(path).returns(%w(. ..) + entries.map { |e| e.name }.sort)
132
-
133
- entries.each { |e| e.stub! }
134
- end
135
- end
136
-
137
- def expect_scp_session(arguments)
138
- story do |session|
139
- channel = session.opens_channel
140
- channel.sends_exec "scp #{arguments}"
141
- yield channel if block_given?
142
- channel.sends_eof
143
- channel.gets_exit_status
144
- channel.gets_eof
145
- channel.gets_close
146
- channel.sends_close
147
- end
148
- end
149
-
150
- def scp(options={})
151
- @scp ||= Net::SCP.new(connection(options))
152
- end
153
- end
@@ -1,3 +0,0 @@
1
- Dir.chdir(File.dirname(__FILE__)) do
2
- Dir['**/test_*.rb'].each { |file| require(file) }
3
- end
@@ -1,197 +0,0 @@
1
- require 'common'
2
-
3
- class TestDownload < Net::SCP::TestCase
4
- def test_download_file_should_transfer_file
5
- file = prepare_file("/path/to/local.txt", "a" * 1234)
6
-
7
- expect_scp_session "-f /path/to/remote.txt" do |channel|
8
- simple_download(channel)
9
- end
10
-
11
- assert_scripted { scp.download!("/path/to/remote.txt", "/path/to/local.txt") }
12
- assert_equal "a" * 1234, file.io.string
13
- end
14
-
15
- def test_download_file_with_spaces_in_name_should_escape_remote_file_name
16
- file = prepare_file("/path/to/local file.txt", "")
17
-
18
- expect_scp_session "-f /path/to/remote\\ file.txt" do |channel|
19
- channel.sends_ok
20
- channel.gets_data "C0666 0 local file.txt\n"
21
- channel.sends_ok
22
- channel.gets_ok
23
- channel.sends_ok
24
- end
25
-
26
- assert_scripted { scp.download!("/path/to/remote file.txt", "/path/to/local file.txt") }
27
- end
28
-
29
- def test_download_file_with_metacharacters_in_name_should_escape_remote_file_name
30
- file = prepare_file("/path/to/local/#{awful_file_name}", "")
31
-
32
- expect_scp_session "-f /path/to/remote/#{escaped_file_name}" do |channel|
33
- channel.sends_ok
34
- channel.gets_data "C0666 0 #{awful_file_name}\n"
35
- channel.sends_ok
36
- channel.gets_ok
37
- channel.sends_ok
38
- end
39
-
40
- assert_scripted { scp.download!("/path/to/remote/#{awful_file_name}", "/path/to/local/#{awful_file_name}") }
41
- end
42
-
43
- def test_download_with_preserve_should_send_times
44
- file = prepare_file("/path/to/local.txt", "a" * 1234, 0644, Time.at(1234567890, 123456), Time.at(12121212, 232323))
45
-
46
- expect_scp_session "-f -p /path/to/remote.txt" do |channel|
47
- channel.sends_ok
48
- channel.gets_data "T1234567890 123456 12121212 232323\n"
49
- simple_download(channel, 0644)
50
- end
51
-
52
- File.expects(:utime).with(Time.at(12121212, 232323), Time.at(1234567890, 123456), "/path/to/local.txt")
53
- assert_scripted { scp.download!("/path/to/remote.txt", "/path/to/local.txt", :preserve => true) }
54
- assert_equal "a" * 1234, file.io.string
55
- end
56
-
57
- def test_download_with_error_should_respond_with_error_text
58
- story do |session|
59
- channel = session.opens_channel
60
- channel.sends_exec "scp -f /path/to/remote.txt"
61
-
62
- channel.sends_ok
63
- channel.gets_data "\x01File not found: /path/to/remote.txt\n"
64
- channel.sends_ok
65
-
66
- channel.gets_eof
67
- channel.gets_exit_status(1)
68
- channel.gets_close
69
- channel.sends_close
70
- end
71
-
72
- error = nil
73
- assert_scripted do
74
- begin
75
- scp.download!("/path/to/remote.txt")
76
- rescue
77
- error = $!
78
- end
79
- end
80
- assert_equal Net::SCP::Error, error.class
81
- assert_equal "SCP did not finish successfully (1): File not found: /path/to/remote.txt\n", error.message
82
- end
83
-
84
- def test_download_with_progress_callback_should_invoke_callback
85
- prepare_file("/path/to/local.txt", "a" * 3000 + "b" * 3000 + "c" * 3000 + "d" * 3000)
86
-
87
- expect_scp_session "-f /path/to/remote.txt" do |channel|
88
- channel.sends_ok
89
- channel.gets_data "C0666 12000 remote.txt\n"
90
- channel.sends_ok
91
- channel.gets_data "a" * 3000
92
- channel.inject_remote_delay!
93
- channel.gets_data "b" * 3000
94
- channel.inject_remote_delay!
95
- channel.gets_data "c" * 3000
96
- channel.inject_remote_delay!
97
- channel.gets_data "d" * 3000
98
- channel.gets_ok
99
- channel.sends_ok
100
- end
101
-
102
- calls = []
103
- progress = Proc.new { |ch, *args| calls << args }
104
-
105
- assert_scripted do
106
- scp.download!("/path/to/remote.txt", "/path/to/local.txt", &progress)
107
- end
108
-
109
- assert_equal ["/path/to/local.txt", 0, 12000], calls.shift
110
- assert_equal ["/path/to/local.txt", 3000, 12000], calls.shift
111
- assert_equal ["/path/to/local.txt", 6000, 12000], calls.shift
112
- assert_equal ["/path/to/local.txt", 9000, 12000], calls.shift
113
- assert_equal ["/path/to/local.txt", 12000, 12000], calls.shift
114
- assert calls.empty?
115
- end
116
-
117
- def test_download_io_with_recursive_should_raise_error
118
- expect_scp_session "-f -r /path/to/remote.txt"
119
- assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote.txt", StringIO.new, :recursive => true) }
120
- end
121
-
122
- def test_download_io_with_preserve_should_ignore_preserve
123
- expect_scp_session "-f -p /path/to/remote.txt" do |channel|
124
- simple_download(channel)
125
- end
126
-
127
- io = StringIO.new
128
- assert_scripted { scp.download!("/path/to/remote.txt", io, :preserve => true) }
129
- assert_equal "a" * 1234, io.string
130
- end
131
-
132
- def test_download_io_should_transfer_data
133
- expect_scp_session "-f /path/to/remote.txt" do |channel|
134
- simple_download(channel)
135
- end
136
-
137
- io = StringIO.new
138
- assert_scripted { scp.download!("/path/to/remote.txt", io) }
139
- assert_equal "a" * 1234, io.string
140
- end
141
-
142
- def test_download_bang_without_target_should_return_string
143
- expect_scp_session "-f /path/to/remote.txt" do |channel|
144
- simple_download(channel)
145
- end
146
-
147
- assert_scripted do
148
- assert_equal "a" * 1234, scp.download!("/path/to/remote.txt")
149
- end
150
- end
151
-
152
- def test_download_directory_without_recursive_should_raise_error
153
- expect_scp_session "-f /path/to/remote" do |channel|
154
- channel.sends_ok
155
- channel.gets_data "D0755 0 remote\n"
156
- end
157
-
158
- assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote") }
159
- end
160
-
161
- def test_download_directory_should_create_directory_and_files_locally
162
- file = nil
163
- prepare_directory "/path/to/local" do |dir|
164
- dir.directory "remote" do |dir2|
165
- dir2.directory "sub" do |dir3|
166
- file = dir3.file "remote.txt", ""
167
- end
168
- end
169
- end
170
-
171
- expect_scp_session "-f -r /path/to/remote" do |channel|
172
- channel.sends_ok
173
- channel.gets_data "D0755 0 remote\n"
174
- channel.sends_ok
175
- channel.gets_data "D0755 0 sub\n"
176
- simple_download(channel)
177
- channel.gets_data "E\n"
178
- channel.sends_ok
179
- channel.gets_data "E\n"
180
- channel.sends_ok
181
- end
182
-
183
- scp.download!("/path/to/remote", "/path/to/local", :recursive => true, :ssh => { :verbose => :debug })
184
- assert_equal "a" * 1234, file.io.string
185
- end
186
-
187
- private
188
-
189
- def simple_download(channel, mode=0666)
190
- channel.sends_ok
191
- channel.gets_data "C%04o 1234 remote.txt\n" % mode
192
- channel.sends_ok
193
- channel.gets_data "a" * 1234
194
- channel.gets_ok
195
- channel.sends_ok
196
- end
197
- end