redcar 0.3.7.1 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. data/CHANGES +16 -0
  2. data/README.md +5 -0
  3. data/ROADMAP.md +7 -9
  4. data/Rakefile +55 -22
  5. data/lib/redcar.rb +12 -6
  6. data/lib/redcar/installer.rb +119 -44
  7. data/plugins/application/features/step_definitions/speedbar_steps.rb +62 -0
  8. data/plugins/application/features/step_definitions/tree_steps.rb +3 -3
  9. data/plugins/application/features/support/env.rb +2 -1
  10. data/plugins/application/lib/application/notebook.rb +53 -7
  11. data/plugins/application/lib/application/speedbar.rb +12 -0
  12. data/plugins/application/lib/application/tab.rb +16 -5
  13. data/plugins/application/lib/application/treebook.rb +21 -1
  14. data/plugins/application_swt/lib/application_swt.rb +12 -2
  15. data/plugins/application_swt/lib/application_swt/html_tab.rb +4 -0
  16. data/plugins/application_swt/lib/application_swt/notebook.rb +5 -3
  17. data/plugins/application_swt/lib/application_swt/speedbar.rb +15 -27
  18. data/plugins/application_swt/lib/application_swt/swt_wrapper.rb +1 -0
  19. data/plugins/application_swt/lib/application_swt/tab.rb +1 -0
  20. data/plugins/application_swt/lib/application_swt/treebook.rb +36 -8
  21. data/plugins/application_swt/lib/application_swt/window.rb +24 -18
  22. data/plugins/auto_completer/lib/auto_completer.rb +5 -20
  23. data/plugins/core/lib/core.rb +7 -4
  24. data/plugins/core/lib/core/observable_struct.rb +2 -2
  25. data/plugins/declarations/lib/declarations.rb +3 -17
  26. data/plugins/document_search/features/search.feature +163 -0
  27. data/plugins/document_search/features/support/env.rb +4 -0
  28. data/plugins/document_search/lib/document_search.rb +121 -0
  29. data/plugins/document_search/plugin.rb +8 -0
  30. data/plugins/edit_view/features/line_delimiter.feature +7 -0
  31. data/plugins/edit_view/features/step_definitions/editing_steps.rb +49 -1
  32. data/plugins/edit_view/features/step_definitions/tab_steps.rb +10 -11
  33. data/plugins/edit_view/features/switch_tabs.feature +61 -10
  34. data/plugins/edit_view/lib/edit_view.rb +4 -0
  35. data/plugins/edit_view/lib/edit_view/document.rb +56 -0
  36. data/plugins/edit_view/lib/edit_view/document/command.rb +1 -1
  37. data/plugins/edit_view/lib/edit_view/edit_tab.rb +0 -8
  38. data/plugins/edit_view_swt/lib/edit_view_swt.rb +4 -0
  39. data/plugins/html_view/lib/html_controller.rb +19 -1
  40. data/plugins/html_view/lib/html_view.rb +28 -1
  41. data/plugins/html_view/lib/html_view/html_tab.rb +10 -1
  42. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +3 -1
  43. data/plugins/project/features/open_directory_tree.feature +3 -3
  44. data/plugins/project/lib/project.rb +4 -6
  45. data/plugins/project/lib/project/commands.rb +17 -0
  46. data/plugins/project/lib/project/dir_controller.rb +2 -1
  47. data/plugins/project/lib/project/dir_mirror.rb +8 -0
  48. data/plugins/project/lib/project/manager.rb +2 -0
  49. data/plugins/project/plugin.rb +2 -1
  50. data/plugins/project/vendor/net-sftp/Manifest +55 -0
  51. data/plugins/project/vendor/net-sftp/Rakefile +30 -0
  52. data/plugins/project/vendor/net-sftp/lib/net/sftp.rb +70 -0
  53. data/plugins/project/vendor/net-sftp/lib/net/sftp/constants.rb +187 -0
  54. data/plugins/project/vendor/net-sftp/lib/net/sftp/errors.rb +39 -0
  55. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/dir.rb +93 -0
  56. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/download.rb +364 -0
  57. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/file.rb +176 -0
  58. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/file_factory.rb +60 -0
  59. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/upload.rb +387 -0
  60. data/plugins/project/vendor/net-sftp/lib/net/sftp/packet.rb +21 -0
  61. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol.rb +32 -0
  62. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/01/attributes.rb +315 -0
  63. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/01/base.rb +268 -0
  64. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/01/name.rb +43 -0
  65. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/02/base.rb +31 -0
  66. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/03/base.rb +35 -0
  67. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/04/attributes.rb +152 -0
  68. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/04/base.rb +94 -0
  69. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/04/name.rb +67 -0
  70. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/05/base.rb +66 -0
  71. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/06/attributes.rb +107 -0
  72. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/06/base.rb +63 -0
  73. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/base.rb +50 -0
  74. data/plugins/project/vendor/net-sftp/lib/net/sftp/request.rb +91 -0
  75. data/plugins/project/vendor/net-sftp/lib/net/sftp/response.rb +76 -0
  76. data/plugins/project/vendor/net-sftp/lib/net/sftp/session.rb +951 -0
  77. data/plugins/project/vendor/net-sftp/lib/net/sftp/version.rb +18 -0
  78. data/plugins/project/vendor/net-sftp/setup.rb +1331 -0
  79. data/plugins/project/vendor/net-sftp/test/common.rb +171 -0
  80. data/plugins/project/vendor/net-sftp/test/protocol/01/test_attributes.rb +97 -0
  81. data/plugins/project/vendor/net-sftp/test/protocol/01/test_base.rb +210 -0
  82. data/plugins/project/vendor/net-sftp/test/protocol/01/test_name.rb +27 -0
  83. data/plugins/project/vendor/net-sftp/test/protocol/02/test_base.rb +26 -0
  84. data/plugins/project/vendor/net-sftp/test/protocol/03/test_base.rb +27 -0
  85. data/plugins/project/vendor/net-sftp/test/protocol/04/test_attributes.rb +148 -0
  86. data/plugins/project/vendor/net-sftp/test/protocol/04/test_base.rb +74 -0
  87. data/plugins/project/vendor/net-sftp/test/protocol/04/test_name.rb +53 -0
  88. data/plugins/project/vendor/net-sftp/test/protocol/05/test_base.rb +62 -0
  89. data/plugins/project/vendor/net-sftp/test/protocol/06/test_attributes.rb +124 -0
  90. data/plugins/project/vendor/net-sftp/test/protocol/06/test_base.rb +51 -0
  91. data/plugins/project/vendor/net-sftp/test/protocol/test_base.rb +42 -0
  92. data/plugins/project/vendor/net-sftp/test/test_all.rb +7 -0
  93. data/plugins/project/vendor/net-sftp/test/test_dir.rb +47 -0
  94. data/plugins/project/vendor/net-sftp/test/test_download.rb +252 -0
  95. data/plugins/project/vendor/net-sftp/test/test_file.rb +159 -0
  96. data/plugins/project/vendor/net-sftp/test/test_file_factory.rb +48 -0
  97. data/plugins/project/vendor/net-sftp/test/test_packet.rb +9 -0
  98. data/plugins/project/vendor/net-sftp/test/test_protocol.rb +17 -0
  99. data/plugins/project/vendor/net-sftp/test/test_request.rb +71 -0
  100. data/plugins/project/vendor/net-sftp/test/test_response.rb +53 -0
  101. data/plugins/project/vendor/net-sftp/test/test_session.rb +741 -0
  102. data/plugins/project/vendor/net-sftp/test/test_upload.rb +219 -0
  103. data/plugins/project/vendor/net-ssh/Manifest +110 -0
  104. data/plugins/project/vendor/net-ssh/Rakefile +85 -0
  105. data/plugins/project/vendor/net-ssh/Rudyfile +96 -0
  106. data/plugins/project/vendor/net-ssh/lib/net/ssh.rb +215 -0
  107. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/agent.rb +179 -0
  108. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/constants.rb +18 -0
  109. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/key_manager.rb +193 -0
  110. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/abstract.rb +60 -0
  111. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/hostbased.rb +71 -0
  112. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/keyboard_interactive.rb +66 -0
  113. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/password.rb +39 -0
  114. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/publickey.rb +92 -0
  115. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/pageant.rb +183 -0
  116. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/session.rb +134 -0
  117. data/plugins/project/vendor/net-ssh/lib/net/ssh/buffer.rb +340 -0
  118. data/plugins/project/vendor/net-ssh/lib/net/ssh/buffered_io.rb +198 -0
  119. data/plugins/project/vendor/net-ssh/lib/net/ssh/config.rb +202 -0
  120. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/channel.rb +630 -0
  121. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/constants.rb +33 -0
  122. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/session.rb +597 -0
  123. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/term.rb +178 -0
  124. data/plugins/project/vendor/net-ssh/lib/net/ssh/errors.rb +85 -0
  125. data/plugins/project/vendor/net-ssh/lib/net/ssh/key_factory.rb +102 -0
  126. data/plugins/project/vendor/net-ssh/lib/net/ssh/known_hosts.rb +129 -0
  127. data/plugins/project/vendor/net-ssh/lib/net/ssh/loggable.rb +61 -0
  128. data/plugins/project/vendor/net-ssh/lib/net/ssh/packet.rb +102 -0
  129. data/plugins/project/vendor/net-ssh/lib/net/ssh/prompt.rb +93 -0
  130. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/command.rb +75 -0
  131. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/errors.rb +14 -0
  132. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/http.rb +94 -0
  133. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/socks4.rb +70 -0
  134. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/socks5.rb +142 -0
  135. data/plugins/project/vendor/net-ssh/lib/net/ssh/ruby_compat.rb +43 -0
  136. data/plugins/project/vendor/net-ssh/lib/net/ssh/service/forward.rb +288 -0
  137. data/plugins/project/vendor/net-ssh/lib/net/ssh/test.rb +89 -0
  138. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/channel.rb +129 -0
  139. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/extensions.rb +152 -0
  140. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/kex.rb +44 -0
  141. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/local_packet.rb +51 -0
  142. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/packet.rb +81 -0
  143. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/remote_packet.rb +38 -0
  144. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/script.rb +157 -0
  145. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/socket.rb +64 -0
  146. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/algorithms.rb +384 -0
  147. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/cipher_factory.rb +97 -0
  148. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/constants.rb +30 -0
  149. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac.rb +31 -0
  150. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/abstract.rb +79 -0
  151. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/md5.rb +12 -0
  152. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/md5_96.rb +11 -0
  153. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/none.rb +15 -0
  154. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/sha1.rb +13 -0
  155. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/sha1_96.rb +11 -0
  156. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/identity_cipher.rb +55 -0
  157. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/kex.rb +13 -0
  158. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +208 -0
  159. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +77 -0
  160. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/openssl.rb +128 -0
  161. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/packet_stream.rb +235 -0
  162. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/server_version.rb +71 -0
  163. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/session.rb +276 -0
  164. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/state.rb +206 -0
  165. data/plugins/project/vendor/net-ssh/lib/net/ssh/verifiers/lenient.rb +30 -0
  166. data/plugins/project/vendor/net-ssh/lib/net/ssh/verifiers/null.rb +12 -0
  167. data/plugins/project/vendor/net-ssh/lib/net/ssh/verifiers/strict.rb +53 -0
  168. data/plugins/project/vendor/net-ssh/lib/net/ssh/version.rb +62 -0
  169. data/plugins/project/vendor/net-ssh/net-ssh.gemspec +138 -0
  170. data/plugins/project/vendor/net-ssh/setup.rb +1585 -0
  171. data/plugins/project/vendor/net-ssh/support/arcfour_check.rb +20 -0
  172. data/plugins/project/vendor/net-ssh/support/ssh_tunnel_bug.rb +65 -0
  173. data/plugins/project/vendor/net-ssh/test/README.txt +42 -0
  174. data/plugins/project/vendor/net-ssh/test/authentication/methods/common.rb +28 -0
  175. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_abstract.rb +51 -0
  176. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_hostbased.rb +114 -0
  177. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_keyboard_interactive.rb +98 -0
  178. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_password.rb +50 -0
  179. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_publickey.rb +127 -0
  180. data/plugins/project/vendor/net-ssh/test/authentication/test_agent.rb +205 -0
  181. data/plugins/project/vendor/net-ssh/test/authentication/test_key_manager.rb +105 -0
  182. data/plugins/project/vendor/net-ssh/test/authentication/test_session.rb +93 -0
  183. data/plugins/project/vendor/net-ssh/test/common.rb +107 -0
  184. data/plugins/project/vendor/net-ssh/test/configs/eqsign +3 -0
  185. data/plugins/project/vendor/net-ssh/test/configs/exact_match +8 -0
  186. data/plugins/project/vendor/net-ssh/test/configs/host_plus +10 -0
  187. data/plugins/project/vendor/net-ssh/test/configs/multihost +4 -0
  188. data/plugins/project/vendor/net-ssh/test/configs/nohost +19 -0
  189. data/plugins/project/vendor/net-ssh/test/configs/numeric_host +4 -0
  190. data/plugins/project/vendor/net-ssh/test/configs/wild_cards +14 -0
  191. data/plugins/project/vendor/net-ssh/test/connection/test_channel.rb +467 -0
  192. data/plugins/project/vendor/net-ssh/test/connection/test_session.rb +488 -0
  193. data/plugins/project/vendor/net-ssh/test/manual/test_forward.rb +185 -0
  194. data/plugins/project/vendor/net-ssh/test/test_all.rb +9 -0
  195. data/plugins/project/vendor/net-ssh/test/test_buffer.rb +336 -0
  196. data/plugins/project/vendor/net-ssh/test/test_buffered_io.rb +63 -0
  197. data/plugins/project/vendor/net-ssh/test/test_config.rb +117 -0
  198. data/plugins/project/vendor/net-ssh/test/test_key_factory.rb +67 -0
  199. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_md5.rb +39 -0
  200. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_md5_96.rb +25 -0
  201. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_none.rb +34 -0
  202. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_sha1.rb +34 -0
  203. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_sha1_96.rb +25 -0
  204. data/plugins/project/vendor/net-ssh/test/transport/kex/test_diffie_hellman_group1_sha1.rb +146 -0
  205. data/plugins/project/vendor/net-ssh/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +92 -0
  206. data/plugins/project/vendor/net-ssh/test/transport/test_algorithms.rb +302 -0
  207. data/plugins/project/vendor/net-ssh/test/transport/test_cipher_factory.rb +213 -0
  208. data/plugins/project/vendor/net-ssh/test/transport/test_hmac.rb +34 -0
  209. data/plugins/project/vendor/net-ssh/test/transport/test_identity_cipher.rb +40 -0
  210. data/plugins/project/vendor/net-ssh/test/transport/test_packet_stream.rb +441 -0
  211. data/plugins/project/vendor/net-ssh/test/transport/test_server_version.rb +78 -0
  212. data/plugins/project/vendor/net-ssh/test/transport/test_session.rb +315 -0
  213. data/plugins/project/vendor/net-ssh/test/transport/test_state.rb +173 -0
  214. data/plugins/redcar/plugin.rb +3 -1
  215. data/plugins/redcar/redcar.rb +108 -121
  216. data/plugins/redcar_debug/lib/redcar_debug.rb +2 -0
  217. data/plugins/runnables/lib/runnables.rb +80 -23
  218. data/plugins/runnables/lib/runnables/command_output_controller.rb +102 -0
  219. data/plugins/runnables/lib/runnables/running_process_checker.rb +34 -0
  220. data/plugins/runnables/{plugin_no_load.rb → plugin.rb} +2 -1
  221. data/plugins/runnables/vendor/session-2.4.0/HISTORY +73 -0
  222. data/plugins/runnables/vendor/session-2.4.0/README +89 -0
  223. data/plugins/runnables/vendor/session-2.4.0/TODO +3 -0
  224. data/plugins/runnables/vendor/session-2.4.0/VERSION +1 -0
  225. data/plugins/runnables/vendor/session-2.4.0/gemspec.rb +22 -0
  226. data/plugins/runnables/vendor/session-2.4.0/install.rb +143 -0
  227. data/plugins/runnables/vendor/session-2.4.0/lib/session.rb +757 -0
  228. data/plugins/runnables/vendor/session-2.4.0/sample/bash.rb +60 -0
  229. data/plugins/runnables/vendor/session-2.4.0/sample/driver.rb +47 -0
  230. data/plugins/runnables/vendor/session-2.4.0/sample/session_idl.rb +25 -0
  231. data/plugins/runnables/vendor/session-2.4.0/sample/session_sh.rb +29 -0
  232. data/plugins/runnables/vendor/session-2.4.0/sample/sh0.rb +23 -0
  233. data/plugins/runnables/vendor/session-2.4.0/sample/stdin.rb +17 -0
  234. data/plugins/runnables/vendor/session-2.4.0/sample/threadtest.rb +42 -0
  235. data/plugins/runnables/vendor/session-2.4.0/session-2.4.0.gem +0 -0
  236. data/plugins/runnables/vendor/session-2.4.0/test/session.rb +227 -0
  237. data/plugins/runnables/views/command_output.html.erb +32 -0
  238. data/plugins/task_manager/lib/task_manager.rb +2 -0
  239. data/plugins/textmate/lib/textmate/plist.rb +1 -1
  240. data/plugins/textmate/lib/textmate/snippet.rb +1 -0
  241. data/plugins/tree/lib/tree/mirror.rb +8 -1
  242. data/plugins/tree_view_swt/lib/tree_view_swt.rb +29 -2
  243. metadata +191 -6
  244. data/plugins/declarations/TODO +0 -3
  245. data/plugins/redcar/spec/redcar/redcar_spec.rb +0 -70
  246. data/plugins/redcar/spec/spec_helper.rb +0 -4
