abiquo-installer-tests 20120104 → 20121023.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (265) hide show
  1. data/Rakefile +11 -7
  2. data/bin/abiquo-installer-tests +68 -43
  3. data/tests/1.8.5/abiquo_ciab.rb +21 -0
  4. data/tests/1.8.5/abiquo_kvm.rb +25 -0
  5. data/tests/1.8.5/abiquo_lvmiscsi.rb +17 -0
  6. data/tests/1.8.5/abiquo_monolithic.rb +12 -0
  7. data/tests/1.8.5/abiquo_nfs_repository.rb +23 -0
  8. data/tests/1.8.5/abiquo_platform.rb +39 -0
  9. data/tests/1.8.5/abiquo_remote_services.rb +115 -0
  10. data/tests/1.8.5/abiquo_server.rb +63 -0
  11. data/tests/1.8.5/abiquo_v2v.rb +37 -0
  12. data/tests/1.8.5/abiquo_vbox.rb +27 -0
  13. data/tests/1.8.5/abiquo_xen.rb +27 -0
  14. data/tests/2.0/abiquo_ciab.rb +9 -0
  15. data/tests/2.0/abiquo_community_hypervisor.rb +52 -0
  16. data/tests/2.0/abiquo_kvm.rb +5 -23
  17. data/tests/2.0/abiquo_monolithic.rb +12 -1
  18. data/tests/2.0/abiquo_platform.rb +2 -2
  19. data/tests/2.0/abiquo_remote_services.rb +15 -38
  20. data/tests/2.0/abiquo_server.rb +7 -1
  21. data/tests/2.0/abiquo_v2v.rb +42 -0
  22. data/tests/2.0/abiquo_vbox.rb +5 -25
  23. data/tests/2.0/abiquo_xen.rb +5 -25
  24. data/tests/2.2.0/abiquo_ciab.rb +30 -0
  25. data/tests/2.2.0/abiquo_community_hypervisor.rb +52 -0
  26. data/tests/2.2.0/abiquo_kvm.rb +7 -0
  27. data/tests/2.2.0/abiquo_lvmiscsi.rb +17 -0
  28. data/tests/2.2.0/abiquo_monolithic.rb +23 -0
  29. data/tests/2.2.0/abiquo_nfs_repository.rb +23 -0
  30. data/tests/2.2.0/abiquo_platform.rb +35 -0
  31. data/tests/2.2.0/abiquo_remote_services.rb +96 -0
  32. data/tests/2.2.0/abiquo_server.rb +95 -0
  33. data/tests/2.2.0/abiquo_v2v.rb +79 -0
  34. data/tests/2.2.0/abiquo_vbox.rb +7 -0
  35. data/tests/2.2.0/abiquo_xen.rb +7 -0
  36. data/tests/2.3.0/abiquo_ciab.rb +30 -0
  37. data/tests/2.3.0/abiquo_community_hypervisor.rb +52 -0
  38. data/tests/2.3.0/abiquo_kvm.rb +7 -0
  39. data/tests/2.3.0/abiquo_lvmiscsi.rb +17 -0
  40. data/tests/2.3.0/abiquo_monolithic.rb +23 -0
  41. data/tests/2.3.0/abiquo_nfs_repository.rb +23 -0
  42. data/tests/2.3.0/abiquo_platform.rb +35 -0
  43. data/tests/2.3.0/abiquo_remote_services.rb +96 -0
  44. data/tests/2.3.0/abiquo_server.rb +95 -0
  45. data/tests/2.3.0/abiquo_v2v.rb +79 -0
  46. data/tests/2.3.0/abiquo_vbox.rb +7 -0
  47. data/tests/2.3.0/abiquo_xen.rb +7 -0
  48. data/tests/abiquo_postinst_test.rb +12 -1
  49. data/vendor/net-scp-1.0.4/CHANGELOG.rdoc +29 -0
  50. data/vendor/net-scp-1.0.4/Manifest +17 -0
  51. data/vendor/net-scp-1.0.4/README.rdoc +98 -0
  52. data/vendor/net-scp-1.0.4/Rakefile +83 -0
  53. data/vendor/net-scp-1.0.4/lib/net/scp.rb +432 -0
  54. data/vendor/net-scp-1.0.4/lib/net/scp/download.rb +150 -0
  55. data/vendor/net-scp-1.0.4/lib/net/scp/errors.rb +5 -0
  56. data/vendor/net-scp-1.0.4/lib/net/scp/upload.rb +142 -0
  57. data/vendor/net-scp-1.0.4/lib/net/scp/version.rb +18 -0
  58. data/vendor/net-scp-1.0.4/lib/uri/open-scp.rb +18 -0
  59. data/vendor/net-scp-1.0.4/lib/uri/scp.rb +35 -0
  60. data/vendor/net-scp-1.0.4/net-scp.gemspec +34 -0
  61. data/vendor/net-scp-1.0.4/setup.rb +1331 -0
  62. data/vendor/net-scp-1.0.4/test/common.rb +153 -0
  63. data/vendor/net-scp-1.0.4/test/test_all.rb +3 -0
  64. data/vendor/net-scp-1.0.4/test/test_download.rb +170 -0
  65. data/vendor/net-scp-1.0.4/test/test_scp.rb +60 -0
  66. data/vendor/net-scp-1.0.4/test/test_upload.rb +269 -0
  67. data/vendor/net-sftp-2.0.5/CHANGELOG.rdoc +49 -0
  68. data/vendor/net-sftp-2.0.5/Manifest +55 -0
  69. data/vendor/net-sftp-2.0.5/README.rdoc +96 -0
  70. data/vendor/net-sftp-2.0.5/Rakefile +30 -0
  71. data/vendor/net-sftp-2.0.5/lib/net/sftp.rb +70 -0
  72. data/vendor/net-sftp-2.0.5/lib/net/sftp/constants.rb +187 -0
  73. data/vendor/net-sftp-2.0.5/lib/net/sftp/errors.rb +39 -0
  74. data/vendor/net-sftp-2.0.5/lib/net/sftp/operations/dir.rb +93 -0
  75. data/vendor/net-sftp-2.0.5/lib/net/sftp/operations/download.rb +364 -0
  76. data/vendor/net-sftp-2.0.5/lib/net/sftp/operations/file.rb +176 -0
  77. data/vendor/net-sftp-2.0.5/lib/net/sftp/operations/file_factory.rb +60 -0
  78. data/vendor/net-sftp-2.0.5/lib/net/sftp/operations/upload.rb +387 -0
  79. data/vendor/net-sftp-2.0.5/lib/net/sftp/packet.rb +21 -0
  80. data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol.rb +32 -0
  81. data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/01/attributes.rb +315 -0
  82. data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/01/base.rb +268 -0
  83. data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/01/name.rb +43 -0
  84. data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/02/base.rb +31 -0
  85. data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/03/base.rb +35 -0
  86. data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/04/attributes.rb +152 -0
  87. data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/04/base.rb +94 -0
  88. data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/04/name.rb +67 -0
  89. data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/05/base.rb +66 -0
  90. data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/06/attributes.rb +107 -0
  91. data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/06/base.rb +63 -0
  92. data/vendor/net-sftp-2.0.5/lib/net/sftp/protocol/base.rb +50 -0
  93. data/vendor/net-sftp-2.0.5/lib/net/sftp/request.rb +91 -0
  94. data/vendor/net-sftp-2.0.5/lib/net/sftp/response.rb +76 -0
  95. data/vendor/net-sftp-2.0.5/lib/net/sftp/session.rb +952 -0
  96. data/vendor/net-sftp-2.0.5/lib/net/sftp/version.rb +18 -0
  97. data/vendor/net-sftp-2.0.5/net-sftp.gemspec +34 -0
  98. data/vendor/net-sftp-2.0.5/setup.rb +1331 -0
  99. data/vendor/net-sftp-2.0.5/test/common.rb +172 -0
  100. data/vendor/net-sftp-2.0.5/test/protocol/01/test_attributes.rb +97 -0
  101. data/vendor/net-sftp-2.0.5/test/protocol/01/test_base.rb +210 -0
  102. data/vendor/net-sftp-2.0.5/test/protocol/01/test_name.rb +27 -0
  103. data/vendor/net-sftp-2.0.5/test/protocol/02/test_base.rb +26 -0
  104. data/vendor/net-sftp-2.0.5/test/protocol/03/test_base.rb +27 -0
  105. data/vendor/net-sftp-2.0.5/test/protocol/04/test_attributes.rb +148 -0
  106. data/vendor/net-sftp-2.0.5/test/protocol/04/test_base.rb +74 -0
  107. data/vendor/net-sftp-2.0.5/test/protocol/04/test_name.rb +53 -0
  108. data/vendor/net-sftp-2.0.5/test/protocol/05/test_base.rb +62 -0
  109. data/vendor/net-sftp-2.0.5/test/protocol/06/test_attributes.rb +124 -0
  110. data/vendor/net-sftp-2.0.5/test/protocol/06/test_base.rb +51 -0
  111. data/vendor/net-sftp-2.0.5/test/protocol/test_base.rb +42 -0
  112. data/vendor/net-sftp-2.0.5/test/test_all.rb +7 -0
  113. data/vendor/net-sftp-2.0.5/test/test_dir.rb +47 -0
  114. data/vendor/net-sftp-2.0.5/test/test_download.rb +252 -0
  115. data/vendor/net-sftp-2.0.5/test/test_file.rb +159 -0
  116. data/vendor/net-sftp-2.0.5/test/test_file_factory.rb +48 -0
  117. data/vendor/net-sftp-2.0.5/test/test_packet.rb +9 -0
  118. data/vendor/net-sftp-2.0.5/test/test_protocol.rb +17 -0
  119. data/vendor/net-sftp-2.0.5/test/test_request.rb +71 -0
  120. data/vendor/net-sftp-2.0.5/test/test_response.rb +53 -0
  121. data/vendor/net-sftp-2.0.5/test/test_session.rb +741 -0
  122. data/vendor/net-sftp-2.0.5/test/test_upload.rb +219 -0
  123. data/vendor/net-ssh-2.5.2/CHANGELOG.rdoc +295 -0
  124. data/vendor/net-ssh-2.5.2/LICENSE.rdoc +19 -0
  125. data/vendor/net-ssh-2.5.2/Manifest +132 -0
  126. data/vendor/net-ssh-2.5.2/README.rdoc +184 -0
  127. data/vendor/net-ssh-2.5.2/Rakefile +88 -0
  128. data/vendor/net-ssh-2.5.2/Rudyfile +96 -0
  129. data/vendor/net-ssh-2.5.2/THANKS.rdoc +19 -0
  130. data/vendor/net-ssh-2.5.2/lib/net/ssh.rb +223 -0
  131. data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/agent.rb +23 -0
  132. data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/agent/java_pageant.rb +85 -0
  133. data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/agent/socket.rb +170 -0
  134. data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/constants.rb +18 -0
  135. data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/key_manager.rb +253 -0
  136. data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/methods/abstract.rb +60 -0
  137. data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/methods/hostbased.rb +75 -0
  138. data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/methods/keyboard_interactive.rb +70 -0
  139. data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/methods/password.rb +43 -0
  140. data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/methods/publickey.rb +96 -0
  141. data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/pageant.rb +264 -0
  142. data/vendor/net-ssh-2.5.2/lib/net/ssh/authentication/session.rb +154 -0
  143. data/vendor/net-ssh-2.5.2/lib/net/ssh/buffer.rb +350 -0
  144. data/vendor/net-ssh-2.5.2/lib/net/ssh/buffered_io.rb +198 -0
  145. data/vendor/net-ssh-2.5.2/lib/net/ssh/config.rb +207 -0
  146. data/vendor/net-ssh-2.5.2/lib/net/ssh/connection/channel.rb +630 -0
  147. data/vendor/net-ssh-2.5.2/lib/net/ssh/connection/constants.rb +33 -0
  148. data/vendor/net-ssh-2.5.2/lib/net/ssh/connection/session.rb +597 -0
  149. data/vendor/net-ssh-2.5.2/lib/net/ssh/connection/term.rb +178 -0
  150. data/vendor/net-ssh-2.5.2/lib/net/ssh/errors.rb +88 -0
  151. data/vendor/net-ssh-2.5.2/lib/net/ssh/key_factory.rb +107 -0
  152. data/vendor/net-ssh-2.5.2/lib/net/ssh/known_hosts.rb +141 -0
  153. data/vendor/net-ssh-2.5.2/lib/net/ssh/loggable.rb +61 -0
  154. data/vendor/net-ssh-2.5.2/lib/net/ssh/packet.rb +102 -0
  155. data/vendor/net-ssh-2.5.2/lib/net/ssh/prompt.rb +93 -0
  156. data/vendor/net-ssh-2.5.2/lib/net/ssh/proxy/command.rb +75 -0
  157. data/vendor/net-ssh-2.5.2/lib/net/ssh/proxy/errors.rb +14 -0
  158. data/vendor/net-ssh-2.5.2/lib/net/ssh/proxy/http.rb +94 -0
  159. data/vendor/net-ssh-2.5.2/lib/net/ssh/proxy/socks4.rb +70 -0
  160. data/vendor/net-ssh-2.5.2/lib/net/ssh/proxy/socks5.rb +142 -0
  161. data/vendor/net-ssh-2.5.2/lib/net/ssh/ruby_compat.rb +51 -0
  162. data/vendor/net-ssh-2.5.2/lib/net/ssh/service/forward.rb +298 -0
  163. data/vendor/net-ssh-2.5.2/lib/net/ssh/test.rb +89 -0
  164. data/vendor/net-ssh-2.5.2/lib/net/ssh/test/channel.rb +129 -0
  165. data/vendor/net-ssh-2.5.2/lib/net/ssh/test/extensions.rb +152 -0
  166. data/vendor/net-ssh-2.5.2/lib/net/ssh/test/kex.rb +44 -0
  167. data/vendor/net-ssh-2.5.2/lib/net/ssh/test/local_packet.rb +51 -0
  168. data/vendor/net-ssh-2.5.2/lib/net/ssh/test/packet.rb +81 -0
  169. data/vendor/net-ssh-2.5.2/lib/net/ssh/test/remote_packet.rb +38 -0
  170. data/vendor/net-ssh-2.5.2/lib/net/ssh/test/script.rb +157 -0
  171. data/vendor/net-ssh-2.5.2/lib/net/ssh/test/socket.rb +64 -0
  172. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/algorithms.rb +407 -0
  173. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/cipher_factory.rb +106 -0
  174. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/constants.rb +32 -0
  175. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/ctr.rb +95 -0
  176. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac.rb +45 -0
  177. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/abstract.rb +79 -0
  178. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/md5.rb +12 -0
  179. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/md5_96.rb +11 -0
  180. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/none.rb +15 -0
  181. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/ripemd160.rb +13 -0
  182. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha1.rb +13 -0
  183. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha1_96.rb +11 -0
  184. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha2_256.rb +15 -0
  185. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha2_256_96.rb +13 -0
  186. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha2_512.rb +14 -0
  187. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/hmac/sha2_512_96.rb +13 -0
  188. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/identity_cipher.rb +55 -0
  189. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex.rb +28 -0
  190. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/diffie_hellman_group14_sha1.rb +44 -0
  191. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +216 -0
  192. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +80 -0
  193. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha256.rb +15 -0
  194. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/ecdh_sha2_nistp256.rb +93 -0
  195. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/ecdh_sha2_nistp384.rb +13 -0
  196. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/kex/ecdh_sha2_nistp521.rb +13 -0
  197. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/key_expander.rb +26 -0
  198. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/openssl.rb +237 -0
  199. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/packet_stream.rb +235 -0
  200. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/server_version.rb +71 -0
  201. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/session.rb +278 -0
  202. data/vendor/net-ssh-2.5.2/lib/net/ssh/transport/state.rb +206 -0
  203. data/vendor/net-ssh-2.5.2/lib/net/ssh/verifiers/lenient.rb +30 -0
  204. data/vendor/net-ssh-2.5.2/lib/net/ssh/verifiers/null.rb +12 -0
  205. data/vendor/net-ssh-2.5.2/lib/net/ssh/verifiers/strict.rb +53 -0
  206. data/vendor/net-ssh-2.5.2/lib/net/ssh/version.rb +62 -0
  207. data/vendor/net-ssh-2.5.2/net-ssh.gemspec +172 -0
  208. data/vendor/net-ssh-2.5.2/setup.rb +1585 -0
  209. data/vendor/net-ssh-2.5.2/support/arcfour_check.rb +20 -0
  210. data/vendor/net-ssh-2.5.2/support/ssh_tunnel_bug.rb +65 -0
  211. data/vendor/net-ssh-2.5.2/test/README.txt +43 -0
  212. data/vendor/net-ssh-2.5.2/test/authentication/methods/common.rb +28 -0
  213. data/vendor/net-ssh-2.5.2/test/authentication/methods/test_abstract.rb +51 -0
  214. data/vendor/net-ssh-2.5.2/test/authentication/methods/test_hostbased.rb +114 -0
  215. data/vendor/net-ssh-2.5.2/test/authentication/methods/test_keyboard_interactive.rb +100 -0
  216. data/vendor/net-ssh-2.5.2/test/authentication/methods/test_password.rb +52 -0
  217. data/vendor/net-ssh-2.5.2/test/authentication/methods/test_publickey.rb +148 -0
  218. data/vendor/net-ssh-2.5.2/test/authentication/test_agent.rb +205 -0
  219. data/vendor/net-ssh-2.5.2/test/authentication/test_key_manager.rb +218 -0
  220. data/vendor/net-ssh-2.5.2/test/authentication/test_session.rb +106 -0
  221. data/vendor/net-ssh-2.5.2/test/common.rb +107 -0
  222. data/vendor/net-ssh-2.5.2/test/configs/eqsign +3 -0
  223. data/vendor/net-ssh-2.5.2/test/configs/exact_match +8 -0
  224. data/vendor/net-ssh-2.5.2/test/configs/host_plus +10 -0
  225. data/vendor/net-ssh-2.5.2/test/configs/multihost +4 -0
  226. data/vendor/net-ssh-2.5.2/test/configs/nohost +19 -0
  227. data/vendor/net-ssh-2.5.2/test/configs/numeric_host +4 -0
  228. data/vendor/net-ssh-2.5.2/test/configs/wild_cards +14 -0
  229. data/vendor/net-ssh-2.5.2/test/connection/test_channel.rb +467 -0
  230. data/vendor/net-ssh-2.5.2/test/connection/test_session.rb +488 -0
  231. data/vendor/net-ssh-2.5.2/test/known_hosts/github +1 -0
  232. data/vendor/net-ssh-2.5.2/test/manual/test_forward.rb +223 -0
  233. data/vendor/net-ssh-2.5.2/test/start/test_transport.rb +28 -0
  234. data/vendor/net-ssh-2.5.2/test/test_all.rb +9 -0
  235. data/vendor/net-ssh-2.5.2/test/test_buffer.rb +426 -0
  236. data/vendor/net-ssh-2.5.2/test/test_buffered_io.rb +63 -0
  237. data/vendor/net-ssh-2.5.2/test/test_config.rb +120 -0
  238. data/vendor/net-ssh-2.5.2/test/test_key_factory.rb +121 -0
  239. data/vendor/net-ssh-2.5.2/test/test_known_hosts.rb +13 -0
  240. data/vendor/net-ssh-2.5.2/test/transport/hmac/test_md5.rb +39 -0
  241. data/vendor/net-ssh-2.5.2/test/transport/hmac/test_md5_96.rb +25 -0
  242. data/vendor/net-ssh-2.5.2/test/transport/hmac/test_none.rb +34 -0
  243. data/vendor/net-ssh-2.5.2/test/transport/hmac/test_ripemd160.rb +34 -0
  244. data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha1.rb +34 -0
  245. data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha1_96.rb +25 -0
  246. data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha2_256.rb +35 -0
  247. data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha2_256_96.rb +25 -0
  248. data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha2_512.rb +35 -0
  249. data/vendor/net-ssh-2.5.2/test/transport/hmac/test_sha2_512_96.rb +25 -0
  250. data/vendor/net-ssh-2.5.2/test/transport/kex/test_diffie_hellman_group14_sha1.rb +13 -0
  251. data/vendor/net-ssh-2.5.2/test/transport/kex/test_diffie_hellman_group1_sha1.rb +146 -0
  252. data/vendor/net-ssh-2.5.2/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +92 -0
  253. data/vendor/net-ssh-2.5.2/test/transport/kex/test_diffie_hellman_group_exchange_sha256.rb +33 -0
  254. data/vendor/net-ssh-2.5.2/test/transport/kex/test_ecdh_sha2_nistp256.rb +161 -0
  255. data/vendor/net-ssh-2.5.2/test/transport/kex/test_ecdh_sha2_nistp384.rb +37 -0
  256. data/vendor/net-ssh-2.5.2/test/transport/kex/test_ecdh_sha2_nistp521.rb +37 -0
  257. data/vendor/net-ssh-2.5.2/test/transport/test_algorithms.rb +330 -0
  258. data/vendor/net-ssh-2.5.2/test/transport/test_cipher_factory.rb +441 -0
  259. data/vendor/net-ssh-2.5.2/test/transport/test_hmac.rb +34 -0
  260. data/vendor/net-ssh-2.5.2/test/transport/test_identity_cipher.rb +40 -0
  261. data/vendor/net-ssh-2.5.2/test/transport/test_packet_stream.rb +1745 -0
  262. data/vendor/net-ssh-2.5.2/test/transport/test_server_version.rb +78 -0
  263. data/vendor/net-ssh-2.5.2/test/transport/test_session.rb +315 -0
  264. data/vendor/net-ssh-2.5.2/test/transport/test_state.rb +179 -0
  265. metadata +325 -78
