net-sftp 2.0.5 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +2 -0
  3. data/.gitignore +5 -0
  4. data/.travis.yml +20 -0
  5. data/{CHANGELOG.rdoc → CHANGES.txt} +18 -0
  6. data/Gemfile +15 -0
  7. data/LICENSE.txt +19 -0
  8. data/README.rdoc +23 -1
  9. data/Rakefile +44 -21
  10. data/lib/net/sftp/operations/dir.rb +3 -3
  11. data/lib/net/sftp/operations/download.rb +8 -7
  12. data/lib/net/sftp/operations/file.rb +30 -8
  13. data/lib/net/sftp/operations/upload.rb +14 -6
  14. data/lib/net/sftp/session.rb +9 -7
  15. data/lib/net/sftp/version.rb +63 -13
  16. data/lib/net/sftp.rb +12 -4
  17. data/net-sftp-public_cert.pem +20 -0
  18. data/net-sftp.gemspec +38 -24
  19. data.tar.gz.sig +0 -0
  20. metadata +110 -127
  21. metadata.gz.sig +0 -0
  22. data/test/common.rb +0 -172
  23. data/test/protocol/01/test_attributes.rb +0 -97
  24. data/test/protocol/01/test_base.rb +0 -210
  25. data/test/protocol/01/test_name.rb +0 -27
  26. data/test/protocol/02/test_base.rb +0 -26
  27. data/test/protocol/03/test_base.rb +0 -27
  28. data/test/protocol/04/test_attributes.rb +0 -148
  29. data/test/protocol/04/test_base.rb +0 -74
  30. data/test/protocol/04/test_name.rb +0 -53
  31. data/test/protocol/05/test_base.rb +0 -62
  32. data/test/protocol/06/test_attributes.rb +0 -124
  33. data/test/protocol/06/test_base.rb +0 -51
  34. data/test/protocol/test_base.rb +0 -42
  35. data/test/test_all.rb +0 -7
  36. data/test/test_dir.rb +0 -47
  37. data/test/test_download.rb +0 -252
  38. data/test/test_file.rb +0 -159
  39. data/test/test_file_factory.rb +0 -48
  40. data/test/test_packet.rb +0 -9
  41. data/test/test_protocol.rb +0 -17
  42. data/test/test_request.rb +0 -71
  43. data/test/test_response.rb +0 -53
  44. data/test/test_session.rb +0 -741
  45. data/test/test_upload.rb +0 -219
data/net-sftp.gemspec CHANGED
@@ -1,34 +1,48 @@
1
- # -*- encoding: utf-8 -*-
1
+ require_relative 'lib/net/sftp/version'
2
2
 