@@ -0,0 +1,63 @@
1
+ require 'common'
2
+ require 'net/ssh/buffered_io'
3
+
4
+ class TestBufferedIo < Test::Unit::TestCase
5
+ def test_fill_should_pull_from_underlying_io
6
+ io.expects(:recv).with(8192).returns("here is some data")
7
+ assert_equal 17, io.fill
8
+ assert_equal 17, io.available
9
+ assert_equal "here is some data", io.read_available(20)
10
+ end
11
+
12
+ def test_enqueue_should_not_write_to_underlying_io
13
+ assert !io.pending_write?
14
+ io.expects(:send).never
15
+ io.enqueue("here is some data")
16
+ assert io.pending_write?
17
+ end
18
+
19
+ def test_send_pending_should_not_fail_when_no_writes_are_pending
20
+ assert !io.pending_write?
21
+ io.expects(:send).never
22
+ assert_nothing_raised { io.send_pending }
23
+ end
24
+
25
+ def test_send_pending_with_pending_writes_should_write_to_underlying_io
26
+ io.enqueue("here is some data")
27
+ io.expects(:send).with("here is some data", 0).returns(17)
28
+ assert io.pending_write?
29
+ assert_nothing_raised { io.send_pending }
30
+ assert !io.pending_write?
31
+ end
32
+
33
+ def test_wait_for_pending_sends_should_write_only_once_if_all_can_be_written_at_once
34
+ io.enqueue("here is some data")
35
+ io.expects(:send).with("here is some data", 0).returns(17)
36
+ assert io.pending_write?
37
+ assert_nothing_raised { io.wait_for_pending_sends }
38
+ assert !io.pending_write?
39
+ end
40
+
41
+ def test_wait_for_pending_sends_should_write_multiple_times_if_first_write_was_partial
42
+ io.enqueue("here is some data")
43
+
44
+ io.expects(:send).with("here is some data", 0).returns(10)
45
+ io.expects(:send).with("me data", 0).returns(4)
46
+ io.expects(:send).with("ata", 0).returns(3)
47
+
48
+ IO.expects(:select).times(2).with(nil, [io]).returns([[], [io]])
49
+
50
+ assert_nothing_raised { io.wait_for_pending_sends }
51
+ assert !io.pending_write?
52
+ end
53
+
54
+ private
55
+
56
+ def io
57
+ @io ||= begin
58
+ io = mock("io")
59
+ io.extend(Net::SSH::BufferedIo)
60
+ io
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,117 @@
1
+ require 'common'
2
+ require 'net/ssh/config'
3
+
4
+ class TestConfig < Test::Unit::TestCase
5
+ def test_load_for_non_existant_file_should_return_empty_hash
6
+ File.expects(:readable?).with("/bogus/file").returns(false)
7
+ assert_equal({}, Net::SSH::Config.load("/bogus/file", "host.name"))
8
+ end
9
+
10
+ def test_load_should_expand_path
11
+ expected = File.expand_path("~/.ssh/config")
12
+ File.expects(:readable?).with(expected).returns(false)
13
+ Net::SSH::Config.load("~/.ssh/config", "host.name")
14
+ end
15
+
16
+ def test_load_with_exact_host_match_should_load_that_section
17
+ config = Net::SSH::Config.load(config(:exact_match), "test.host")
18
+ assert config['compression']
19
+ assert config['forwardagent']
20
+ assert_equal 1234, config['port']
21
+ end
22
+
23
+ def test_load_with_wild_card_matches_should_load_all_matches_with_first_match_taking_precedence
24
+ config = Net::SSH::Config.load(config(:wild_cards), "test.host")
25
+ assert_equal 1234, config['port']
26
+ assert !config['compression']
27
+ assert config['forwardagent']
28
+ assert_equal %w(~/.ssh/id_dsa), config['identityfile']
29
+ assert !config.key?('rekeylimit')
30
+ end
31
+
32
+ def test_for_should_load_all_files_and_translate_to_net_ssh_options
33
+ config = Net::SSH::Config.for("test.host", [config(:exact_match), config(:wild_cards)])
34
+ assert_equal 1234, config[:port]
35
+ assert config[:compression]
36
+ assert config[:forward_agent]
37
+ assert_equal %w(~/.ssh/id_dsa), config[:keys]
38
+ assert !config.key?(:rekey_limit)
39
+ end
40
+
41
+ def test_load_with_no_host
42
+ config = Net::SSH::Config.load(config(:nohost), "test.host")
43
+ assert_equal %w(~/.ssh/id_dsa ~/.ssh/id_rsa), config['identityfile']
44
+ assert_equal 1985, config['port']
45
+ end
46
+
47
+ def test_load_with_multiple_hosts
48
+ config = Net::SSH::Config.load(config(:multihost), "test.host")
49
+ assert config['compression']
50
+ assert_equal '2G', config['rekeylimit']
51
+ assert_equal 1980, config['port']
52
+ end
53
+
54
+ def test_load_with_multiple_hosts_and_config_should_match_for_both
55
+ aconfig = Net::SSH::Config.load(config(:multihost), "test.host")
56
+ bconfig = Net::SSH::Config.load(config(:multihost), "other.host")
57
+ assert_equal aconfig['port'], bconfig['port']
58
+ assert_equal aconfig['compression'], bconfig['compression']
59
+ assert_equal aconfig['rekeylimit'], bconfig['rekeylimit']
60
+ end
61
+
62
+ def test_load_should_parse_equal_sign_delimiters
63
+ config = Net::SSH::Config.load(config(:eqsign), "test.test")
64
+ assert config['compression']
65
+ assert_equal 1234, config['port']
66
+ end
67
+
68
+ def test_translate_should_correctly_translate_from_openssh_to_net_ssh_names
69
+ open_ssh = {
70
+ 'ciphers' => "a,b,c",
71
+ 'compression' => true,
72
+ 'compressionlevel' => 6,
73
+ 'connecttimeout' => 100,
74
+ 'forwardagent' => true,
75
+ 'hostbasedauthentication' => true,
76
+ 'hostkeyalgorithms' => "d,e,f",
77
+ 'identityfile' => %w(g h i),
78
+ 'macs' => "j,k,l",
79
+ 'passwordauthentication' => true,
80
+ 'port' => 1234,
81
+ 'pubkeyauthentication' => true,
82
+ 'rekeylimit' => 1024
83
+ }
84
+
85
+ net_ssh = Net::SSH::Config.translate(open_ssh)
86
+
87
+ assert_equal %w(a b c), net_ssh[:encryption]
88
+ assert_equal true, net_ssh[:compression]
89
+ assert_equal 6, net_ssh[:compression_level]
90
+ assert_equal 100, net_ssh[:timeout]
91
+ assert_equal true, net_ssh[:forward_agent]
92
+ assert_equal %w(hostbased password publickey), net_ssh[:auth_methods].sort
93
+ assert_equal %w(d e f), net_ssh[:host_key]
94
+ assert_equal %w(g h i), net_ssh[:keys]
95
+ assert_equal %w(j k l), net_ssh[:hmac]
96
+ assert_equal 1234, net_ssh[:port]
97
+ assert_equal 1024, net_ssh[:rekey_limit]
98
+ end
99
+
100
+ def test_load_with_plus_sign_hosts
101
+ config = Net::SSH::Config.load(config(:host_plus), "test.host")
102
+ assert config['compression']
103
+ end
104
+
105
+ def test_load_with_numeric_host
106
+ config = Net::SSH::Config.load(config(:numeric_host), "1234")
107
+ assert config['compression']
108
+ assert_equal '2G', config['rekeylimit']
109
+ assert_equal 1980, config['port']
110
+ end
111
+
112
+ private
113
+
114
+ def config(name)
115
+ "test/configs/#{name}"
116
+ end
117
+ end
@@ -0,0 +1,67 @@
1
+ require 'common'
2
+ require 'net/ssh/key_factory'
3
+
4
+ class TestKeyFactory < Test::Unit::TestCase
5
+ def test_load_unencrypted_private_RSA_key_should_return_key
6
+ File.expects(:read).with("/key-file").returns(rsa_key.export)
7
+ assert_equal rsa_key.to_der, Net::SSH::KeyFactory.load_private_key("/key-file").to_der
8
+ end
9
+
10
+ def test_load_unencrypted_private_DSA_key_should_return_key
11
+ File.expects(:read).with("/key-file").returns(dsa_key.export)
12
+ assert_equal dsa_key.to_der, Net::SSH::KeyFactory.load_private_key("/key-file").to_der
13
+ end
14
+
15
+ def test_load_encrypted_private_RSA_key_should_prompt_for_password_and_return_key
16
+ File.expects(:read).with("/key-file").returns(encrypted(rsa_key, "password"))
17
+ Net::SSH::KeyFactory.expects(:prompt).with("Enter passphrase for /key-file:", false).returns("password")
18
+ assert_equal rsa_key.to_der, Net::SSH::KeyFactory.load_private_key("/key-file").to_der
19
+ end
20
+
21
+ def test_load_encrypted_private_RSA_key_with_password_should_not_prompt_and_return_key
22
+ File.expects(:read).with("/key-file").returns(encrypted(rsa_key, "password"))
23
+ assert_equal rsa_key.to_der, Net::SSH::KeyFactory.load_private_key("/key-file", "password").to_der
24
+ end
25
+
26
+ def test_load_encrypted_private_DSA_key_should_prompt_for_password_and_return_key
27
+ File.expects(:read).with("/key-file").returns(encrypted(dsa_key, "password"))
28
+ Net::SSH::KeyFactory.expects(:prompt).with("Enter passphrase for /key-file:", false).returns("password")
29
+ assert_equal dsa_key.to_der, Net::SSH::KeyFactory.load_private_key("/key-file").to_der
30
+ end
31
+
32
+ def test_load_encrypted_private_DSA_key_with_password_should_not_prompt_and_return_key
33
+ File.expects(:read).with("/key-file").returns(encrypted(dsa_key, "password"))
34
+ assert_equal dsa_key.to_der, Net::SSH::KeyFactory.load_private_key("/key-file", "password").to_der
35
+ end
36
+
37
+ def test_load_encrypted_private_key_should_give_three_tries_for_the_password_and_then_raise_exception
38
+ File.expects(:read).with("/key-file").returns(encrypted(rsa_key, "password"))
39
+ Net::SSH::KeyFactory.expects(:prompt).times(3).with("Enter passphrase for /key-file:", false).returns("passwod","passphrase","passwd")
40
+ assert_raises(OpenSSL::PKey::RSAError) { Net::SSH::KeyFactory.load_private_key("/key-file") }
41
+ end
42
+
43
+ def test_load_public_rsa_key_should_return_key
44
+ File.expects(:read).with("/key-file").returns(public(rsa_key))
45
+ assert_equal rsa_key.to_blob, Net::SSH::KeyFactory.load_public_key("/key-file").to_blob
46
+ end
47
+
48
+ private
49
+
50
+ def rsa_key
51
+ @rsa_key ||= OpenSSL::PKey::RSA.new("0@\002\001\000\002\t\000\300\030\317\2132\340 \267\002\003\001\000\001\002\t\000\236~\232\025\350Y=\341\002\005\000\352D\217\a\002\005\000\321\352\304\321\002\005\000\242\350\206%\002\005\000\270\021\217\361\002\004~\253\214j")
52
+ end
53
+
54
+ def dsa_key
55
+ @dsa_key ||= OpenSSL::PKey::DSA.new("0\201\367\002\001\000\002A\000\203\316/\037u\272&J\265\003l3\315d\324h\372{\t8\252#\331_\026\006\035\270\266\255\343\353Z\302\276\335\336\306\220\375\202L\244\244J\206>\346\b\315\211\302L\246x\247u\a\376\366\345\302\016#\002\025\000\244\274\302\221Og\275/\302+\356\346\360\024\373wI\2573\361\002@\027\215\270r*\f\213\350C\245\021:\350 \006\\\376\345\022`\210b\262\3643\023XLKS\320\370\002\276\347A\nU\204\276\324\256`=\026\240\330\306J\316V\213\024\e\030\215\355\006\037q\337\356ln\002@\017\257\034\f\260\333'S\271#\237\230E\321\312\027\021\226\331\251Vj\220\305\316\036\v\266+\000\230\270\177B\003?t\a\305]e\344\261\334\023\253\323\251\223M\2175)a(\004\"lI8\312\303\307\a\002\024_\aznW\345\343\203V\326\246ua\203\376\201o\350\302\002")
56
+ end
57
+
58
+ def encrypted(key, password)
59
+ key.export(OpenSSL::Cipher::Cipher.new("des-ede3-cbc"), password)
60
+ end
61
+
62
+ def public(key)
63
+ result = "#{key.ssh_type} "
64
+ result << [Net::SSH::Buffer.from(:key, key).to_s].pack("m*").strip.tr("\n\r\t ", "")
65
+ result << " joe@host.test"
66
+ end
67
+ end
@@ -0,0 +1,39 @@
1
+ require 'common'
2
+ require 'net/ssh/transport/hmac/md5'
3
+
4
+ module Transport; module HMAC
5
+
6
+ class TestMD5 < Test::Unit::TestCase
7
+ def test_expected_digest_class
8
+ assert_equal OpenSSL::Digest::MD5, subject.digest_class
9
+ assert_equal OpenSSL::Digest::MD5, subject.new.digest_class
10
+ end
11
+
12
+ def test_expected_key_length
13
+ assert_equal 16, subject.key_length
14
+ assert_equal 16, subject.new.key_length
15
+ end
16
+
17
+ def test_expected_mac_length
18
+ assert_equal 16, subject.mac_length
19
+ assert_equal 16, subject.new.mac_length
20
+ end
21
+
22
+ def test_expected_digest
23
+ hmac = subject.new("1234567890123456")
24
+ assert_equal "\275\345\006\307y~Oi\035<.\341\031\250<\257", hmac.digest("hello world")
25
+ end
26
+
27
+ def test_key_should_be_truncated_to_required_length
28
+ hmac = subject.new("12345678901234567890")
29
+ assert_equal "1234567890123456", hmac.key
30
+ end
31
+
32
+ private
33
+
34
+ def subject
35
+ Net::SSH::Transport::HMAC::MD5
36
+ end
37
+ end
38
+
39
+ end; end
@@ -0,0 +1,25 @@
1
+ require 'common'
2
+ require 'transport/hmac/test_md5'
3
+ require 'net/ssh/transport/hmac/md5_96'
4
+
5
+ module Transport; module HMAC
6
+
7
+ class TestMD5_96 < TestMD5
8
+ def test_expected_mac_length
9
+ assert_equal 12, subject.mac_length
10
+ assert_equal 12, subject.new.mac_length
11
+ end
12
+
13
+ def test_expected_digest
14
+ hmac = subject.new("1234567890123456")
15
+ assert_equal "\275\345\006\307y~Oi\035<.\341", hmac.digest("hello world")
16
+ end
17
+
18
+ private
19
+
20
+ def subject
21
+ Net::SSH::Transport::HMAC::MD5_96
22
+ end
23
+ end
24
+
25
+ end; end
@@ -0,0 +1,34 @@
1
+ require 'common'
2
+ require 'net/ssh/transport/hmac/none'
3
+
4
+ module Transport; module HMAC
5
+
6
+ class TestNone < Test::Unit::TestCase
7
+ def test_expected_digest_class
8
+ assert_equal nil, subject.digest_class
9
+ assert_equal nil, subject.new.digest_class
10
+ end
11
+
12
+ def test_expected_key_length
13
+ assert_equal 0, subject.key_length
14
+ assert_equal 0, subject.new.key_length
15
+ end
16
+
17
+ def test_expected_mac_length
18
+ assert_equal 0, subject.mac_length
19
+ assert_equal 0, subject.new.mac_length
20
+ end
21
+
22
+ def test_expected_digest
23
+ hmac = subject.new("1234567890123456")
24
+ assert_equal "", hmac.digest("hello world")
25
+ end
26
+
27
+ private
28
+
29
+ def subject
30
+ Net::SSH::Transport::HMAC::None
31
+ end
32
+ end
33
+
34
+ end; end
@@ -0,0 +1,34 @@
1
+ require 'common'
2
+ require 'net/ssh/transport/hmac/sha1'
3
+
4
+ module Transport; module HMAC
5
+
6
+ class TestSHA1 < Test::Unit::TestCase
7
+ def test_expected_digest_class
8
+ assert_equal OpenSSL::Digest::SHA1, subject.digest_class
9
+ assert_equal OpenSSL::Digest::SHA1, subject.new.digest_class
10
+ end
11
+
12
+ def test_expected_key_length
13
+ assert_equal 20, subject.key_length
14
+ assert_equal 20, subject.new.key_length
15
+ end
16
+
17
+ def test_expected_mac_length
18
+ assert_equal 20, subject.mac_length
19
+ assert_equal 20, subject.new.mac_length
20
+ end
21
+
22
+ def test_expected_digest
23
+ hmac = subject.new("1234567890123456")
24
+ assert_equal "\000\004W\202\204+&\335\311\251P\266\250\214\276\206;\022U\365", hmac.digest("hello world")
25
+ end
26
+
27
+ private
28
+
29
+ def subject
30
+ Net::SSH::Transport::HMAC::SHA1
31
+ end
32
+ end
33
+
34
+ end; end
@@ -0,0 +1,25 @@
1
+ require 'common'
2
+ require 'transport/hmac/test_sha1'
3
+ require 'net/ssh/transport/hmac/sha1_96'
4
+
5
+ module Transport; module HMAC
6
+
7
+ class TestSHA1_96 < TestSHA1
8
+ def test_expected_mac_length
9
+ assert_equal 12, subject.mac_length
10
+ assert_equal 12, subject.new.mac_length
11
+ end
12
+
13
+ def test_expected_digest
14
+ hmac = subject.new("1234567890123456")
15
+ assert_equal "\000\004W\202\204+&\335\311\251P\266", hmac.digest("hello world")
16
+ end
17
+
18
+ private
19
+
20
+ def subject
21
+ Net::SSH::Transport::HMAC::SHA1_96
22
+ end
23
+ end
24
+
25
+ end; end
@@ -0,0 +1,146 @@
1
+ require 'common'
2
+ require 'net/ssh/transport/kex/diffie_hellman_group1_sha1'
3
+ require 'ostruct'
4
+
5
+ module Transport; module Kex
6
+
7
+ class TestDiffieHellmanGroup1SHA1 < Test::Unit::TestCase
8
+ include Net::SSH::Transport::Constants
9
+
10
+ def setup
11
+ @dh_options = @dh = @algorithms = @connection = @server_key =
12
+ @packet_data = @shared_secret = nil
13
+ end
14
+
15
+ def test_exchange_keys_should_return_expected_results_when_successful
16
+ result = exchange!
17
+ assert_equal session_id, result[:session_id]
18
+ assert_equal server_key.to_blob, result[:server_key].to_blob
19
+ assert_equal shared_secret, result[:shared_secret]
20
+ assert_equal OpenSSL::Digest::SHA1, result[:hashing_algorithm]
21
+ end
22
+
23
+ def test_exchange_keys_with_unverifiable_host_should_raise_exception
24
+ connection.verifier { false }
25
+ assert_raises(Net::SSH::Exception) { exchange! }
26
+ end
27
+
28
+ def test_exchange_keys_with_signature_key_type_mismatch_should_raise_exception
29
+ assert_raises(Net::SSH::Exception) { exchange! :key_type => "ssh-dss" }
30
+ end
31
+
32
+ def test_exchange_keys_with_host_key_type_mismatch_should_raise_exception
33
+ algorithms :host_key => "ssh-dss"
34
+ assert_raises(Net::SSH::Exception) { exchange! :key_type => "ssh-dss" }
35
+ end
36
+
37
+ def test_exchange_keys_when_server_signature_could_not_be_verified_should_raise_exception
38
+ @signature = "1234567890"
39
+ assert_raises(Net::SSH::Exception) { exchange! }
40
+ end
41
+
42
+ def test_exchange_keys_should_pass_expected_parameters_to_host_key_verifier
43
+ verified = false
44
+ connection.verifier do |data|
45
+ verified = true
46
+ assert_equal server_key.to_blob, data[:key].to_blob
47
+
48
+ blob = b(:key, data[:key]).to_s
49
+ fingerprint = OpenSSL::Digest::MD5.hexdigest(blob).scan(/../).join(":")
50
+
51
+ assert_equal blob, data[:key_blob]
52
+ assert_equal fingerprint, data[:fingerprint]
53
+ assert_equal connection, data[:session]
54
+
55
+ true
56
+ end
57
+
58
+ assert_nothing_raised { exchange! }
59
+ assert verified
60
+ end
61
+
62
+ private
63
+
64
+ def exchange!(options={})
65
+ connection.expect do |t, buffer|
66
+ assert_equal KEXDH_INIT, buffer.type
67
+ assert_equal dh.dh.pub_key, buffer.read_bignum
68
+ t.return(KEXDH_REPLY, :string, b(:key, server_key), :bignum, server_dh_pubkey, :string, b(:string, options[:key_type] || "ssh-rsa", :string, signature))
69
+ connection.expect do |t2, buffer2|
70
+ assert_equal NEWKEYS, buffer2.type
71
+ t2.return(NEWKEYS)
72
+ end
73
+ end
74
+
75
+ dh.exchange_keys
76
+ end
77
+
78
+ def dh_options(options={})
79
+ @dh_options = options
80
+ end
81
+
82
+ def dh
83
+ @dh ||= subject.new(algorithms, connection, packet_data.merge(:need_bytes => 20).merge(@dh_options || {}))
84
+ end
85
+
86
+ def algorithms(options={})
87
+ @algorithms ||= OpenStruct.new(:host_key => options[:host_key] || "ssh-rsa")
88
+ end
89
+
90
+ def connection
91
+ @connection ||= MockTransport.new
92
+ end
93
+
94
+ def subject
95
+ Net::SSH::Transport::Kex::DiffieHellmanGroup1SHA1
96
+ end
97
+
98
+ # 368 bits is the smallest possible key that will work with this, so
99
+ # we use it for speed reasons
100
+ def server_key(bits=368)
101
+ @server_key ||= OpenSSL::PKey::RSA.new(bits)
102
+ end
103
+
104
+ def packet_data
105
+ @packet_data ||= { :client_version_string => "client version string",
106
+ :server_version_string => "server version string",
107
+ :server_algorithm_packet => "server algorithm packet",
108
+ :client_algorithm_packet => "client algorithm packet" }
109
+ end
110
+
111
+ def server_dh_pubkey
112
+ @server_dh_pubkey ||= bn(1234567890)
113
+ end
114
+
115
+ def shared_secret
116
+ @shared_secret ||= OpenSSL::BN.new(dh.dh.compute_key(server_dh_pubkey), 2)
117
+ end
118
+
119
+ def session_id
120
+ @session_id ||= begin
121
+ buffer = Net::SSH::Buffer.from(:string, packet_data[:client_version_string],
122
+ :string, packet_data[:server_version_string],
123
+ :string, packet_data[:client_algorithm_packet],
124
+ :string, packet_data[:server_algorithm_packet],
125
+ :string, Net::SSH::Buffer.from(:key, server_key),
126
+ :bignum, dh.dh.pub_key,
127
+ :bignum, server_dh_pubkey,
128
+ :bignum, shared_secret)
129
+ OpenSSL::Digest::SHA1.digest(buffer.to_s)
130
+ end
131
+ end
132
+
133
+ def signature
134
+ @signature ||= server_key.ssh_do_sign(session_id)
135
+ end
136
+
137
+ def bn(number, base=10)
138
+ OpenSSL::BN.new(number.to_s, base)
139
+ end
140
+
141
+ def b(*args)
142
+ Net::SSH::Buffer.from(*args)
143
+ end
144
+ end
145
+
146
+ end; end