@@ -0,0 +1,106 @@
1
+ require 'common'
2
+ require 'net/ssh/authentication/session'
3
+
4
+ module Authentication
5
+
6
+ class TestSession < Test::Unit::TestCase
7
+ include Net::SSH::Transport::Constants
8
+ include Net::SSH::Authentication::Constants
9
+
10
+ def test_constructor_should_set_defaults
11
+ assert_equal %w(publickey hostbased password keyboard-interactive), session.auth_methods
12
+ assert_equal session.auth_methods, session.allowed_auth_methods
13
+ end
14
+
15
+ def test_authenticate_should_continue_if_method_disallowed
16
+ transport.expect do |t, packet|
17
+ assert_equal SERVICE_REQUEST, packet.type
18
+ assert_equal "ssh-userauth", packet.read_string
19
+ t.return(SERVICE_ACCEPT)
20
+ end
21
+
22
+ Net::SSH::Authentication::Methods::Publickey.any_instance.expects(:authenticate).with("next service", "username", "password").raises(Net::SSH::Authentication::DisallowedMethod)
23
+ Net::SSH::Authentication::Methods::Hostbased.any_instance.expects(:authenticate).with("next service", "username", "password").returns(true)
24
+
25
+ assert session.authenticate("next service", "username", "password")
26
+ end
27
+
28
+ def test_authenticate_should_raise_error_if_service_request_fails
29
+ transport.expect do |t, packet|
30
+ assert_equal SERVICE_REQUEST, packet.type
31
+ assert_equal "ssh-userauth", packet.read_string
32
+ t.return(255)
33
+ end
34
+
35
+ assert_raises(Net::SSH::Exception) { session.authenticate("next service", "username", "password") }
36
+ end
37
+
38
+ def test_authenticate_should_return_false_if_all_auth_methods_fail
39
+ transport.expect do |t, packet|
40
+ assert_equal SERVICE_REQUEST, packet.type
41
+ assert_equal "ssh-userauth", packet.read_string
42
+ t.return(SERVICE_ACCEPT)
43
+ end
44
+
45
+ Net::SSH::Authentication::Methods::Publickey.any_instance.expects(:authenticate).with("next service", "username", "password").returns(false)
46
+ Net::SSH::Authentication::Methods::Hostbased.any_instance.expects(:authenticate).with("next service", "username", "password").returns(false)
47
+ Net::SSH::Authentication::Methods::Password.any_instance.expects(:authenticate).with("next service", "username", "password").returns(false)
48
+ Net::SSH::Authentication::Methods::KeyboardInteractive.any_instance.expects(:authenticate).with("next service", "username", "password").returns(false)
49
+
50
+ assert_equal false, session.authenticate("next service", "username", "password")
51
+ end
52
+
53
+ def test_next_message_should_silently_handle_USERAUTH_BANNER_packets
54
+ transport.return(USERAUTH_BANNER, :string, "Howdy, folks!")
55
+ transport.return(SERVICE_ACCEPT)
56
+ assert_equal SERVICE_ACCEPT, session.next_message.type
57
+ end
58
+
59
+ def test_next_message_should_understand_USERAUTH_FAILURE
60
+ transport.return(USERAUTH_FAILURE, :string, "a,b,c", :bool, false)
61
+ packet = session.next_message
62
+ assert_equal USERAUTH_FAILURE, packet.type
63
+ assert_equal %w(a b c), session.allowed_auth_methods
64
+ end
65
+
66
+ (60..79).each do |type|
67
+ define_method("test_next_message_should_return_packets_of_type_#{type}") do
68
+ transport.return(type)
69
+ assert_equal type, session.next_message.type
70
+ end
71
+ end
72
+
73
+ def test_next_message_should_understand_USERAUTH_SUCCESS
74
+ transport.return(USERAUTH_SUCCESS)
75
+ assert !transport.hints[:authenticated]
76
+ assert_equal USERAUTH_SUCCESS, session.next_message.type
77
+ assert transport.hints[:authenticated]
78
+ end
79
+
80
+ def test_next_message_should_raise_error_on_unrecognized_packet_types
81
+ transport.return(1)
82
+ assert_raises(Net::SSH::Exception) { session.next_message }
83
+ end
84
+
85
+ def test_expect_message_should_raise_exception_if_next_packet_is_not_expected_type
86
+ transport.return(SERVICE_ACCEPT)
87
+ assert_raises(Net::SSH::Exception) { session.expect_message(USERAUTH_BANNER) }
88
+ end
89
+
90
+ def test_expect_message_should_return_packet_if_next_packet_is_expected_type
91
+ transport.return(SERVICE_ACCEPT)
92
+ assert_equal SERVICE_ACCEPT, session.expect_message(SERVICE_ACCEPT).type
93
+ end
94
+
95
+ private
96
+
97
+ def session(options={})
98
+ @session ||= Net::SSH::Authentication::Session.new(transport(options), options)
99
+ end
100
+
101
+ def transport(options={})
102
+ @transport ||= MockTransport.new(options)
103
+ end
104
+ end
105
+
106
+ end
@@ -0,0 +1,107 @@
1
+ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
2
+ gem "test-unit" # http://rubyforge.org/pipermail/test-unit-tracker/2009-July/000075.html
3
+ require 'test/unit'
4
+ require 'mocha'
5
+ require 'net/ssh/buffer'
6
+ require 'net/ssh/config'
7
+ require 'net/ssh/loggable'
8
+ require 'net/ssh/packet'
9
+ require 'net/ssh/transport/session'
10
+ require 'ostruct'
11
+
12
+ # clear the default files out so that tests don't get confused by existing
13
+ # SSH config files.
14
+ $original_config_default_files = Net::SSH::Config.default_files.dup
15
+ Net::SSH::Config.default_files.clear
16
+
17
+ def P(*args)
18
+ Net::SSH::Packet.new(Net::SSH::Buffer.from(*args))
19
+ end
20
+
21
+ class MockTransport < Net::SSH::Transport::Session
22
+ class BlockVerifier
23
+ def initialize(block)
24
+ @block = block
25
+ end
26
+
27
+ def verify(data)
28
+ @block.call(data)
29
+ end
30
+ end
31
+
32
+ attr_reader :host_key_verifier
33
+ attr_accessor :host_as_string
34
+ attr_accessor :server_version
35
+
36
+ attr_reader :client_options
37
+ attr_reader :server_options
38
+ attr_reader :hints, :queue
39
+
40
+ attr_accessor :mock_enqueue
41
+
42
+ def initialize(options={})
43
+ self.logger = options[:logger]
44
+ self.host_as_string = "net.ssh.test,127.0.0.1"
45
+ self.server_version = OpenStruct.new(:version => "SSH-2.0-Ruby/Net::SSH::Test")
46
+ @expectation = nil
47
+ @queue = []
48
+ @hints = {}
49
+ @socket = options[:socket]
50
+ @algorithms = OpenStruct.new(:session_id => "abcxyz123")
51
+ verifier { |data| true }
52
+ end
53
+
54
+ def send_message(message)
55
+ buffer = Net::SSH::Buffer.new(message.to_s)
56
+ if @expectation.nil?
57
+ raise "got #{message.to_s.inspect} but was not expecting anything"
58
+ else
59
+ block, @expectation = @expectation, nil
60
+ block.call(self, Net::SSH::Packet.new(buffer))
61
+ end
62
+ end
63
+
64
+ def enqueue_message(message)
65
+ if mock_enqueue
66
+ send_message(message)
67
+ else
68
+ super
69
+ end
70
+ end
71
+
72
+ def poll_message
73
+ @queue.shift
74
+ end
75
+
76
+ def next_message
77
+ @queue.shift or raise "expected a message from the server but nothing was ready to send"
78
+ end
79
+
80
+ def return(type, *args)
81
+ @queue << P(:byte, type, *args)
82
+ end
83
+
84
+ def expect(&block)
85
+ @expectation = block
86
+ end
87
+
88
+ def expect!
89
+ expect {}
90
+ end
91
+
92
+ def verifier(&block)
93
+ @host_key_verifier = BlockVerifier.new(block)
94
+ end
95
+
96
+ def configure_client(options)
97
+ @client_options = options
98
+ end
99
+
100
+ def configure_server(options)
101
+ @server_options = options
102
+ end
103
+
104
+ def hint(name, value=true)
105
+ @hints[name] = value
106
+ end
107
+ end
@@ -0,0 +1,3 @@
1
+ Host=test.test
2
+ Port =1234
3
+ Compression yes
@@ -0,0 +1,8 @@
1
+ Host other.host
2
+ Compression no
3
+ Port 1231
4
+
5
+ Host test.host
6
+ Compression yes
7
+ ForwardAgent yes
8
+ Port 1234
@@ -0,0 +1,10 @@
1
+ # Jump through hosts with one SSH call
2
+ # via <http://glandium.org/blog/?p=308>
3
+ Host *+*
4
+ ProxyCommand ssh $(echo %h | sed 's/+[^+]*$//;s/\([^+%%]*\)%%\([^+]*\)$/\2 -l \1/;s/:/ -p /') PATH=.:\$PATH nc -w1 $(echo %h | sed 's/^.*+//;/:/!s/$/ %p/;s/:/ /')
5
+
6
+ Host office-offsite
7
+ HostName work-gateway+office-workstation
8
+
9
+ Host test.host
10
+ Compression yes
@@ -0,0 +1,4 @@
1
+ Host other.host test.host
2
+ Compression yes
3
+ Port 1980
4
+ RekeyLimit 2G
@@ -0,0 +1,19 @@
1
+
2
+ IdentityFile ~/.ssh/id_dsa
3
+ IdentityFile ~/.ssh/id_rsa
4
+ Port 1980
5
+
6
+ Host test.host
7
+ Port 1985
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
@@ -0,0 +1,4 @@
1
+ Host 1234
2
+ Compression yes
3
+ Port 1980
4
+ RekeyLimit 2G
@@ -0,0 +1,14 @@
1
+ Host test.*
2
+ Port 1234
3
+ Compression no
4
+
5
+ Host tes?.host
6
+ Port 4321
7
+ ForwardAgent yes
8
+
9
+ Host *.hos?
10
+ IdentityFile ~/.ssh/id_dsa
11
+ Compression yes
12
+
13
+ Host k*.host
14
+ RekeyLimit 1G
@@ -0,0 +1,467 @@
1
+ require 'common'
2
+ require 'net/ssh/connection/channel'
3
+
4
+ module Connection
5
+
6
+ class TestChannel < Test::Unit::TestCase
7
+ include Net::SSH::Connection::Constants
8
+
9
+ def teardown
10
+ connection.test!
11
+ end
12
+
13
+ def test_constructor_should_set_defaults
14
+ assert_equal 0x10000, channel.local_maximum_packet_size
15
+ assert_equal 0x20000, channel.local_maximum_window_size
16
+ assert channel.pending_requests.empty?
17
+ end
18
+
19
+ def test_channel_properties
20
+ channel[:hello] = "some value"
21
+ assert_equal "some value", channel[:hello]
22
+ end
23
+
24
+ def test_exec_should_be_syntactic_sugar_for_a_channel_request
25
+ channel.expects(:send_channel_request).with("exec", :string, "ls").yields
26
+ found_block = false
27
+ channel.exec("ls") { found_block = true }
28
+ assert found_block, "expected block to be passed to send_channel_request"
29
+ end
30
+
31
+ def test_subsystem_should_be_syntactic_sugar_for_a_channel_request
32
+ channel.expects(:send_channel_request).with("subsystem", :string, "sftp").yields
33
+ found_block = false
34
+ channel.subsystem("sftp") { found_block = true }
35
+ assert found_block, "expected block to be passed to send_channel_request"
36
+ end
37
+
38
+ def test_request_pty_with_invalid_option_should_raise_error
39
+ assert_raises(ArgumentError) do
40
+ channel.request_pty(:bogus => "thing")
41
+ end
42
+ end
43
+
44
+ def test_request_pty_without_options_should_use_defaults
45
+ channel.expects(:send_channel_request).with("pty-req", :string, "xterm",
46
+ :long, 80, :long, 24, :long, 640, :long, 480, :string, "\0").yields
47
+ found_block = false
48
+ channel.request_pty { found_block = true }
49
+ assert found_block, "expected block to be passed to send_channel_request"
50
+ end
51
+
52
+ def test_request_pty_with_options_should_honor_options
53
+ channel.expects(:send_channel_request).with("pty-req", :string, "vanilla",
54
+ :long, 60, :long, 15, :long, 400, :long, 200, :string, "\5\0\0\0\1\0")
55
+ channel.request_pty :term => "vanilla", :chars_wide => 60, :chars_high => 15,
56
+ :pixels_wide => 400, :pixels_high => 200, :modes => { 5 => 1 }
57
+ end
58
+
59
+ def test_send_data_should_append_to_channels_output_buffer
60
+ channel.send_data("hello")
61
+ assert_equal "hello", channel.output.to_s
62
+ channel.send_data("world")
63
+ assert_equal "helloworld", channel.output.to_s
64
+ end
65
+
66
+ def test_close_before_channel_has_been_confirmed_should_do_nothing
67
+ assert !channel.closing?
68
+ channel.close
69
+ assert !channel.closing?
70
+ end
71
+
72
+ def test_close_should_set_closing_and_send_message
73
+ channel.do_open_confirmation(0, 100, 100)
74
+ assert !channel.closing?
75
+
76
+ connection.expect { |t,packet| assert_equal CHANNEL_CLOSE, packet.type }
77
+ channel.close
78
+
79
+ assert channel.closing?
80
+ end
81
+
82
+ def test_close_while_closing_should_do_nothing
83
+ test_close_should_set_closing_and_send_message
84
+ assert_nothing_raised { channel.close }
85
+ end
86
+
87
+ def test_process_when_process_callback_is_not_set_should_just_enqueue_data
88
+ channel.expects(:enqueue_pending_output)
89
+ channel.process
90
+ end
91
+
92
+ def test_process_when_process_callback_is_set_should_yield_self_before_enqueuing_data
93
+ channel.expects(:enqueue_pending_output).never
94
+ channel.on_process { |ch| ch.expects(:enqueue_pending_output).once }
95
+ channel.process
96
+ end
97
+
98
+ def test_enqueue_pending_output_should_have_no_effect_if_channel_has_not_been_confirmed
99
+ channel.send_data("hello")
100
+ assert_nothing_raised { channel.enqueue_pending_output }
101
+ end
102
+
103
+ def test_enqueue_pending_output_should_have_no_effect_if_there_is_no_output
104
+ channel.do_open_confirmation(0, 100, 100)
105
+ assert_nothing_raised { channel.enqueue_pending_output }
106
+ end
107
+
108
+ def test_enqueue_pending_output_should_not_enqueue_more_than_output_length
109
+ channel.do_open_confirmation(0, 100, 100)
110
+ channel.send_data("hello world")
111
+
112
+ connection.expect do |t,packet|
113
+ assert_equal CHANNEL_DATA, packet.type
114
+ assert_equal 0, packet[:local_id]
115
+ assert_equal 11, packet[:data].length
116
+ end
117
+
118
+ channel.enqueue_pending_output
119
+ end
120
+
121
+ def test_enqueue_pending_output_should_not_enqueue_more_than_max_packet_length_at_once
122
+ channel.do_open_confirmation(0, 100, 8)
123
+ channel.send_data("hello world")
124
+
125
+ connection.expect do |t,packet|
126
+ assert_equal CHANNEL_DATA, packet.type
127
+ assert_equal 0, packet[:local_id]
128
+ assert_equal "hello wo", packet[:data]
129
+
130
+ t.expect do |t2,packet2|
131
+ assert_equal CHANNEL_DATA, packet2.type
132
+ assert_equal 0, packet2[:local_id]
133
+ assert_equal "rld", packet2[:data]
134
+ end
135
+ end
136
+
137
+ channel.enqueue_pending_output
138
+ end
139
+
140
+ def test_enqueue_pending_output_should_not_enqueue_more_than_max_window_size
141
+ channel.do_open_confirmation(0, 8, 100)
142
+ channel.send_data("hello world")
143
+
144
+ connection.expect do |t,packet|
145
+ assert_equal CHANNEL_DATA, packet.type
146
+ assert_equal 0, packet[:local_id]
147
+ assert_equal "hello wo", packet[:data]
148
+ end
149
+
150
+ channel.enqueue_pending_output
151
+ end
152
+
153
+ def test_on_data_with_block_should_set_callback
154
+ flag = false
155
+ channel.on_data { flag = !flag }
156
+ channel.do_data("")
157
+ assert(flag, "callback should have been invoked")
158
+ channel.on_data
159
+ channel.do_data("")
160
+ assert(flag, "callback should have been removed")
161
+ end
162
+
163
+ def test_on_extended_data_with_block_should_set_callback
164
+ flag = false
165
+ channel.on_extended_data { flag = !flag }
166
+ channel.do_extended_data(0, "")
167
+ assert(flag, "callback should have been invoked")
168
+ channel.on_extended_data
169
+ channel.do_extended_data(0, "")
170
+ assert(flag, "callback should have been removed")
171
+ end
172
+
173
+ def test_on_process_with_block_should_set_callback
174
+ flag = false
175
+ channel.on_process { flag = !flag }
176
+ channel.process
177
+ assert(flag, "callback should have been invoked")
178
+ channel.on_process
179
+ channel.process
180
+ assert(flag, "callback should have been removed")
181
+ end
182
+
183
+ def test_on_close_with_block_should_set_callback
184
+ flag = false
185
+ channel.on_close { flag = !flag }
186
+ channel.do_close
187
+ assert(flag, "callback should have been invoked")
188
+ channel.on_close
189
+ channel.do_close
190
+ assert(flag, "callback should have been removed")
191
+ end
192
+
193
+ def test_on_eof_with_block_should_set_callback
194
+ flag = false
195
+ channel.on_eof { flag = !flag }
196
+ channel.do_eof
197
+ assert(flag, "callback should have been invoked")
198
+ channel.on_eof
199
+ channel.do_eof
200
+ assert(flag, "callback should have been removed")
201
+ end
202
+
203
+ def test_do_request_for_unhandled_request_should_do_nothing_if_not_wants_reply
204
+ channel.do_open_confirmation(0, 100, 100)
205
+ assert_nothing_raised { channel.do_request "exit-status", false, nil }
206
+ end
207
+
208
+ def test_do_request_for_unhandled_request_should_send_CHANNEL_FAILURE_if_wants_reply
209
+ channel.do_open_confirmation(0, 100, 100)
210
+ connection.expect { |t,packet| assert_equal CHANNEL_FAILURE, packet.type }
211
+ channel.do_request "keepalive@openssh.com", true, nil
212
+ end
213
+
214
+ def test_do_request_for_handled_request_should_invoke_callback_and_do_nothing_if_returns_true_and_not_wants_reply
215
+ channel.do_open_confirmation(0, 100, 100)
216
+ flag = false
217
+ channel.on_request("exit-status") { flag = true; true }
218
+ assert_nothing_raised { channel.do_request "exit-status", false, nil }
219
+ assert flag, "callback should have been invoked"
220
+ end
221
+
222
+ def test_do_request_for_handled_request_should_invoke_callback_and_do_nothing_if_fails_and_not_wants_reply
223
+ channel.do_open_confirmation(0, 100, 100)
224
+ flag = false
225
+ channel.on_request("exit-status") { flag = true; raise Net::SSH::ChannelRequestFailed }
226
+ assert_nothing_raised { channel.do_request "exit-status", false, nil }
227
+ assert flag, "callback should have been invoked"
228
+ end
229
+
230
+ def test_do_request_for_handled_request_should_invoke_callback_and_send_CHANNEL_SUCCESS_if_returns_true_and_wants_reply
231
+ channel.do_open_confirmation(0, 100, 100)
232
+ flag = false
233
+ channel.on_request("exit-status") { flag = true; true }
234
+ connection.expect { |t,p| assert_equal CHANNEL_SUCCESS, p.type }
235
+ assert_nothing_raised { channel.do_request "exit-status", true, nil }
236
+ assert flag, "callback should have been invoked"
237
+ end
238
+
239
+ def test_do_request_for_handled_request_should_invoke_callback_and_send_CHANNEL_FAILURE_if_returns_false_and_wants_reply
240
+ channel.do_open_confirmation(0, 100, 100)
241
+ flag = false
242
+ channel.on_request("exit-status") { flag = true; raise Net::SSH::ChannelRequestFailed }
243
+ connection.expect { |t,p| assert_equal CHANNEL_FAILURE, p.type }
244
+ assert_nothing_raised { channel.do_request "exit-status", true, nil }
245
+ assert flag, "callback should have been invoked"
246
+ end
247
+
248
+ def test_send_channel_request_without_callback_should_not_want_reply
249
+ channel.do_open_confirmation(0, 100, 100)
250
+ connection.expect do |t,p|
251
+ assert_equal CHANNEL_REQUEST, p.type
252
+ assert_equal 0, p[:local_id]
253
+ assert_equal "exec", p[:request]
254
+ assert_equal false, p[:want_reply]
255
+ assert_equal "ls", p[:request_data].read_string
256
+ end
257
+ channel.send_channel_request("exec", :string, "ls")
258
+ assert channel.pending_requests.empty?
259
+ end
260
+
261
+ def test_send_channel_request_with_callback_should_want_reply
262
+ channel.do_open_confirmation(0, 100, 100)
263
+ connection.expect do |t,p|
264
+ assert_equal CHANNEL_REQUEST, p.type
265
+ assert_equal 0, p[:local_id]
266
+ assert_equal "exec", p[:request]
267
+ assert_equal true, p[:want_reply]
268
+ assert_equal "ls", p[:request_data].read_string
269
+ end
270
+ callback = Proc.new {}
271
+ channel.send_channel_request("exec", :string, "ls", &callback)
272
+ assert_equal [callback], channel.pending_requests
273
+ end
274
+
275
+ def test_do_open_confirmation_should_set_remote_parameters
276
+ channel.do_open_confirmation(1, 2, 3)
277
+ assert_equal 1, channel.remote_id
278
+ assert_equal 2, channel.remote_window_size
279
+ assert_equal 2, channel.remote_maximum_window_size
280
+ assert_equal 3, channel.remote_maximum_packet_size
281
+ end
282
+
283
+ def test_do_open_confirmation_should_call_open_confirmation_callback
284
+ flag = false
285
+ channel { flag = true }
286
+ assert !flag, "callback should not have been invoked yet"
287
+ channel.do_open_confirmation(1,2,3)
288
+ assert flag, "callback should have been invoked"
289
+ end
290
+
291
+ def test_do_open_confirmation_with_session_channel_should_invoke_agent_forwarding_if_agent_forwarding_requested
292
+ connection :forward_agent => true
293
+ forward = mock("forward")
294
+ forward.expects(:agent).with(channel)
295
+ connection.expects(:forward).returns(forward)
296
+ channel.do_open_confirmation(1,2,3)
297
+ end
298
+
299
+ def test_do_open_confirmation_with_non_session_channel_should_not_invoke_agent_forwarding_even_if_agent_forwarding_requested
300
+ connection :forward_agent => true
301
+ channel :type => "direct-tcpip"
302
+ connection.expects(:forward).never
303
+ channel.do_open_confirmation(1,2,3)
304
+ end
305
+
306
+ def test_do_window_adjust_should_adjust_remote_window_size_by_the_given_amount
307
+ channel.do_open_confirmation(0, 1000, 1000)
308
+ assert_equal 1000, channel.remote_window_size
309
+ assert_equal 1000, channel.remote_maximum_window_size
310
+ channel.do_window_adjust(500)
311
+ assert_equal 1500, channel.remote_window_size
312
+ assert_equal 1500, channel.remote_maximum_window_size
313
+ end
314
+
315
+ def test_do_data_should_update_local_window_size
316
+ assert_equal 0x20000, channel.local_maximum_window_size
317
+ assert_equal 0x20000, channel.local_window_size
318
+ channel.do_data("here is some data")
319
+ assert_equal 0x20000, channel.local_maximum_window_size
320
+ assert_equal 0x1FFEF, channel.local_window_size
321
+ end
322
+
323
+ def test_do_extended_data_should_update_local_window_size
324
+ assert_equal 0x20000, channel.local_maximum_window_size
325
+ assert_equal 0x20000, channel.local_window_size
326
+ channel.do_extended_data(1, "here is some data")
327
+ assert_equal 0x20000, channel.local_maximum_window_size
328
+ assert_equal 0x1FFEF, channel.local_window_size
329
+ end
330
+
331
+ def test_do_data_when_local_window_size_drops_below_threshold_should_trigger_WINDOW_ADJUST_message
332
+ channel.do_open_confirmation(0, 1000, 1000)
333
+ assert_equal 0x20000, channel.local_maximum_window_size
334
+ assert_equal 0x20000, channel.local_window_size
335
+
336
+ connection.expect do |t,p|
337
+ assert_equal CHANNEL_WINDOW_ADJUST, p.type
338
+ assert_equal 0, p[:local_id]
339
+ assert_equal 0x20000, p[:extra_bytes]
340
+ end
341
+
342
+ channel.do_data("." * 0x10001)
343
+ assert_equal 0x40000, channel.local_maximum_window_size
344
+ assert_equal 0x2FFFF, channel.local_window_size
345
+ end
346
+
347
+ def test_do_failure_should_grab_next_pending_request_and_call_it
348
+ result = nil
349
+ channel.pending_requests << Proc.new { |*args| result = args }
350
+ channel.do_failure
351
+ assert_equal [channel, false], result
352
+ assert channel.pending_requests.empty?
353
+ end
354
+
355
+ def test_do_success_should_grab_next_pending_request_and_call_it
356
+ result = nil
357
+ channel.pending_requests << Proc.new { |*args| result = args }
358
+ channel.do_success
359
+ assert_equal [channel, true], result
360
+ assert channel.pending_requests.empty?
361
+ end
362
+
363
+ def test_active_should_be_true_when_channel_appears_in_channel_list
364
+ connection.channels[channel.local_id] = channel
365
+ assert channel.active?
366
+ end
367
+
368
+ def test_active_should_be_false_when_channel_is_not_in_channel_list
369
+ assert !channel.active?
370
+ end
371
+
372
+ def test_wait_should_block_while_channel_is_active?
373
+ channel.expects(:active?).times(3).returns(true,true,false)
374
+ channel.wait
375
+ end
376
+
377
+ def test_eof_bang_should_send_eof_to_server
378
+ channel.do_open_confirmation(0, 1000, 1000)
379
+ connection.expect { |t,p| assert_equal CHANNEL_EOF, p.type }
380
+ channel.eof!
381
+ channel.process
382
+ end
383
+
384
+ def test_eof_bang_should_not_send_eof_if_eof_was_already_declared
385
+ channel.do_open_confirmation(0, 1000, 1000)
386
+ connection.expect { |t,p| assert_equal CHANNEL_EOF, p.type }
387
+ channel.eof!
388
+ assert_nothing_raised { channel.eof! }
389
+ channel.process
390
+ end
391
+
392
+ def test_eof_q_should_return_true_if_eof_declared
393
+ channel.do_open_confirmation(0, 1000, 1000)
394
+ connection.expect { |t,p| assert_equal CHANNEL_EOF, p.type }
395
+
396
+ assert !channel.eof?
397
+ channel.eof!
398
+ assert channel.eof?
399
+ channel.process
400
+ end
401
+
402
+ def test_send_data_should_raise_exception_if_eof_declared
403
+ channel.do_open_confirmation(0, 1000, 1000)
404
+ connection.expect { |t,p| assert_equal CHANNEL_EOF, p.type }
405
+ channel.eof!
406
+ channel.process
407
+ assert_raises(EOFError) { channel.send_data("die! die! die!") }
408
+ end
409
+
410
+ def test_data_should_precede_eof
411
+ channel.do_open_confirmation(0, 1000, 1000)
412
+ connection.expect do |t,p|
413
+ assert_equal CHANNEL_DATA, p.type
414
+ connection.expect { |t,p| assert_equal CHANNEL_EOF, p.type }
415
+ end
416
+ channel.send_data "foo"
417
+ channel.eof!
418
+ channel.process
419
+ end
420
+
421
+ private
422
+
423
+ class MockConnection
424
+ attr_reader :logger
425
+ attr_reader :options
426
+ attr_reader :channels
427
+
428
+ def initialize(options={})
429
+ @expectation = nil
430
+ @options = options
431
+ @channels = {}
432
+ end
433
+
434
+ def expect(&block)
435
+ @expectation = block
436
+ end
437
+
438
+ def send_message(msg)
439
+ raise "#{msg.to_s.inspect} recieved but no message was expected" unless @expectation
440
+ packet = Net::SSH::Packet.new(msg.to_s)
441
+ callback, @expectation = @expectation, nil
442
+ callback.call(self, packet)
443
+ end
444
+
445
+ alias loop_forever loop
446
+ def loop(&block)
447
+ loop_forever { break unless block.call }
448
+ end
449
+
450
+ def test!
451
+ raise "expected a packet but none were sent" if @expectation
452
+ end
453
+ end
454
+
455
+ def connection(options={})
456
+ @connection ||= MockConnection.new(options)
457
+ end
458
+
459
+ def channel(options={}, &block)
460
+ @channel ||= Net::SSH::Connection::Channel.new(connection(options),
461
+ options[:type] || "session",
462
+ options[:local_id] || 0,
463
+ &block)
464
+ end
465
+ end
466
+
467
+ end