double-bag-ftps 0.1.0 → 0.1.1
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.
- checksums.yaml +15 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +9 -0
- data/double_bag_ftps.gemspec +2 -1
- data/lib/double_bag_ftps.rb +32 -5
- data/spec/double_bag_ftps_spec.rb +21 -9
- data/spec/spec_helper.rb +3 -1
- metadata +23 -15
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NGY4OTNkYzcyNmI3NWFlMzdlOGFiM2JjZjI4NDhiOTM4ZjcwOWU1MA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZDI0YzlmNTMwMmU1YTM3ZmNlNjNmNDI2NDFkZGQxMjZmM2ZmODRlNQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YzhjZGUyMmJiNjg3OWFhYWE5ZjNiNWMwNDYyMjE0N2U5OTQwNDBjNzZiNjY0
|
10
|
+
M2U3MGU1NDU2YTE5MzcwZjZlMmNlNWFiYWMyZWViMmNiZjAxZjA2YjE2Y2Vl
|
11
|
+
ODRjYjZiOTJmMmU0ODNlMjRlOWRlMzUzNzFiOWM2ZDg2YTUwOGE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZTNiOGRhNWNiYzM5NTZkNzM5YjZkNzYyOTA1NjI1OGEyYWM1OWYyYzEyODEz
|
14
|
+
ZjdiNTUzYzMxY2NiOGQ2ZDI0MzIwNDQwNThkMmFlZmYyN2Y0MmNjNTkzNWY1
|
15
|
+
ZGM0ZTJjMWJmZDcxMThhOThmMTgxZTM1ZjI0NWUxNTVlY2E1NDE=
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
data/double_bag_ftps.gemspec
CHANGED
@@ -3,7 +3,8 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "double-bag-ftps"
|
6
|
-
s.version = "0.1.
|
6
|
+
s.version = "0.1.1"
|
7
|
+
s.license = "MIT"
|
7
8
|
s.author = "Bryan Nix"
|
8
9
|
s.homepage = "https://github.com/bnix/double-bag-ftps"
|
9
10
|
s.summary = "Provides a child class of Net::FTP to support implicit and explicit FTPS."
|
data/lib/double_bag_ftps.rb
CHANGED
@@ -121,10 +121,9 @@ class DoubleBagFTPS < Net::FTP
|
|
121
121
|
if resp[0] != ?1
|
122
122
|
raise FTPReplyError, resp
|
123
123
|
end
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
temp_ssl_sock.close
|
124
|
+
conn = sock.accept
|
125
|
+
conn = ssl_socket(conn)
|
126
|
+
sock.close
|
128
127
|
end
|
129
128
|
return conn
|
130
129
|
end
|
@@ -150,15 +149,43 @@ class DoubleBagFTPS < Net::FTP
|
|
150
149
|
unless @ssl_context.verify_mode == OpenSSL::SSL::VERIFY_NONE
|
151
150
|
sock.post_connection_check(@hostname)
|
152
151
|
end
|
152
|
+
decorate_socket sock
|
153
153
|
return sock
|
154
154
|
end
|
155
155
|
private :ssl_socket
|
156
156
|
|
157
|
+
# Ruby 2.0's Ftp class closes sockets by first doing a shutdown,
|
158
|
+
# setting the read timeout, and doing a read. OpenSSL doesn't
|
159
|
+
# have those methods, so fake it.
|
160
|
+
#
|
161
|
+
# Ftp calls #close in an ensure block, so the socket will still get
|
162
|
+
# closed.
|
163
|
+
|
164
|
+
def decorate_socket(sock)
|
165
|
+
|
166
|
+
def sock.shutdown(how)
|
167
|
+
@shutdown = true
|
168
|
+
end
|
169
|
+
|
170
|
+
def sock.read_timeout=(seconds)
|
171
|
+
end
|
172
|
+
|
173
|
+
# Skip read after shutdown. Prevents 2.0 from hanging in
|
174
|
+
# Ftp#close
|
175
|
+
|
176
|
+
def sock.read(*args)
|
177
|
+
return if @shutdown
|
178
|
+
super(*args)
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
private :decorate_socket
|
183
|
+
|
157
184
|
def DoubleBagFTPS.create_ssl_context(params = {})
|
158
185
|
raise 'SSL extension not installed' unless defined?(OpenSSL)
|
159
186
|
context = OpenSSL::SSL::SSLContext.new
|
160
187
|
context.set_params(params)
|
161
188
|
return context
|
162
189
|
end
|
163
|
-
|
190
|
+
|
164
191
|
end
|
@@ -6,23 +6,35 @@ shared_examples_for "DoubleBagFTPS" do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it "logs in with a user name and password" do
|
9
|
-
|
9
|
+
@ftp.connect(HOST)
|
10
10
|
lambda {@ftp.login(USR, PASSWD)}.should_not raise_error
|
11
11
|
end
|
12
12
|
|
13
13
|
it "can open a secure data channel" do
|
14
|
-
|
14
|
+
@ftp.connect(HOST)
|
15
15
|
@ftp.login(USR, PASSWD)
|
16
16
|
@ftp.send(:transfercmd, 'nlst').should be_an_instance_of OpenSSL::SSL::SSLSocket
|
17
17
|
end
|
18
18
|
|
19
|
+
it "can retrieve a file" do
|
20
|
+
Dir.mktmpdir do |temp_dir|
|
21
|
+
@ftp.connect HOST
|
22
|
+
@ftp.login USR, PASSWD
|
23
|
+
filename = @ftp.nlst.first
|
24
|
+
filename.should_not be_nil
|
25
|
+
local_path = File.join(temp_dir, filename)
|
26
|
+
@ftp.get(filename, local_path)
|
27
|
+
File.exists?(local_path).should be_true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
19
31
|
it "prevents setting the FTPS mode while connected" do
|
20
32
|
@ftp.connect(HOST)
|
21
|
-
lambda {@ftp.ftps_mode =
|
33
|
+
lambda {@ftp.ftps_mode = DoubleBagFTPS::IMPLICIT}.should raise_error RuntimeError
|
22
34
|
end
|
23
35
|
|
24
36
|
it "prevents setting the FTPS mode to an unrecognized value" do
|
25
|
-
lambda {@ftp.ftps_mode = 'dummy value'}.should raise_error
|
37
|
+
lambda {@ftp.ftps_mode = 'dummy value'}.should raise_error ArgumentError
|
26
38
|
end
|
27
39
|
|
28
40
|
end
|
@@ -51,14 +63,14 @@ describe DoubleBagFTPS do
|
|
51
63
|
|
52
64
|
context "explicit" do
|
53
65
|
before(:each) do
|
54
|
-
|
55
|
-
|
66
|
+
@ftp = DoubleBagFTPS.new
|
67
|
+
@ftp.ftps_mode = DoubleBagFTPS::EXPLICIT
|
56
68
|
@ftp.passive = true
|
57
|
-
|
69
|
+
@ftp.ssl_context = DoubleBagFTPS.create_ssl_context(:verify_mode => OpenSSL::SSL::VERIFY_NONE)
|
58
70
|
end
|
59
71
|
|
60
72
|
after(:each) do
|
61
|
-
|
73
|
+
@ftp.close unless @ftp.welcome.nil?
|
62
74
|
end
|
63
75
|
|
64
76
|
it "does not use an SSLSocket when first connected" do
|
@@ -69,4 +81,4 @@ describe DoubleBagFTPS do
|
|
69
81
|
|
70
82
|
it_should_behave_like "DoubleBagFTPS"
|
71
83
|
end
|
72
|
-
end
|
84
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,38 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: double-bag-ftps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Bryan Nix
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-05-06 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: rspec
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
31
|
- - ! '>='
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
34
|
type: :development
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
36
41
|
description:
|
37
42
|
email:
|
38
43
|
executables: []
|
@@ -40,6 +45,7 @@ extensions: []
|
|
40
45
|
extra_rdoc_files: []
|
41
46
|
files:
|
42
47
|
- .gitignore
|
48
|
+
- CHANGELOG.md
|
43
49
|
- LICENSE
|
44
50
|
- README.md
|
45
51
|
- Rakefile
|
@@ -48,27 +54,29 @@ files:
|
|
48
54
|
- spec/double_bag_ftps_spec.rb
|
49
55
|
- spec/spec_helper.rb
|
50
56
|
homepage: https://github.com/bnix/double-bag-ftps
|
51
|
-
licenses:
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
52
60
|
post_install_message:
|
53
61
|
rdoc_options: []
|
54
62
|
require_paths:
|
55
63
|
- lib
|
56
64
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
65
|
requirements:
|
59
66
|
- - ! '>='
|
60
67
|
- !ruby/object:Gem::Version
|
61
68
|
version: '0'
|
62
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
70
|
requirements:
|
65
71
|
- - ! '>='
|
66
72
|
- !ruby/object:Gem::Version
|
67
73
|
version: '0'
|
68
74
|
requirements: []
|
69
75
|
rubyforge_project:
|
70
|
-
rubygems_version:
|
76
|
+
rubygems_version: 2.0.3
|
71
77
|
signing_key:
|
72
|
-
specification_version:
|
78
|
+
specification_version: 4
|
73
79
|
summary: Provides a child class of Net::FTP to support implicit and explicit FTPS.
|
74
|
-
test_files:
|
80
|
+
test_files:
|
81
|
+
- spec/double_bag_ftps_spec.rb
|
82
|
+
- spec/spec_helper.rb
|