3
- Gem::Specification.new do |s|
4
- s.name = %q{net-sftp}
5
- s.version = "2.0.5"
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "net-sftp"
5
+ spec.version = Net::SFTP::Version::STRING
6
+ spec.authors = ["Jamis Buck", "Delano Mandelbaum", "Mikl\u{f3}s Fazekas"]
7
+ spec.email = ["net-ssh@solutious.com"]
6
8
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Jamis Buck"]
9
- s.date = %q{2010-08-19}
10
- s.description = %q{A pure Ruby implementation of the SFTP client protocol}
11
- s.email = %q{netsftp@solutious.com}
12
- s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/net/sftp/constants.rb", "lib/net/sftp/errors.rb", "lib/net/sftp/operations/dir.rb", "lib/net/sftp/operations/download.rb", "lib/net/sftp/operations/file.rb", "lib/net/sftp/operations/file_factory.rb", "lib/net/sftp/operations/upload.rb", "lib/net/sftp/packet.rb", "lib/net/sftp/protocol/01/attributes.rb", "lib/net/sftp/protocol/01/base.rb", "lib/net/sftp/protocol/01/name.rb", "lib/net/sftp/protocol/02/base.rb", "lib/net/sftp/protocol/03/base.rb", "lib/net/sftp/protocol/04/attributes.rb", "lib/net/sftp/protocol/04/base.rb", "lib/net/sftp/protocol/04/name.rb", "lib/net/sftp/protocol/05/base.rb", "lib/net/sftp/protocol/06/attributes.rb", "lib/net/sftp/protocol/06/base.rb", "lib/net/sftp/protocol/base.rb", "lib/net/sftp/protocol.rb", "lib/net/sftp/request.rb", "lib/net/sftp/response.rb", "lib/net/sftp/session.rb", "lib/net/sftp/version.rb", "lib/net/sftp.rb", "README.rdoc"]
13
- s.files = ["CHANGELOG.rdoc", "lib/net/sftp/constants.rb", "lib/net/sftp/errors.rb", "lib/net/sftp/operations/dir.rb", "lib/net/sftp/operations/download.rb", "lib/net/sftp/operations/file.rb", "lib/net/sftp/operations/file_factory.rb", "lib/net/sftp/operations/upload.rb", "lib/net/sftp/packet.rb", "lib/net/sftp/protocol/01/attributes.rb", "lib/net/sftp/protocol/01/base.rb", "lib/net/sftp/protocol/01/name.rb", "lib/net/sftp/protocol/02/base.rb", "lib/net/sftp/protocol/03/base.rb", "lib/net/sftp/protocol/04/attributes.rb", "lib/net/sftp/protocol/04/base.rb", "lib/net/sftp/protocol/04/name.rb", "lib/net/sftp/protocol/05/base.rb", "lib/net/sftp/protocol/06/attributes.rb", "lib/net/sftp/protocol/06/base.rb", "lib/net/sftp/protocol/base.rb", "lib/net/sftp/protocol.rb", "lib/net/sftp/request.rb", "lib/net/sftp/response.rb", "lib/net/sftp/session.rb", "lib/net/sftp/version.rb", "lib/net/sftp.rb", "Rakefile", "README.rdoc", "setup.rb", "test/common.rb", "test/protocol/01/test_attributes.rb", "test/protocol/01/test_base.rb", "test/protocol/01/test_name.rb", "test/protocol/02/test_base.rb", "test/protocol/03/test_base.rb", "test/protocol/04/test_attributes.rb", "test/protocol/04/test_base.rb", "test/protocol/04/test_name.rb", "test/protocol/05/test_base.rb", "test/protocol/06/test_attributes.rb", "test/protocol/06/test_base.rb", "test/protocol/test_base.rb", "test/test_all.rb", "test/test_dir.rb", "test/test_download.rb", "test/test_file.rb", "test/test_file_factory.rb", "test/test_packet.rb", "test/test_protocol.rb", "test/test_request.rb", "test/test_response.rb", "test/test_session.rb", "test/test_upload.rb", "Manifest", "net-sftp.gemspec"]
14
- s.homepage = %q{http://net-ssh.rubyforge.org/sftp}
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Net-sftp", "--main", "README.rdoc"]
16
- s.require_paths = ["lib"]
17
- s.rubyforge_project = %q{net-ssh}
18
- s.rubygems_version = %q{1.3.7}
19
- s.summary = %q{A pure Ruby implementation of the SFTP client protocol}
20
- s.test_files = ["test/test_all.rb"]
9
+ if ENV['NET_SSH_BUILDGEM_SIGNED']
10
+ spec.cert_chain = ["net-sftp-public_cert.pem"]
11
+ spec.signing_key = "/mnt/gem/net-ssh-private_key.pem"
12
+ end
13
+
14
+ spec.summary = %q{A pure Ruby implementation of the SFTP client protocol.}
15
+ spec.description = %q{A pure Ruby implementation of the SFTP client protocol}
16
+ spec.homepage = "https://github.com/net-ssh/net-sftp"
17
+ spec.license = "MIT"
18
+ spec.required_rubygems_version = Gem::Requirement.new(">= 0") if spec.respond_to? :required_rubygems_version=
19
+
20
+ spec.extra_rdoc_files = [
21
+ "LICENSE.txt",
22
+ "README.rdoc"
23
+ ]
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
21
29
 
22
- if s.respond_to? :specification_version then
23
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
- s.specification_version = 3
30
+ if spec.respond_to? :specification_version then
31
+ spec.specification_version = 3
25
32
 
26
33
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
- s.add_runtime_dependency(%q<net-ssh>, [">= 2.0.9"])
34
+ spec.add_runtime_dependency(%q<net-ssh>, [">= 5.0.0", "< 7.0.0"])
35
+ spec.add_development_dependency(%q<minitest>, [">= 5"])
36
+ spec.add_development_dependency(%q<mocha>, [">= 0"])
28
37
  else
29
- s.add_dependency(%q<net-ssh>, [">= 2.0.9"])
38
+ spec.add_dependency(%q<net-ssh>, [">= 5.0.0", "< 7.0.0"])
39
+ spec.add_dependency(%q<minitest>, [">= 5"])
40
+ spec.add_dependency(%q<mocha>, [">= 0"])
30
41
  end
31
42
  else
32
- s.add_dependency(%q<net-ssh>, [">= 2.0.9"])
43
+ spec.add_dependency(%q<net-ssh>, [">= 5.0.0", "< 7.0.0"])
44
+ spec.add_dependency(%q<minitest>, [">= 5"])
45
+ spec.add_dependency(%q<test-unit>, [">= 0"])
46
+ spec.add_dependency(%q<mocha>, [">= 0"])
33
47
  end
34
48
  end
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,76 +1,104 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: net-sftp
3
- version: !ruby/object:Gem::Version
4
- hash: 5
5
- prerelease: false
6
- segments:
7
- - 2
8
- - 0
9
- - 5
10
- version: 2.0.5
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Jamis Buck
8
+ - Delano Mandelbaum
9
+ - Miklós Fazekas
14
10
  autorequire:
15
- bindir: bin
16
- cert_chain: []
17
-
18
- date: 2010-08-19 00:00:00 -04:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
11
+ bindir: exe
12
+ cert_chain:
13
+ - |
14
+ -----BEGIN CERTIFICATE-----
15
+ MIIDQDCCAiigAwIBAgIBATANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpuZXRz
16
+ c2gvREM9c29sdXRpb3VzL0RDPWNvbTAeFw0yMDA0MjYwNjI0NTFaFw0yMTA0MjYw
17
+ NjI0NTFaMCUxIzAhBgNVBAMMGm5ldHNzaC9EQz1zb2x1dGlvdXMvREM9Y29tMIIB
18
+ IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxieE22fR/qmdPKUHyYTyUx2g
19
+ wskLwrCkxay+Tvc97ZZUOwf85LDDDPqhQaTWLvRwnIOMgQE2nBPzwalVclK6a+pW
20
+ x/18KDeZY15vm3Qn5p42b0wi9hUxOqPm3J2hdCLCcgtENgdX21nVzejn39WVqFJO
21
+ lntgSDNW5+kCS8QaRsmIbzj17GKKkrsw39kiQw7FhWfJFeTjddzoZiWwc59KA/Bx
22
+ fBbmDnsMLAtAtauMOxORrbx3EOY7sHku/kSrMg3FXFay7jc6BkbbUij+MjJ/k82l
23
+ 4o8o0YO4BAnya90xgEmgOG0LCCxRhuXQFnMDuDjK2XnUe0h4/6NCn94C+z9GsQID
24
+ AQABo3sweTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUBfKiwO2e
25
+ M4NEiRrVG793qEPLYyMwHwYDVR0RBBgwFoEUbmV0c3NoQHNvbHV0aW91cy5jb20w
26
+ HwYDVR0SBBgwFoEUbmV0c3NoQHNvbHV0aW91cy5jb20wDQYJKoZIhvcNAQELBQAD
27
+ ggEBAHZOpj9ZNefc4eoie/20zX4iOgk3i+Rmjo04sMYWEtj0+4zLHXqSjune7+hd
28
+ ruP+u5xmEy9ueGQ/0kcLlDDM+8eQo6gjCY4GIQtwAzVLsUVeejE4291/GyfPf24v
29
+ 1dLWRtPwth0nyN5EOwOPqeiYiLAr5lO3wHTgfIgFhvdZpcXG8zB6JojuFJjDpKvO
30
+ HBV0P82HXjocnjusBt1YykGCvK4cDnaRruZJh6w2XeYQJJjlbqbDfBSQVesg97yM
31
+ bwwLGaqsVz0cC6q3EpU57oyyTu529o0HnDatc94Cz8t9p6ogkKtSM+jwsnnC6wmI
32
+ MMzdZVhRg3QdHAGYfd+TfsS3Mps=
33
+ -----END CERTIFICATE-----
34
+ date: 2020-04-27 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
22
37
  name: net-ssh
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
27
40
  - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 29
30
- segments:
31
- - 2
32
- - 0
33
- - 9
34
- version: 2.0.9
41
+ - !ruby/object:Gem::Version
42
+ version: 5.0.0
43
+ - - "<"
44
+ - !ruby/object:Gem::Version
45
+ version: 7.0.0
35
46
  type: :runtime
36
- version_requirements: *id001
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 5.0.0
53
+ - - "<"
54
+ - !ruby/object:Gem::Version
55
+ version: 7.0.0
56
+ - !ruby/object:Gem::Dependency
57
+ name: minitest
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '5'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '5'
70
+ - !ruby/object:Gem::Dependency
71
+ name: mocha
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
37
84
  description: A pure Ruby implementation of the SFTP client protocol
38
- email: netsftp@solutious.com
85
+ email:
86
+ - net-ssh@solutious.com
39
87
  executables: []
40
-
41
88
  extensions: []
42
-
43
- extra_rdoc_files:
44
- - CHANGELOG.rdoc
45
- - lib/net/sftp/constants.rb
46
- - lib/net/sftp/errors.rb
47
- - lib/net/sftp/operations/dir.rb
48
- - lib/net/sftp/operations/download.rb
49
- - lib/net/sftp/operations/file.rb
50
- - lib/net/sftp/operations/file_factory.rb
51
- - lib/net/sftp/operations/upload.rb
52
- - lib/net/sftp/packet.rb
53
- - lib/net/sftp/protocol/01/attributes.rb
54
- - lib/net/sftp/protocol/01/base.rb
55
- - lib/net/sftp/protocol/01/name.rb
56
- - lib/net/sftp/protocol/02/base.rb
57
- - lib/net/sftp/protocol/03/base.rb
58
- - lib/net/sftp/protocol/04/attributes.rb
59
- - lib/net/sftp/protocol/04/base.rb
60
- - lib/net/sftp/protocol/04/name.rb
61
- - lib/net/sftp/protocol/05/base.rb
62
- - lib/net/sftp/protocol/06/attributes.rb
63
- - lib/net/sftp/protocol/06/base.rb
64
- - lib/net/sftp/protocol/base.rb
65
- - lib/net/sftp/protocol.rb
66
- - lib/net/sftp/request.rb
67
- - lib/net/sftp/response.rb
68
- - lib/net/sftp/session.rb
69
- - lib/net/sftp/version.rb
70
- - lib/net/sftp.rb
89
+ extra_rdoc_files:
90
+ - LICENSE.txt
91
+ - README.rdoc
92
+ files:
93
+ - ".gitignore"
94
+ - ".travis.yml"
95
+ - CHANGES.txt
96
+ - Gemfile
97
+ - LICENSE.txt
98
+ - Manifest
71
99
  - README.rdoc
72
- files:
73
- - CHANGELOG.rdoc
100
+ - Rakefile
101
+ - lib/net/sftp.rb
74
102
  - lib/net/sftp/constants.rb
75
103
  - lib/net/sftp/errors.rb
76
104
  - lib/net/sftp/operations/dir.rb
@@ -79,6 +107,7 @@ files:
79
107
  - lib/net/sftp/operations/file_factory.rb
80
108
  - lib/net/sftp/operations/upload.rb
81
109
  - lib/net/sftp/packet.rb
110
+ - lib/net/sftp/protocol.rb
82
111
  - lib/net/sftp/protocol/01/attributes.rb
83
112
  - lib/net/sftp/protocol/01/base.rb
84
113
  - lib/net/sftp/protocol/01/name.rb
@@ -91,80 +120,34 @@ files:
91
120
  - lib/net/sftp/protocol/06/attributes.rb
92
121
  - lib/net/sftp/protocol/06/base.rb
93
122
  - lib/net/sftp/protocol/base.rb
94
- - lib/net/sftp/protocol.rb
95
123
  - lib/net/sftp/request.rb
96
124
  - lib/net/sftp/response.rb
97
125
  - lib/net/sftp/session.rb
98
126
  - lib/net/sftp/version.rb
99
- - lib/net/sftp.rb
100
- - Rakefile
101
- - README.rdoc
102
- - setup.rb
103
- - test/common.rb
104
- - test/protocol/01/test_attributes.rb
105
- - test/protocol/01/test_base.rb
106
- - test/protocol/01/test_name.rb
107
- - test/protocol/02/test_base.rb
108
- - test/protocol/03/test_base.rb
109
- - test/protocol/04/test_attributes.rb
110
- - test/protocol/04/test_base.rb
111
- - test/protocol/04/test_name.rb
112
- - test/protocol/05/test_base.rb
113
- - test/protocol/06/test_attributes.rb
114
- - test/protocol/06/test_base.rb
115
- - test/protocol/test_base.rb
116
- - test/test_all.rb
117
- - test/test_dir.rb
118
- - test/test_download.rb
119
- - test/test_file.rb
120
- - test/test_file_factory.rb
121
- - test/test_packet.rb
122
- - test/test_protocol.rb
123
- - test/test_request.rb
124
- - test/test_response.rb
125
- - test/test_session.rb
126
- - test/test_upload.rb
127
- - Manifest
127
+ - net-sftp-public_cert.pem
128
128
  - net-sftp.gemspec
129
- has_rdoc: true
130
- homepage: http://net-ssh.rubyforge.org/sftp
131
- licenses: []
132
-
129
+ - setup.rb
130
+ homepage: https://github.com/net-ssh/net-sftp
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
133
134
  post_install_message:
134
- rdoc_options:
135
- - --line-numbers
136
- - --inline-source
137
- - --title
138
- - Net-sftp
139
- - --main
140
- - README.rdoc
141
- require_paths:
135
+ rdoc_options: []
136
+ require_paths:
142
137
  - lib
143
- required_ruby_version: !ruby/object:Gem::Requirement
144
- none: false
145
- requirements:
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
146
140
  - - ">="
147
- - !ruby/object:Gem::Version
148
- hash: 3
149
- segments:
150
- - 0
151
- version: "0"
152
- required_rubygems_version: !ruby/object:Gem::Requirement
153
- none: false
154
- requirements:
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
155
145
  - - ">="
156
- - !ruby/object:Gem::Version
157
- hash: 11
158
- segments:
159
- - 1
160
- - 2
161
- version: "1.2"
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
162
148
  requirements: []
163
-
164
- rubyforge_project: net-ssh
165
- rubygems_version: 1.3.7
149
+ rubygems_version: 3.0.3
166
150
  signing_key:
167
151
  specification_version: 3
168
- summary: A pure Ruby implementation of the SFTP client protocol
169
- test_files:
170
- - test/test_all.rb
152
+ summary: A pure Ruby implementation of the SFTP client protocol.
153
+ test_files: []
metadata.gz.sig ADDED
Binary file
data/test/common.rb DELETED
@@ -1,172 +0,0 @@
1
- require 'test/unit'
2
- require 'mocha'
3
- require 'stringio'
4
-
5
- begin
6
- require 'net/ssh'
7
- require 'net/ssh/version'
8
- raise LoadError, "wrong version" unless Net::SSH::Version::STRING >= '1.99.0'
9
- rescue LoadError
10
- begin
11
- gem 'net-ssh', ">= 2.0.0"
12
- require 'net/ssh'
13
- rescue LoadError => e
14
- abort "could not load net/ssh v2 (#{e.inspect})"
15
- end
16
- end
17
-
18
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
19
- require 'net/sftp'
20
- require 'net/sftp/constants'
21
- require 'net/ssh/test'
22
-
23
- class Net::SFTP::TestCase < Test::Unit::TestCase
24
- include Net::SFTP::Constants::PacketTypes
25
- include Net::SSH::Test
26
-
27
- def default_test
28
- # do nothing, this is just hacky-hack to work around Test::Unit's
29
- # insistence that all TestCase subclasses have at least one test
30
- # method defined.
31
- end
32
-
33
- protected
34
-
35
- def raw(*args)
36
- Net::SSH::Buffer.from(*args).to_s
37
- end
38
-
39
- def sftp(options={})
40
- @sftp ||= Net::SFTP::Session.new(connection(options))
41
- end
42
-
43
- def expect_sftp_session(opts={})
44
- story do |session|
45
- channel = session.opens_channel
46
- channel.sends_subsystem("sftp")
47
- channel.sends_packet(FXP_INIT, :long, opts[:client_version] || Net::SFTP::Session::HIGHEST_PROTOCOL_VERSION_SUPPORTED)
48
- channel.gets_packet(FXP_VERSION, :long, opts[:server_version] || Net::SFTP::Session::HIGHEST_PROTOCOL_VERSION_SUPPORTED)
49
- yield channel if block_given?
50
- end
51
- end
52
-
53
- def assert_scripted_command
54
- assert_scripted do
55
- sftp.connect!
56
- yield
57
- sftp.loop
58
- end
59
- end
60
-
61
- def assert_progress_reported_open(expect={})
62
- assert_progress_reported(:open, expect)
63
- end
64
-
65
- def assert_progress_reported_put(offset, data, expect={})
66
- assert_equal offset, current_event[3] if offset
67
- assert_equal data, current_event[4] if data
68
- assert_progress_reported(:put, expect)
69
- end
70
-
71
- def assert_progress_reported_get(offset, data, expect={})
72
- assert_equal offset, current_event[3] if offset
73
- if data.is_a?(Fixnum)
74
- assert_equal data, current_event[4].length
75
- elsif data
76
- assert_equal data, current_event[4]
77
- end
78
- assert_progress_reported(:get, expect)
79
- end
80
-
81
- def assert_progress_reported_close(expect={})
82
- assert_progress_reported(:close, expect)
83
- end
84
-
85
- def assert_progress_reported_mkdir(dir)
86
- assert_equal dir, current_event[2]
87
- assert_progress_reported(:mkdir)
88
- end
89
-
90
- def assert_progress_reported_finish
91
- assert_progress_reported(:finish)
92
- end
93
-
94
- def assert_progress_reported(event, expect={})
95
- assert_equal event, current_event[0]
96
- expect.each do |key, value|
97
- assert_equal value, current_event[2].send(key)
98
- end
99
- next_event!
100
- end
101
-
102
- def assert_no_more_reported_events
103
- assert @progress.empty?, "expected #{@progress.empty?} to be empty"
104
- end
105
-
106
- def prepare_progress!
107
- @progress = []
108
- end
109
-
110
- def record_progress(event)
111
- @progress << event
112
- end
113
-
114
- def current_event
115
- @progress.first
116
- end
117
-
118
- def next_event!
119
- @progress.shift
120
- end
121
- end
122
-
123
- class Net::SSH::Test::Channel
124
- def gets_packet(type, *args)
125
- gets_data(sftp_packet(type, *args))
126
- end
127
-
128
- def sends_packet(type, *args)
129
- sends_data(sftp_packet(type, *args))
130
- end
131
-
132
- private
133
-
134
- def sftp_packet(type, *args)
135
- data = Net::SSH::Buffer.from(*args)
136
- Net::SSH::Buffer.from(:long, data.length+1, :byte, type, :raw, data).to_s
137
- end
138
- end
139
-
140
- class ProgressHandler
141
- def initialize(progress_ref)
142
- @progress = progress_ref
143
- end
144
-
145
- def on_open(*args)
146
- @progress << [:open, *args]
147
- end
148
-
149
- def on_put(*args)
150
- @progress << [:put, *args]
151
- end
152
-
153
- def on_close(*args)
154
- @progress << [:close, *args]
155
- end
156
-
157
- def on_finish(*args)
158
- @progress << [:finish, *args]
159
- end
160
- end
161
-
162
- # "prime the pump", so to speak: predefine the modules we need so we can
163
- # define the test classes in a more elegant short-hand.
164
-
165
- module Protocol
166
- module V01; end
167
- module V02; end
168
- module V03; end
169
- module V04; end
170
- module V05; end
171
- module V06; end
172
- end
@@ -1,97 +0,0 @@
1
- require 'common'
2
-
3
- module Etc; end
4
-
5
- class Protocol::V01::TestAttributes < Net::SFTP::TestCase
6
- def test_from_buffer_should_correctly_parse_buffer_and_return_attribute_object
7
- attributes = attributes_factory.from_buffer(full_buffer)
8
-
9
- assert_equal 1234567890, attributes.size
10
- assert_equal 100, attributes.uid
11
- assert_equal 200, attributes.gid
12
- assert_equal 0755, attributes.permissions
13
- assert_equal 1234567890, attributes.atime
14
- assert_equal 2345678901, attributes.mtime
15
- assert_equal "second", attributes.extended["first"]
16
- end
17
-
18
- def test_from_buffer_should_correctly_parse_buffer_with_attribute_subset_and_return_attribute_object
19
- buffer = Net::SSH::Buffer.from(:long, 0x4, :long, 0755)
20
-
21
- attributes = attributes_factory.from_buffer(buffer)
22
-
23
- assert_equal 0755, attributes.permissions
24
-
25
- assert_nil attributes.size
26
- assert_nil attributes.uid
27
- assert_nil attributes.gid
28
- assert_nil attributes.atime
29
- assert_nil attributes.mtime
30
- assert_nil attributes.extended
31
- end
32
-
33
- def test_attributes_to_s_should_build_binary_representation
34
- attributes = attributes_factory.new(
35
- :size => 1234567890,
36
- :uid => 100, :gid => 200,
37
- :permissions => 0755,
38
- :atime => 1234567890, :mtime => 2345678901,
39
- :extended => { "first" => "second" })
40
-
41
- assert_equal full_buffer.to_s, attributes.to_s
42
- end
43
-
44
- def test_attributes_to_s_should_build_binary_representation_when_subset_is_present
45
- attributes = attributes_factory.new(:permissions => 0755)
46
- assert_equal Net::SSH::Buffer.from(:long, 0x4, :long, 0755).to_s, attributes.to_s
47
- end
48
-
49
- def test_attributes_to_s_with_owner_and_group_should_translate_to_uid_and_gid
50
- attributes = attributes_factory.new(:owner => "jamis", :group => "sftp")
51
- attributes.expects(:require).with("etc").times(2)
52
- Etc.expects(:getpwnam).with("jamis").returns(mock('user', :uid => 100))
53
- Etc.expects(:getgrnam).with("sftp").returns(mock('group', :gid => 200))
54
- assert_equal Net::SSH::Buffer.from(:long, 0x2, :long, 100, :long, 200).to_s, attributes.to_s
55
- end
56
-
57
- def test_owner_should_translate_from_uid
58
- attributes = attributes_factory.new(:uid => 100)
59
- attributes.expects(:require).with("etc")
60
- Etc.expects(:getpwuid).with(100).returns(mock('user', :name => "jamis"))
61
- assert_equal "jamis", attributes.owner
62
- end
63
-
64
- def test_group_should_translate_from_gid
65
- attributes = attributes_factory.new(:gid => 200)
66
- attributes.expects(:require).with("etc")
67
- Etc.expects(:getgrgid).with(200).returns(mock('group', :name => "sftp"))
68
- assert_equal "sftp", attributes.group
69
- end
70
-
71
- def test_type_should_infer_type_from_permissions
72
- assert_equal af::T_SOCKET, af.new(:permissions => 0140755).type
73
- assert_equal af::T_SYMLINK, af.new(:permissions => 0120755).type
74
- assert_equal af::T_REGULAR, af.new(:permissions => 0100755).type
75
- assert_equal af::T_BLOCK_DEVICE, af.new(:permissions => 060755).type
76
- assert_equal af::T_DIRECTORY, af.new(:permissions => 040755).type
77
- assert_equal af::T_CHAR_DEVICE, af.new(:permissions => 020755).type
78
- assert_equal af::T_FIFO, af.new(:permissions => 010755).type
79
- assert_equal af::T_UNKNOWN, af.new(:permissions => 0755).type
80
- assert_equal af::T_UNKNOWN, af.new.type
81
- end
82
-
83
- private
84
-
85
- def full_buffer
86
- Net::SSH::Buffer.from(:long, 0x8000000f,
87
- :int64, 1234567890, :long, 100, :long, 200,
88
- :long, 0755, :long, 1234567890, :long, 2345678901,
89
- :long, 1, :string, "first", :string, "second")
90
- end
91
-
92
- def attributes_factory
93
- Net::SFTP::Protocol::V01::Attributes
94
- end
95
-
96
- alias af attributes_factory
97
- end