net-sftp 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. data/CHANGELOG.rdoc +23 -0
  2. data/Manifest +55 -0
  3. data/README.rdoc +96 -0
  4. data/Rakefile +30 -0
  5. data/lib/net/sftp.rb +53 -38
  6. data/lib/net/sftp/constants.rb +187 -0
  7. data/lib/net/sftp/errors.rb +34 -20
  8. data/lib/net/sftp/operations/dir.rb +93 -0
  9. data/lib/net/sftp/operations/download.rb +364 -0
  10. data/lib/net/sftp/operations/file.rb +176 -0
  11. data/lib/net/sftp/operations/file_factory.rb +60 -0
  12. data/lib/net/sftp/operations/upload.rb +387 -0
  13. data/lib/net/sftp/packet.rb +21 -0
  14. data/lib/net/sftp/protocol.rb +32 -0
  15. data/lib/net/sftp/protocol/01/attributes.rb +265 -96
  16. data/lib/net/sftp/protocol/01/base.rb +268 -0
  17. data/lib/net/sftp/protocol/01/name.rb +43 -0
  18. data/lib/net/sftp/protocol/02/base.rb +31 -0
  19. data/lib/net/sftp/protocol/03/base.rb +35 -0
  20. data/lib/net/sftp/protocol/04/attributes.rb +120 -195
  21. data/lib/net/sftp/protocol/04/base.rb +94 -0
  22. data/lib/net/sftp/protocol/04/name.rb +67 -0
  23. data/lib/net/sftp/protocol/05/base.rb +66 -0
  24. data/lib/net/sftp/protocol/06/attributes.rb +107 -0
  25. data/lib/net/sftp/protocol/06/base.rb +63 -0
  26. data/lib/net/sftp/protocol/base.rb +50 -0
  27. data/lib/net/sftp/request.rb +91 -0
  28. data/lib/net/sftp/response.rb +76 -0
  29. data/lib/net/sftp/session.rb +914 -238
  30. data/lib/net/sftp/version.rb +14 -21
  31. data/net-sftp.gemspec +60 -0
  32. data/setup.rb +1331 -0
  33. data/test/common.rb +173 -0
  34. data/test/protocol/01/test_attributes.rb +97 -0
  35. data/test/protocol/01/test_base.rb +210 -0
  36. data/test/protocol/01/test_name.rb +27 -0
  37. data/test/protocol/02/test_base.rb +26 -0
  38. data/test/protocol/03/test_base.rb +27 -0
  39. data/test/protocol/04/test_attributes.rb +148 -0
  40. data/test/protocol/04/test_base.rb +74 -0
  41. data/test/protocol/04/test_name.rb +49 -0
  42. data/test/protocol/05/test_base.rb +62 -0
  43. data/test/protocol/06/test_attributes.rb +124 -0
  44. data/test/protocol/06/test_base.rb +51 -0
  45. data/test/protocol/test_base.rb +42 -0
  46. data/test/test_all.rb +3 -0
  47. data/test/test_dir.rb +47 -0
  48. data/test/test_download.rb +252 -0
  49. data/test/test_file.rb +159 -0
  50. data/test/test_file_factory.rb +48 -0
  51. data/test/test_packet.rb +9 -0
  52. data/test/test_protocol.rb +17 -0
  53. data/test/test_request.rb +71 -0
  54. data/test/test_response.rb +53 -0
  55. data/test/test_session.rb +741 -0
  56. data/test/test_upload.rb +219 -0
  57. metadata +59 -111
  58. data/doc/LICENSE-BSD +0 -27
  59. data/doc/LICENSE-GPL +0 -280
  60. data/doc/LICENSE-RUBY +0 -56
  61. data/doc/faq/faq.html +0 -298
  62. data/doc/faq/faq.rb +0 -154
  63. data/doc/faq/faq.yml +0 -183
  64. data/examples/asynchronous.rb +0 -57
  65. data/examples/get-put.rb +0 -45
  66. data/examples/sftp-open-uri.rb +0 -30
  67. data/examples/ssh-service.rb +0 -30
  68. data/examples/synchronous.rb +0 -131
  69. data/lib/net/sftp/operations/abstract.rb +0 -108
  70. data/lib/net/sftp/operations/close.rb +0 -31
  71. data/lib/net/sftp/operations/errors.rb +0 -76
  72. data/lib/net/sftp/operations/fsetstat.rb +0 -36
  73. data/lib/net/sftp/operations/fstat.rb +0 -32
  74. data/lib/net/sftp/operations/lstat.rb +0 -31
  75. data/lib/net/sftp/operations/mkdir.rb +0 -33
  76. data/lib/net/sftp/operations/open.rb +0 -32
  77. data/lib/net/sftp/operations/opendir.rb +0 -32
  78. data/lib/net/sftp/operations/read.rb +0 -88
  79. data/lib/net/sftp/operations/readdir.rb +0 -55
  80. data/lib/net/sftp/operations/realpath.rb +0 -37
  81. data/lib/net/sftp/operations/remove.rb +0 -31
  82. data/lib/net/sftp/operations/rename.rb +0 -32
  83. data/lib/net/sftp/operations/rmdir.rb +0 -31
  84. data/lib/net/sftp/operations/services.rb +0 -42
  85. data/lib/net/sftp/operations/setstat.rb +0 -33
  86. data/lib/net/sftp/operations/stat.rb +0 -31
  87. data/lib/net/sftp/operations/write.rb +0 -63
  88. data/lib/net/sftp/protocol/01/impl.rb +0 -251
  89. data/lib/net/sftp/protocol/01/packet-assistant.rb +0 -82
  90. data/lib/net/sftp/protocol/01/services.rb +0 -47
  91. data/lib/net/sftp/protocol/02/impl.rb +0 -39
  92. data/lib/net/sftp/protocol/02/packet-assistant.rb +0 -32
  93. data/lib/net/sftp/protocol/02/services.rb +0 -44
  94. data/lib/net/sftp/protocol/03/impl.rb +0 -42
  95. data/lib/net/sftp/protocol/03/packet-assistant.rb +0 -35
  96. data/lib/net/sftp/protocol/03/services.rb +0 -44
  97. data/lib/net/sftp/protocol/04/impl.rb +0 -86
  98. data/lib/net/sftp/protocol/04/packet-assistant.rb +0 -45
  99. data/lib/net/sftp/protocol/04/services.rb +0 -44
  100. data/lib/net/sftp/protocol/05/impl.rb +0 -90
  101. data/lib/net/sftp/protocol/05/packet-assistant.rb +0 -34
  102. data/lib/net/sftp/protocol/05/services.rb +0 -44
  103. data/lib/net/sftp/protocol/constants.rb +0 -60
  104. data/lib/net/sftp/protocol/driver.rb +0 -235
  105. data/lib/net/sftp/protocol/packet-assistant.rb +0 -84
  106. data/lib/net/sftp/protocol/services.rb +0 -55
  107. data/lib/uri/open-sftp.rb +0 -54
  108. data/lib/uri/sftp.rb +0 -42
  109. data/test/ALL-TESTS.rb +0 -23
  110. data/test/operations/tc_abstract.rb +0 -124
  111. data/test/operations/tc_close.rb +0 -40
  112. data/test/operations/tc_fsetstat.rb +0 -48
  113. data/test/operations/tc_fstat.rb +0 -40
  114. data/test/operations/tc_lstat.rb +0 -40
  115. data/test/operations/tc_mkdir.rb +0 -48
  116. data/test/operations/tc_open.rb +0 -42
  117. data/test/operations/tc_opendir.rb +0 -40
  118. data/test/operations/tc_read.rb +0 -103
  119. data/test/operations/tc_readdir.rb +0 -88
  120. data/test/operations/tc_realpath.rb +0 -54
  121. data/test/operations/tc_remove.rb +0 -40
  122. data/test/operations/tc_rmdir.rb +0 -40
  123. data/test/operations/tc_setstat.rb +0 -48
  124. data/test/operations/tc_stat.rb +0 -40
  125. data/test/operations/tc_write.rb +0 -91
  126. data/test/protocol/01/tc_attributes.rb +0 -138
  127. data/test/protocol/01/tc_impl.rb +0 -294
  128. data/test/protocol/01/tc_packet_assistant.rb +0 -81
  129. data/test/protocol/02/tc_impl.rb +0 -41
  130. data/test/protocol/02/tc_packet_assistant.rb +0 -31
  131. data/test/protocol/03/tc_impl.rb +0 -48
  132. data/test/protocol/03/tc_packet_assistant.rb +0 -34
  133. data/test/protocol/04/tc_attributes.rb +0 -174
  134. data/test/protocol/04/tc_impl.rb +0 -91
  135. data/test/protocol/04/tc_packet_assistant.rb +0 -38
  136. data/test/protocol/05/tc_impl.rb +0 -61
  137. data/test/protocol/05/tc_packet_assistant.rb +0 -32
  138. data/test/protocol/tc_driver.rb +0 -219
@@ -1,40 +0,0 @@
1
- #--
2
- # =============================================================================
3
- # Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
4
- # All rights reserved.
5
- #
6
- # This source file is distributed as part of the Net::SFTP Secure FTP Client
7
- # library for Ruby. This file (and the library as a whole) may be used only as
8
- # allowed by either the BSD license, or the Ruby license (or, by association
9
- # with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
10
- # distribution for the texts of these licenses.
11
- # -----------------------------------------------------------------------------
12
- # net-sftp website: http://net-ssh.rubyforge.org/sftp
13
- # project website : http://rubyforge.org/projects/net-ssh
14
- # =============================================================================
15
- #++
16
-
17
- $:.unshift "../../lib"
18
-
19
- require 'test/unit'
20
- require 'net/sftp/operations/fstat'
21
- require 'flexmock'
22
-
23
- class TC_Operations_Fstat < Test::Unit::TestCase
24
-
25
- def setup
26
- @log = FlexMock.new
27
- @session = FlexMock.new
28
- @driver = FlexMock.new
29
- @operation = Net::SFTP::Operations::Fstat.new( @log, @session, @driver )
30
- end
31
-
32
- def test_perform
33
- id = handle = nil
34
- @driver.mock_handle( :fstat ) { |i,h| id, handle = i, h; 10 }
35
- assert_equal 10, @operation.perform( "foo" )
36
- assert_nil id
37
- assert_equal "foo", handle
38
- end
39
-
40
- end
@@ -1,40 +0,0 @@
1
- #--
2
- # =============================================================================
3
- # Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
4
- # All rights reserved.
5
- #
6
- # This source file is distributed as part of the Net::SFTP Secure FTP Client
7
- # library for Ruby. This file (and the library as a whole) may be used only as
8
- # allowed by either the BSD license, or the Ruby license (or, by association
9
- # with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
10
- # distribution for the texts of these licenses.
11
- # -----------------------------------------------------------------------------
12
- # net-sftp website: http://net-ssh.rubyforge.org/sftp
13
- # project website : http://rubyforge.org/projects/net-ssh
14
- # =============================================================================
15
- #++
16
-
17
- $:.unshift "../../lib"
18
-
19
- require 'test/unit'
20
- require 'net/sftp/operations/lstat'
21
- require 'flexmock'
22
-
23
- class TC_Operations_Lstat < Test::Unit::TestCase
24
-
25
- def setup
26
- @log = FlexMock.new
27
- @session = FlexMock.new
28
- @driver = FlexMock.new
29
- @operation = Net::SFTP::Operations::Lstat.new( @log, @session, @driver )
30
- end
31
-
32
- def test_perform
33
- id = path = nil
34
- @driver.mock_handle( :lstat ) { |i,p| id, path = i, p; 10 }
35
- assert_equal 10, @operation.perform( "foo" )
36
- assert_nil id
37
- assert_equal "foo", path
38
- end
39
-
40
- end
@@ -1,48 +0,0 @@
1
- #--
2
- # =============================================================================
3
- # Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
4
- # All rights reserved.
5
- #
6
- # This source file is distributed as part of the Net::SFTP Secure FTP Client
7
- # library for Ruby. This file (and the library as a whole) may be used only as
8
- # allowed by either the BSD license, or the Ruby license (or, by association
9
- # with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
10
- # distribution for the texts of these licenses.
11
- # -----------------------------------------------------------------------------
12
- # net-sftp website: http://net-ssh.rubyforge.org/sftp
13
- # project website : http://rubyforge.org/projects/net-ssh
14
- # =============================================================================
15
- #++
16
-
17
- $:.unshift "../../lib"
18
-
19
- require 'test/unit'
20
- require 'net/sftp/operations/mkdir'
21
- require 'flexmock'
22
-
23
- class TC_Operations_Mkdir < Test::Unit::TestCase
24
-
25
- def setup
26
- @log = FlexMock.new
27
- @session = FlexMock.new
28
- @attr_factory = FlexMock.new
29
- @driver = FlexMock.new
30
- @driver.mock_handle( :attr_factory ) { @attr_factory }
31
- @operation = Net::SFTP::Operations::Mkdir.new( @log, @session, @driver )
32
- end
33
-
34
- def test_perform
35
- hash = nil
36
- @attr_factory.mock_handle( :from_hash ) { |h| hash = h; :foo }
37
-
38
- id = handle = attrs = nil
39
- @driver.mock_handle( :mkdir ) { |i,h,a| id, handle, attrs = i, h, a; 10 }
40
-
41
- assert_equal 10, @operation.perform( "foo", "bar" )
42
- assert_nil id
43
- assert_equal "foo", handle
44
- assert_equal "bar", hash
45
- assert_equal :foo, attrs
46
- end
47
-
48
- end
@@ -1,42 +0,0 @@
1
- #--
2
- # =============================================================================
3
- # Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
4
- # All rights reserved.
5
- #
6
- # This source file is distributed as part of the Net::SFTP Secure FTP Client
7
- # library for Ruby. This file (and the library as a whole) may be used only as
8
- # allowed by either the BSD license, or the Ruby license (or, by association
9
- # with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
10
- # distribution for the texts of these licenses.
11
- # -----------------------------------------------------------------------------
12
- # net-sftp website: http://net-ssh.rubyforge.org/sftp
13
- # project website : http://rubyforge.org/projects/net-ssh
14
- # =============================================================================
15
- #++
16
-
17
- $:.unshift "../../lib"
18
-
19
- require 'test/unit'
20
- require 'net/sftp/operations/open'
21
- require 'flexmock'
22
-
23
- class TC_Operations_Open < Test::Unit::TestCase
24
-
25
- def setup
26
- @log = FlexMock.new
27
- @session = FlexMock.new
28
- @driver = FlexMock.new
29
- @operation = Net::SFTP::Operations::Open.new( @log, @session, @driver )
30
- end
31
-
32
- def test_perform
33
- id = handle = flags = mode = nil
34
- @driver.mock_handle( :open ) { |i,h,f,m| id, handle, flags, mode = i, h, f, m; 10 }
35
- assert_equal 10, @operation.perform( "foo" )
36
- assert_nil id
37
- assert_equal "foo", handle
38
- assert_equal IO::RDONLY, flags
39
- assert_equal 0660, mode
40
- end
41
-
42
- end
@@ -1,40 +0,0 @@
1
- #--
2
- # =============================================================================
3
- # Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
4
- # All rights reserved.
5
- #
6
- # This source file is distributed as part of the Net::SFTP Secure FTP Client
7
- # library for Ruby. This file (and the library as a whole) may be used only as
8
- # allowed by either the BSD license, or the Ruby license (or, by association
9
- # with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
10
- # distribution for the texts of these licenses.
11
- # -----------------------------------------------------------------------------
12
- # net-sftp website: http://net-ssh.rubyforge.org/sftp
13
- # project website : http://rubyforge.org/projects/net-ssh
14
- # =============================================================================
15
- #++
16
-
17
- $:.unshift "../../lib"
18
-
19
- require 'test/unit'
20
- require 'net/sftp/operations/opendir'
21
- require 'flexmock'
22
-
23
- class TC_Operations_Opendir < Test::Unit::TestCase
24
-
25
- def setup
26
- @log = FlexMock.new
27
- @session = FlexMock.new
28
- @driver = FlexMock.new
29
- @operation = Net::SFTP::Operations::Opendir.new( @log, @session, @driver )
30
- end
31
-
32
- def test_perform
33
- id = path = nil
34
- @driver.mock_handle( :opendir ) { |i,p| id, path = i, p; 10 }
35
- assert_equal 10, @operation.perform( "foo" )
36
- assert_nil id
37
- assert_equal "foo", path
38
- end
39
-
40
- end
@@ -1,103 +0,0 @@
1
- #--
2
- # =============================================================================
3
- # Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
4
- # All rights reserved.
5
- #
6
- # This source file is distributed as part of the Net::SFTP Secure FTP Client
7
- # library for Ruby. This file (and the library as a whole) may be used only as
8
- # allowed by either the BSD license, or the Ruby license (or, by association
9
- # with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
10
- # distribution for the texts of these licenses.
11
- # -----------------------------------------------------------------------------
12
- # net-sftp website: http://net-ssh.rubyforge.org/sftp
13
- # project website : http://rubyforge.org/projects/net-ssh
14
- # =============================================================================
15
- #++
16
-
17
- $:.unshift "../../lib"
18
-
19
- require 'test/unit'
20
- require 'net/sftp/operations/read'
21
- require 'flexmock'
22
-
23
- class TC_Operations_Read < Test::Unit::TestCase
24
-
25
- def setup
26
- @log = FlexMock.new
27
- @log.mock_handle( :debug? )
28
- @log.mock_handle( :debug )
29
-
30
- @session = FlexMock.new
31
- @driver = FlexMock.new
32
- @operation = Net::SFTP::Operations::Read.new( @log, @session, @driver )
33
- end
34
-
35
- def test_perform_defaults
36
- id = handle = offset = length = nil
37
- @driver.mock_handle( :read ) { |i,h,o,l| id, handle, offset, length = i, h, o, l; 10 }
38
- assert_equal 10, @operation.perform( "foo" )
39
- assert_nil id
40
- assert_equal "foo", handle
41
- assert_equal 0, offset
42
- assert_equal 64 * 1024, length
43
- end
44
-
45
- def test_perform_explicit
46
- id = handle = offset = length = nil
47
- @driver.mock_handle( :read ) { |i,h,o,l| id, handle, offset, length = i, h, o, l; 10 }
48
- assert_equal 10, @operation.perform( "foo", :offset=>15, :length=>72 )
49
- assert_nil id
50
- assert_equal "foo", handle
51
- assert_equal 15, offset
52
- assert_equal 72, length
53
- end
54
-
55
- def test_do_data_full
56
- id = handle = offset = length = nil
57
- @driver.mock_handle( :read ) { |i,h,o,l| id, handle, offset, length = i, h, o, l; 10 }
58
- @session.mock_handle( :register )
59
- @operation.perform( "foo" )
60
- @operation.do_data( "harbinger of doom" )
61
- assert_equal 2, @driver.mock_count( :read )
62
- assert_equal 1, @session.mock_count( :register )
63
- assert_equal "foo", handle
64
- assert_equal 17, offset
65
- assert_equal 64 * 1024, length
66
- end
67
-
68
- def test_do_data_partial
69
- id = handle = offset = length = nil
70
- @driver.mock_handle( :read ) { |i,h,o,l| id, handle, offset, length = i, h, o, l; 10 }
71
- @session.mock_handle( :register )
72
- @session.mock_handle( :loop )
73
- @session.mock_handle( :status= )
74
- called = false
75
- @operation.execute( "foo", :offset=>15, :length=>20 ) { called = true }
76
- @operation.do_data( "harbinger of doom" )
77
- @operation.do_data( "abc" )
78
- assert_equal 2, @driver.mock_count( :read )
79
- assert_equal 2, @session.mock_count( :register )
80
- assert_equal "foo", handle
81
- assert_equal 32, offset
82
- assert_equal 3, length
83
- assert called
84
- end
85
-
86
- def test_do_status_eof
87
- @driver.mock_handle( :read )
88
- @session.mock_handle( :register )
89
- @session.mock_handle( :loop )
90
- @session.mock_handle( :status= )
91
- called = false
92
- @operation.execute( "foo", :offset=>15, :length=>20 ) { called = true }
93
- assert_nothing_raised { @operation.do_status( 1, nil, nil ) }
94
- assert called
95
- end
96
-
97
- def test_do_status_bad
98
- assert_raise( Net::SFTP::Operations::StatusException ) do
99
- @operation.do_status( 2, nil, nil )
100
- end
101
- end
102
-
103
- end
@@ -1,88 +0,0 @@
1
- #--
2
- # =============================================================================
3
- # Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
4
- # All rights reserved.
5
- #
6
- # This source file is distributed as part of the Net::SFTP Secure FTP Client
7
- # library for Ruby. This file (and the library as a whole) may be used only as
8
- # allowed by either the BSD license, or the Ruby license (or, by association
9
- # with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
10
- # distribution for the texts of these licenses.
11
- # -----------------------------------------------------------------------------
12
- # net-sftp website: http://net-ssh.rubyforge.org/sftp
13
- # project website : http://rubyforge.org/projects/net-ssh
14
- # =============================================================================
15
- #++
16
-
17
- $:.unshift "../../lib"
18
-
19
- require 'test/unit'
20
- require 'net/sftp/operations/readdir'
21
- require 'flexmock'
22
-
23
- class TC_Operations_Readdir < Test::Unit::TestCase
24
-
25
- def setup
26
- @log = FlexMock.new
27
- @session = FlexMock.new
28
- @driver = FlexMock.new
29
- @operation = Net::SFTP::Operations::Readdir.new( @log, @session, @driver )
30
- end
31
-
32
- def test_perform
33
- id = handle = nil
34
- @driver.mock_handle( :readdir ) { |i,h| id, handle = i, h; 10 }
35
- assert_equal 10, @operation.perform( "foo" )
36
- assert_nil id
37
- assert_equal "foo", handle
38
- end
39
-
40
- def test_do_name
41
- id = handle = nil
42
- @log.mock_handle( :debug? )
43
- @log.mock_handle( :debug )
44
- @driver.mock_handle( :readdir ) { |i,h| id, handle = i, h; 10 }
45
- @session.mock_handle( :register )
46
- @operation.perform( "foo" )
47
- @operation.do_name( [ :a, :b ] )
48
- assert_equal 1, @session.mock_count( :register )
49
- assert_equal "foo", handle
50
- end
51
-
52
- def test_do_status_ok
53
- called = false
54
-
55
- @log.mock_handle( :debug? )
56
- @log.mock_handle( :debug )
57
- @driver.mock_handle( :readdir )
58
- @session.mock_handle( :register )
59
- @session.mock_handle( :status= )
60
- @session.mock_handle( :loop )
61
-
62
- @operation.execute( "foo" ) { called = true }
63
- assert_nothing_raised { @operation.do_status( 0, :a, :b ) }
64
- assert called
65
- end
66
-
67
- def test_do_status_eof
68
- called = false
69
-
70
- @log.mock_handle( :debug? )
71
- @log.mock_handle( :debug )
72
- @driver.mock_handle( :readdir )
73
- @session.mock_handle( :register )
74
- @session.mock_handle( :status= )
75
- @session.mock_handle( :loop )
76
-
77
- @operation.execute( "foo" ) { called = true }
78
- assert_nothing_raised { @operation.do_status( 1, :a, :b ) }
79
- assert called
80
- end
81
-
82
- def test_do_status_bad
83
- assert_raise( Net::SFTP::Operations::StatusException ) do
84
- @operation.do_status( 2, :a, :b )
85
- end
86
- end
87
-
88
- end
@@ -1,54 +0,0 @@
1
- #--
2
- # =============================================================================
3
- # Copyright (c) 2004, Jamis Buck (jamis@37signals.com)
4
- # All rights reserved.
5
- #
6
- # This source file is distributed as part of the Net::SFTP Secure FTP Client
7
- # library for Ruby. This file (and the library as a whole) may be used only as
8
- # allowed by either the BSD license, or the Ruby license (or, by association
9
- # with the Ruby license, the GPL). See the "doc" subdirectory of the Net::SFTP
10
- # distribution for the texts of these licenses.
11
- # -----------------------------------------------------------------------------
12
- # net-sftp website: http://net-ssh.rubyforge.org/sftp
13
- # project website : http://rubyforge.org/projects/net-ssh
14
- # =============================================================================
15
- #++
16
-
17
- $:.unshift "../../lib"
18
-
19
- require 'test/unit'
20
- require 'net/sftp/operations/realpath'
21
- require 'flexmock'
22
-
23
- class TC_Operations_Realpath < Test::Unit::TestCase
24
-
25
- def setup
26
- @log = FlexMock.new
27
- @session = FlexMock.new
28
- @driver = FlexMock.new
29
- @operation = Net::SFTP::Operations::Realpath.new( @log, @session, @driver )
30
- end
31
-
32
- def test_perform
33
- id = path = nil
34
- @driver.mock_handle( :realpath ) { |i,p| id, path = i, p; 10 }
35
- assert_equal 10, @operation.perform( "foo" )
36
- assert_nil id
37
- assert_equal "foo", path
38
- end
39
-
40
- def test_do_name
41
- @session.mock_handle( :loop )
42
- @session.mock_handle( :status= )
43
- @session.mock_handle( :register )
44
- @driver.mock_handle( :realpath )
45
- @log.mock_handle( :debug? )
46
- @log.mock_handle( :debug )
47
-
48
- called = false
49
- @operation.execute( "foo" ) { |s,v| called = v }
50
- @operation.do_name( [ :a, :b ] )
51
- assert_equal :a, called
52
- end
53
-
54
- end