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,48 @@
1
+ require "common"
2
+
3
+ class FileFactoryTest < Net::SFTP::TestCase
4
+ def setup
5
+ @sftp = stub(:sftp)
6
+ @factory = Net::SFTP::Operations::FileFactory.new(@sftp)
7
+ end
8
+
9
+ def test_open_with_block_should_yield_and_close_handle
10
+ @sftp.expects(:open!).with("/path/to/remote", "r", :permissions => nil).returns("handle")
11
+ @sftp.expects(:close!).with("handle")
12
+
13
+ called = false
14
+ @factory.open("/path/to/remote") do |f|
15
+ called = true
16
+ assert_instance_of Net::SFTP::Operations::File, f
17
+ end
18
+
19
+ assert called
20
+ end
21
+
22
+ def test_open_with_block_should_close_file_even_if_exception_is_raised
23
+ @sftp.expects(:open!).with("/path/to/remote", "r", :permissions => nil).returns("handle")
24
+ @sftp.expects(:close!).with("handle")
25
+
26
+ assert_raises(RuntimeError) do
27
+ @factory.open("/path/to/remote") { |f| raise RuntimeError, "b00m" }
28
+ end
29
+ end
30
+
31
+ def test_open_without_block_should_return_new_file
32
+ @sftp.expects(:open!).with("/path/to/remote", "r", :permissions => nil).returns("handle")
33
+ @sftp.expects(:close!).never
34
+
35
+ f = @factory.open("/path/to/remote")
36
+ assert_instance_of Net::SFTP::Operations::File, f
37
+ end
38
+
39
+ def test_directory_should_be_true_for_directory
40
+ @sftp.expects(:lstat!).with("/path/to/dir").returns(mock('attrs', :directory? => true))
41
+ assert @factory.directory?("/path/to/dir")
42
+ end
43
+
44
+ def test_directory_should_be_false_for_non_directory
45
+ @sftp.expects(:lstat!).with("/path/to/file").returns(mock('attrs', :directory? => false))
46
+ assert !@factory.directory?("/path/to/file")
47
+ end
48
+ end
@@ -0,0 +1,9 @@
1
+ require 'common'
2
+
3
+ class PacketTest < Net::SFTP::TestCase
4
+ def test_packet_should_auto_read_type_byte
5
+ packet = Net::SFTP::Packet.new("\001rest-of-packet-here")
6
+ assert_equal 1, packet.type
7
+ assert_equal "rest-of-packet-here", packet.content[packet.position..-1]
8
+ end
9
+ end
@@ -0,0 +1,17 @@
1
+ require 'common'
2
+
3
+ class ProtocolTest < Net::SFTP::TestCase
4
+ 1.upto(6) do |version|
5
+ define_method("test_load_version_#{version}_should_return_v#{version}_driver") do
6
+ session = stub('session', :logger => nil)
7
+ driver = Net::SFTP::Protocol.load(session, version)
8
+ assert_instance_of Net::SFTP::Protocol.const_get("V%02d" % version)::Base, driver
9
+ end
10
+ end
11
+
12
+ def test_load_version_7_should_be_unsupported
13
+ assert_raises(NotImplementedError) do
14
+ Net::SFTP::Protocol.load(stub('session'), 7)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,71 @@
1
+ require 'common'
2
+
3
+ class RequestTest < Net::SFTP::TestCase
4
+ def test_property_setter_should_symbolize_key
5
+ request = Net::SFTP::Request.new(stub("session"), :open, 1)
6
+ request["key"] = :value
7
+ assert_equal :value, request['key']
8
+ assert_equal :value, request[:key]
9
+ assert_equal :value, request.properties[:key]
10
+ assert_nil request.properties['key']
11
+ end
12
+
13
+ def test_pending_should_query_pending_requests_of_session
14
+ session = stub("session", :pending_requests => {1 => true})
15
+ request = Net::SFTP::Request.new(session, :open, 1)
16
+ assert request.pending?
17
+ request = Net::SFTP::Request.new(session, :open, 2)
18
+ assert !request.pending?
19
+ end
20
+
21
+ def test_wait_should_run_loop_while_pending_and_return_self
22
+ session = MockSession.new
23
+ request = Net::SFTP::Request.new(session, :open, 1)
24
+ request.expects(:pending?).times(4).returns(true, true, true, false)
25
+ assert_equal 0, session.loops
26
+ assert_equal request, request.wait
27
+ assert_equal 4, session.loops
28
+ end
29
+
30
+ def test_respond_to_should_set_response_property
31
+ packet = stub("packet", :type => 1)
32
+ session = stub("session", :protocol => mock("protocol"))
33
+ session.protocol.expects(:parse).with(packet).returns({})
34
+ request = Net::SFTP::Request.new(session, :open, 1)
35
+ assert_nil request.response
36
+ request.respond_to(packet)
37
+ assert_instance_of Net::SFTP::Response, request.response
38
+ end
39
+
40
+ def test_respond_to_with_callback_should_invoke_callback
41
+ packet = stub("packet", :type => 1)
42
+ session = stub("session", :protocol => mock("protocol"))
43
+ session.protocol.expects(:parse).with(packet).returns({})
44
+
45
+ called = false
46
+ request = Net::SFTP::Request.new(session, :open, 1) do |response|
47
+ called = true
48
+ assert_equal request.response, response
49
+ end
50
+
51
+ request.respond_to(packet)
52
+ assert called
53
+ end
54
+
55
+ private
56
+
57
+ class MockSession
58
+ attr_reader :loops
59
+
60
+ def initialize
61
+ @loops = 0
62
+ end
63
+
64
+ def loop
65
+ while true
66
+ @loops += 1
67
+ break unless yield
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,53 @@
1
+ require 'common'
2
+
3
+ class ResponseTest < Net::SFTP::TestCase
4
+ def test_code_should_default_to_FX_OK
5
+ response = Net::SFTP::Response.new(mock("response"))
6
+ assert_equal Net::SFTP::Response::FX_OK, response.code
7
+ end
8
+
9
+ def test_brackets_should_symbolize_key
10
+ response = Net::SFTP::Response.new(mock("response"), :handle => "foo")
11
+ assert_equal "foo", response['handle']
12
+ end
13
+
14
+ def test_to_s_with_nil_message_should_show_default_message
15
+ response = Net::SFTP::Response.new(mock("response"), :code => 14)
16
+ assert_equal "no space on filesystem (14)", response.to_s
17
+ end
18
+
19
+ def test_to_s_with_empty_message_should_show_default_message
20
+ response = Net::SFTP::Response.new(mock("response"), :code => 14, :message => "")
21
+ assert_equal "no space on filesystem (14)", response.to_s
22
+ end
23
+
24
+ def test_to_s_with_default_message_should_show_default_message
25
+ response = Net::SFTP::Response.new(mock("response"), :code => 14, :message => "no space on filesystem")
26
+ assert_equal "no space on filesystem (14)", response.to_s
27
+ end
28
+
29
+ def test_to_s_with_explicit_message_should_show_explicit_message
30
+ response = Net::SFTP::Response.new(mock("response"), :code => 14, :message => "out of space")
31
+ assert_equal "out of space (no space on filesystem, 14)", response.to_s
32
+ end
33
+
34
+ def test_ok_should_be_true_when_code_is_FX_OK
35
+ response = Net::SFTP::Response.new(mock("response"))
36
+ assert_equal true, response.ok?
37
+ end
38
+
39
+ def test_ok_should_be_false_when_code_is_not_FX_OK
40
+ response = Net::SFTP::Response.new(mock("response"), :code => 14)
41
+ assert_equal false, response.ok?
42
+ end
43
+
44
+ def test_eof_should_be_true_when_code_is_FX_EOF
45
+ response = Net::SFTP::Response.new(mock("response"), :code => 1)
46
+ assert_equal true, response.eof?
47
+ end
48
+
49
+ def test_eof_should_be_false_when_code_is_not_FX_EOF
50
+ response = Net::SFTP::Response.new(mock("response"), :code => 14)
51
+ assert_equal false, response.eof?
52
+ end
53
+ end
@@ -0,0 +1,741 @@
1
+ require "common"
2
+
3
+ class SessionTest < Net::SFTP::TestCase
4
+ include Net::SFTP::Constants
5
+ include Net::SFTP::Constants::OpenFlags
6
+ include Net::SFTP::Constants::PacketTypes
7
+
8
+ (1..6).each do |version|
9
+ define_method("test_server_reporting_version_#{version}_should_cause_version_#{version}_to_be_used") do
10
+ expect_sftp_session :server_version => version
11
+ assert_scripted { sftp.connect! }
12
+ assert_equal version, sftp.protocol.version
13
+ end
14
+ end
15
+
16
+ def test_v1_open_read_only_that_succeeds_should_invoke_callback
17
+ expect_open("/path/to/file", "r", nil, :server_version => 1)
18
+ assert_successful_open("/path/to/file")
19
+ end
20
+
21
+ def test_v1_open_read_only_that_fails_should_invoke_callback
22
+ expect_open("/path/to/file", "r", nil, :server_version => 1, :fail => 2)
23
+
24
+ assert_command_with_callback(:open, "/path/to/file") do |response|
25
+ assert !response.ok?
26
+ assert_equal 2, response.code
27
+ end
28
+ end
29
+
30
+ def test_v1_open_write_only_that_succeeds_should_invoke_callback
31
+ expect_open("/path/to/file", "w", nil, :server_version => 1)
32
+ assert_successful_open("/path/to/file", "w")
33
+ end
34
+
35
+ def test_v1_open_read_write_that_succeeds_should_invoke_callback
36
+ expect_open("/path/to/file", "rw", nil, :server_version => 1)
37
+ assert_successful_open("/path/to/file", "r+")
38
+ end
39
+
40
+ def test_v1_open_append_that_succeeds_should_invoke_callback
41
+ expect_open("/path/to/file", "a", nil, :server_version => 1)
42
+ assert_successful_open("/path/to/file", "a")
43
+ end
44
+
45
+ def test_v1_open_with_permissions_should_specify_permissions
46
+ expect_open("/path/to/file", "r", 0765, :server_version => 1)
47
+ assert_successful_open("/path/to/file", "r", :permissions => 0765)
48
+ end
49
+
50
+ def test_v4_open_with_permissions_should_specify_permissions
51
+ expect_open("/path/to/file", "r", 0765, :server_version => 4)
52
+ assert_successful_open("/path/to/file", "r", :permissions => 0765)
53
+ end
54
+
55
+ def test_v5_open_read_only_shuld_invoke_callback
56
+ expect_open("/path/to/file", "r", 0765, :server_version => 5)
57
+ assert_successful_open("/path/to/file", "r", :permissions => 0765)
58
+ end
59
+
60
+ def test_v6_open_with_permissions_should_specify_permissions
61
+ expect_open("/path/to/file", "r", 0765, :server_version => 6)
62
+ assert_successful_open("/path/to/file", "r", :permissions => 0765)
63
+ end
64
+
65
+ def test_open_bang_should_block_and_return_handle
66
+ expect_open("/path/to/file", "r", nil)
67
+ handle = assert_synchronous_command(:open!, "/path/to/file", "r")
68
+ assert_equal "handle", handle
69
+ end
70
+
71
+ def test_open_bang_should_block_and_raise_exception_on_error
72
+ expect_open("/path/to/file", "r", nil, :fail => 5)
73
+ assert_raises(Net::SFTP::StatusException) do
74
+ assert_synchronous_command(:open!, "/path/to/file", "r")
75
+ end
76
+ end
77
+
78
+ def test_close_should_send_close_request_and_invoke_callback
79
+ expect_sftp_session do |channel|
80
+ channel.sends_packet(FXP_CLOSE, :long, 0, :string, "handle")
81
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
82
+ end
83
+
84
+ assert_command_with_callback(:close, "handle") { |r| assert r.ok? }
85
+ end
86
+
87
+ def test_close_bang_should_block_and_return_response
88
+ expect_sftp_session do |channel|
89
+ channel.sends_packet(FXP_CLOSE, :long, 0, :string, "handle")
90
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
91
+ end
92
+
93
+ response = assert_synchronous_command(:close!, "handle")
94
+ assert response.ok?
95
+ end
96
+
97
+ def test_read_should_send_read_request_and_invoke_callback
98
+ expect_sftp_session do |channel|
99
+ channel.sends_packet(FXP_READ, :long, 0, :string, "handle", :int64, 512123, :long, 1024)
100
+ channel.gets_packet(FXP_DATA, :long, 0, :string, "this is some data!")
101
+ end
102
+
103
+ assert_command_with_callback(:read, "handle", 512123, 1024) do |response|
104
+ assert response.ok?
105
+ assert_equal "this is some data!", response[:data]
106
+ end
107
+ end
108
+
109
+ def test_read_bang_should_block_and_return_data
110
+ expect_sftp_session do |channel|
111
+ channel.sends_packet(FXP_READ, :long, 0, :string, "handle", :int64, 512123, :long, 1024)
112
+ channel.gets_packet(FXP_DATA, :long, 0, :string, "this is some data!")
113
+ end
114
+
115
+ data = assert_synchronous_command(:read!, "handle", 512123, 1024)
116
+ assert_equal "this is some data!", data
117
+ end
118
+
119
+ def test_read_bang_should_block_and_return_nil_on_eof
120
+ expect_sftp_session do |channel|
121
+ channel.sends_packet(FXP_READ, :long, 0, :string, "handle", :int64, 512123, :long, 1024)
122
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 1)
123
+ end
124
+
125
+ data = assert_synchronous_command(:read!, "handle", 512123, 1024)
126
+ assert_nil data
127
+ end
128
+
129
+ def test_write_should_send_write_request_and_invoke_callback
130
+ expect_sftp_session do |channel|
131
+ channel.sends_packet(FXP_WRITE, :long, 0, :string, "handle", :int64, 512123, :string, "this is some data!")
132
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
133
+ end
134
+
135
+ assert_command_with_callback(:write, "handle", 512123, "this is some data!") do |response|
136
+ assert response.ok?
137
+ end
138
+ end
139
+
140
+ def test_write_bang_should_block_and_return_response
141
+ expect_sftp_session do |channel|
142
+ channel.sends_packet(FXP_WRITE, :long, 0, :string, "handle", :int64, 512123, :string, "this is some data!")
143
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
144
+ end
145
+
146
+ response = assert_synchronous_command(:write!, "handle", 512123, "this is some data!")
147
+ assert response.ok?
148
+ end
149
+
150
+ def test_v1_lstat_should_send_lstat_request_and_invoke_callback
151
+ expect_sftp_session :server_version => 1 do |channel|
152
+ channel.sends_packet(FXP_LSTAT, :long, 0, :string, "/path/to/file")
153
+ channel.gets_packet(FXP_ATTRS, :long, 0, :long, 0xF, :int64, 123456, :long, 1, :long, 2, :long, 0765, :long, 123456789, :long, 234567890)
154
+ end
155
+
156
+ assert_command_with_callback(:lstat, "/path/to/file") do |response|
157
+ assert response.ok?
158
+ assert_equal 123456, response[:attrs].size
159
+ assert_equal 1, response[:attrs].uid
160
+ assert_equal 2, response[:attrs].gid
161
+ assert_equal 0765, response[:attrs].permissions
162
+ assert_equal 123456789, response[:attrs].atime
163
+ assert_equal 234567890, response[:attrs].mtime
164
+ end
165
+ end
166
+
167
+ def test_v4_lstat_should_send_default_flags_parameter
168
+ expect_sftp_session :server_version => 4 do |channel|
169
+ channel.sends_packet(FXP_LSTAT, :long, 0, :string, "/path/to/file", :long, 0x800001fd)
170
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 2)
171
+ end
172
+
173
+ assert_command_with_callback(:lstat, "/path/to/file")
174
+ end
175
+
176
+ def test_v4_lstat_should_honor_flags_parameter
177
+ expect_sftp_session :server_version => 4 do |channel|
178
+ channel.sends_packet(FXP_LSTAT, :long, 0, :string, "/path/to/file", :long, 0x1)
179
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 2)
180
+ end
181
+
182
+ assert_command_with_callback(:lstat, "/path/to/file", 0x1)
183
+ end
184
+
185
+ def test_lstat_bang_should_block_and_return_attrs
186
+ expect_sftp_session :server_version => 1 do |channel|
187
+ channel.sends_packet(FXP_LSTAT, :long, 0, :string, "/path/to/file")
188
+ channel.gets_packet(FXP_ATTRS, :long, 0, :long, 0xF, :int64, 123456, :long, 1, :long, 2, :long, 0765, :long, 123456789, :long, 234567890)
189
+ end
190
+
191
+ attrs = assert_synchronous_command(:lstat!, "/path/to/file")
192
+
193
+ assert_equal 123456, attrs.size
194
+ assert_equal 1, attrs.uid
195
+ assert_equal 2, attrs.gid
196
+ assert_equal 0765, attrs.permissions
197
+ assert_equal 123456789, attrs.atime
198
+ assert_equal 234567890, attrs.mtime
199
+ end
200
+
201
+ def test_v1_fstat_should_send_fstat_request_and_invoke_callback
202
+ expect_sftp_session :server_version => 1 do |channel|
203
+ channel.sends_packet(FXP_FSTAT, :long, 0, :string, "handle")
204
+ channel.gets_packet(FXP_ATTRS, :long, 0, :long, 0xF, :int64, 123456, :long, 1, :long, 2, :long, 0765, :long, 123456789, :long, 234567890)
205
+ end
206
+
207
+ assert_command_with_callback(:fstat, "handle") do |response|
208
+ assert response.ok?
209
+ assert_equal 123456, response[:attrs].size
210
+ assert_equal 1, response[:attrs].uid
211
+ assert_equal 2, response[:attrs].gid
212
+ assert_equal 0765, response[:attrs].permissions
213
+ assert_equal 123456789, response[:attrs].atime
214
+ assert_equal 234567890, response[:attrs].mtime
215
+ end
216
+ end
217
+
218
+ def test_v4_fstat_should_send_default_flags_parameter
219
+ expect_sftp_session :server_version => 4 do |channel|
220
+ channel.sends_packet(FXP_FSTAT, :long, 0, :string, "handle", :long, 0x800001fd)
221
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 2)
222
+ end
223
+
224
+ assert_command_with_callback(:fstat, "handle")
225
+ end
226
+
227
+ def test_v4_fstat_should_honor_flags_parameter
228
+ expect_sftp_session :server_version => 4 do |channel|
229
+ channel.sends_packet(FXP_FSTAT, :long, 0, :string, "handle", :long, 0x1)
230
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 2)
231
+ end
232
+
233
+ assert_command_with_callback(:fstat, "handle", 0x1)
234
+ end
235
+
236
+ def test_fstat_bang_should_block_and_return_attrs
237
+ expect_sftp_session :server_version => 1 do |channel|
238
+ channel.sends_packet(FXP_FSTAT, :long, 0, :string, "handle")
239
+ channel.gets_packet(FXP_ATTRS, :long, 0, :long, 0xF, :int64, 123456, :long, 1, :long, 2, :long, 0765, :long, 123456789, :long, 234567890)
240
+ end
241
+
242
+ attrs = assert_synchronous_command(:fstat!, "handle")
243
+
244
+ assert_equal 123456, attrs.size
245
+ assert_equal 1, attrs.uid
246
+ assert_equal 2, attrs.gid
247
+ assert_equal 0765, attrs.permissions
248
+ assert_equal 123456789, attrs.atime
249
+ assert_equal 234567890, attrs.mtime
250
+ end
251
+
252
+ def test_v1_setstat_should_send_v1_attributes
253
+ expect_sftp_session :server_version => 1 do |channel|
254
+ channel.sends_packet(FXP_SETSTAT, :long, 0, :string, "/path/to/file", :long, 0xc, :long, 0765, :long, 1234567890, :long, 2345678901)
255
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
256
+ end
257
+
258
+ assert_command_with_callback(:setstat, "/path/to/file", :permissions => 0765, :atime => 1234567890, :mtime => 2345678901)
259
+ end
260
+
261
+ def test_v4_setstat_should_send_v4_attributes
262
+ expect_sftp_session :server_version => 4 do |channel|
263
+ channel.sends_packet(FXP_SETSTAT, :long, 0, :string, "/path/to/file", :long, 0x2c, :byte, 1, :long, 0765, :int64, 1234567890, :int64, 2345678901)
264
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
265
+ end
266
+
267
+ assert_command_with_callback(:setstat, "/path/to/file", :permissions => 0765, :atime => 1234567890, :mtime => 2345678901)
268
+ end
269
+
270
+ def test_v6_setstat_should_send_v6_attributes
271
+ expect_sftp_session :server_version => 6 do |channel|
272
+ channel.sends_packet(FXP_SETSTAT, :long, 0, :string, "/path/to/file", :long, 0x102c, :byte, 1, :long, 0765, :int64, 1234567890, :int64, 2345678901, :string, "text/plain")
273
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
274
+ end
275
+
276
+ assert_command_with_callback(:setstat, "/path/to/file", :permissions => 0765, :atime => 1234567890, :mtime => 2345678901, :mime_type => "text/plain")
277
+ end
278
+
279
+ def test_setstat_bang_should_block_and_return_response
280
+ expect_sftp_session :server_version => 1 do |channel|
281
+ channel.sends_packet(FXP_SETSTAT, :long, 0, :string, "/path/to/file", :long, 0xc, :long, 0765, :long, 1234567890, :long, 2345678901)
282
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
283
+ end
284
+
285
+ response = assert_synchronous_command(:setstat!, "/path/to/file", :permissions => 0765, :atime => 1234567890, :mtime => 2345678901)
286
+ assert response.ok?
287
+ end
288
+
289
+ def test_v1_fsetstat_should_send_v1_attributes
290
+ expect_sftp_session :server_version => 1 do |channel|
291
+ channel.sends_packet(FXP_FSETSTAT, :long, 0, :string, "handle", :long, 0xc, :long, 0765, :long, 1234567890, :long, 2345678901)
292
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
293
+ end
294
+
295
+ assert_command_with_callback(:fsetstat, "handle", :permissions => 0765, :atime => 1234567890, :mtime => 2345678901)
296
+ end
297
+
298
+ def test_v4_fsetstat_should_send_v4_attributes
299
+ expect_sftp_session :server_version => 4 do |channel|
300
+ channel.sends_packet(FXP_FSETSTAT, :long, 0, :string, "handle", :long, 0x2c, :byte, 1, :long, 0765, :int64, 1234567890, :int64, 2345678901)
301
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
302
+ end
303
+
304
+ assert_command_with_callback(:fsetstat, "handle", :permissions => 0765, :atime => 1234567890, :mtime => 2345678901)
305
+ end
306
+
307
+ def test_v6_fsetstat_should_send_v6_attributes
308
+ expect_sftp_session :server_version => 6 do |channel|
309
+ channel.sends_packet(FXP_FSETSTAT, :long, 0, :string, "handle", :long, 0x102c, :byte, 1, :long, 0765, :int64, 1234567890, :int64, 2345678901, :string, "text/plain")
310
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
311
+ end
312
+
313
+ assert_command_with_callback(:fsetstat, "handle", :permissions => 0765, :atime => 1234567890, :mtime => 2345678901, :mime_type => "text/plain")
314
+ end
315
+
316
+ def test_fsetstat_bang_should_block_and_return_response
317
+ expect_sftp_session :server_version => 1 do |channel|
318
+ channel.sends_packet(FXP_FSETSTAT, :long, 0, :string, "handle", :long, 0xc, :long, 0765, :long, 1234567890, :long, 2345678901)
319
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
320
+ end
321
+
322
+ response = assert_synchronous_command(:fsetstat!, "handle", :permissions => 0765, :atime => 1234567890, :mtime => 2345678901)
323
+ assert response.ok?
324
+ end
325
+
326
+ def test_opendir_should_send_opendir_request_and_invoke_callback
327
+ expect_sftp_session do |channel|
328
+ channel.sends_packet(FXP_OPENDIR, :long, 0, :string, "/path/to/dir")
329
+ channel.gets_packet(FXP_HANDLE, :long, 0, :string, "handle")
330
+ end
331
+
332
+ assert_command_with_callback(:opendir, "/path/to/dir")
333
+ end
334
+
335
+ def test_opendir_bang_should_block_and_return_handle
336
+ expect_sftp_session do |channel|
337
+ channel.sends_packet(FXP_OPENDIR, :long, 0, :string, "/path/to/dir")
338
+ channel.gets_packet(FXP_HANDLE, :long, 0, :string, "handle")
339
+ end
340
+
341
+ handle = assert_synchronous_command(:opendir!, "/path/to/dir")
342
+ assert_equal "handle", handle
343
+ end
344
+
345
+ def test_readdir_should_send_readdir_request_and_invoke_callback
346
+ expect_sftp_session do |channel|
347
+ channel.sends_packet(FXP_READDIR, :long, 0, :string, "handle")
348
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 1)
349
+ end
350
+
351
+ assert_command_with_callback(:readdir, "handle") { |r| assert r.eof? }
352
+ end
353
+
354
+ def test_readdir_bang_should_block_and_return_names_array
355
+ expect_sftp_session :server_version => 1 do |channel|
356
+ channel.sends_packet(FXP_READDIR, :long, 0, :string, "handle")
357
+ channel.gets_packet(FXP_NAME, :long, 0, :long, 2,
358
+ :string, "first", :string, "longfirst", :long, 0x0,
359
+ :string, "next", :string, "longnext", :long, 0x0)
360
+ end
361
+
362
+ names = assert_synchronous_command(:readdir!, "handle")
363
+ assert_equal 2, names.length
364
+ assert_equal %w(first next), names.map { |n| n.name }
365
+ end
366
+
367
+ def test_remove_should_send_remove_packet
368
+ expect_sftp_session do |channel|
369
+ channel.sends_packet(FXP_REMOVE, :long, 0, :string, "/path/to/file")
370
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
371
+ end
372
+
373
+ assert_command_with_callback(:remove, "/path/to/file")
374
+ end
375
+
376
+ def test_remove_bang_should_block_and_return_response
377
+ expect_sftp_session do |channel|
378
+ channel.sends_packet(FXP_REMOVE, :long, 0, :string, "/path/to/file")
379
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
380
+ end
381
+
382
+ response = assert_synchronous_command(:remove!, "/path/to/file")
383
+ assert response.ok?
384
+ end
385
+
386
+ def test_mkdir_should_send_mkdir_packet
387
+ expect_sftp_session do |channel|
388
+ channel.sends_packet(FXP_MKDIR, :long, 0, :string, "/path/to/dir", :long, 0x4, :byte, 1, :long, 0765)
389
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
390
+ end
391
+
392
+ assert_command_with_callback(:mkdir, "/path/to/dir", :permissions => 0765)
393
+ end
394
+
395
+ def test_mkdir_bang_should_block_and_return_response
396
+ expect_sftp_session do |channel|
397
+ channel.sends_packet(FXP_MKDIR, :long, 0, :string, "/path/to/dir", :long, 0x4, :byte, 1, :long, 0765)
398
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
399
+ end
400
+
401
+ response = assert_synchronous_command(:mkdir!, "/path/to/dir", :permissions => 0765)
402
+ assert response.ok?
403
+ end
404
+
405
+ def test_rmdir_should_send_rmdir_packet
406
+ expect_sftp_session do |channel|
407
+ channel.sends_packet(FXP_RMDIR, :long, 0, :string, "/path/to/dir")
408
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
409
+ end
410
+
411
+ assert_command_with_callback(:rmdir, "/path/to/dir")
412
+ end
413
+
414
+ def test_rmdir_bang_should_block_and_return_response
415
+ expect_sftp_session do |channel|
416
+ channel.sends_packet(FXP_RMDIR, :long, 0, :string, "/path/to/dir")
417
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
418
+ end
419
+
420
+ response = assert_synchronous_command(:rmdir!, "/path/to/dir")
421
+ assert response.ok?
422
+ end
423
+
424
+ def test_realpath_should_send_realpath_packet
425
+ expect_sftp_session do |channel|
426
+ channel.sends_packet(FXP_REALPATH, :long, 0, :string, "/path/to/dir")
427
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 2)
428
+ end
429
+
430
+ assert_command_with_callback(:realpath, "/path/to/dir")
431
+ end
432
+
433
+ def test_realpath_bang_should_block_and_return_names_item
434
+ expect_sftp_session do |channel|
435
+ channel.sends_packet(FXP_REALPATH, :long, 0, :string, "/path/to/dir")
436
+ channel.gets_packet(FXP_NAME, :long, 0, :long, 1, :string, "dir", :long, 0x0, :long, 2)
437
+ end
438
+
439
+ name = assert_synchronous_command(:realpath!, "/path/to/dir")
440
+ assert_equal "dir", name.name
441
+ end
442
+
443
+ def test_v1_stat_should_send_stat_request_and_invoke_callback
444
+ expect_sftp_session :server_version => 1 do |channel|
445
+ channel.sends_packet(FXP_STAT, :long, 0, :string, "/path/to/file")
446
+ channel.gets_packet(FXP_ATTRS, :long, 0, :long, 0xF, :int64, 123456, :long, 1, :long, 2, :long, 0765, :long, 123456789, :long, 234567890)
447
+ end
448
+
449
+ assert_command_with_callback(:stat, "/path/to/file") do |response|
450
+ assert response.ok?
451
+ assert_equal 123456, response[:attrs].size
452
+ assert_equal 1, response[:attrs].uid
453
+ assert_equal 2, response[:attrs].gid
454
+ assert_equal 0765, response[:attrs].permissions
455
+ assert_equal 123456789, response[:attrs].atime
456
+ assert_equal 234567890, response[:attrs].mtime
457
+ end
458
+ end
459
+
460
+ def test_v4_stat_should_send_default_flags_parameter
461
+ expect_sftp_session :server_version => 4 do |channel|
462
+ channel.sends_packet(FXP_STAT, :long, 0, :string, "/path/to/file", :long, 0x800001fd)
463
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 2)
464
+ end
465
+
466
+ assert_command_with_callback(:stat, "/path/to/file")
467
+ end
468
+
469
+ def test_v4_stat_should_honor_flags_parameter
470
+ expect_sftp_session :server_version => 4 do |channel|
471
+ channel.sends_packet(FXP_STAT, :long, 0, :string, "/path/to/file", :long, 0x1)
472
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 2)
473
+ end
474
+
475
+ assert_command_with_callback(:stat, "/path/to/file", 0x1)
476
+ end
477
+
478
+ def test_stat_bang_should_block_and_return_attrs
479
+ expect_sftp_session :server_version => 1 do |channel|
480
+ channel.sends_packet(FXP_STAT, :long, 0, :string, "/path/to/file")
481
+ channel.gets_packet(FXP_ATTRS, :long, 0, :long, 0xF, :int64, 123456, :long, 1, :long, 2, :long, 0765, :long, 123456789, :long, 234567890)
482
+ end
483
+
484
+ attrs = assert_synchronous_command(:stat!, "/path/to/file")
485
+
486
+ assert_equal 123456, attrs.size
487
+ assert_equal 1, attrs.uid
488
+ assert_equal 2, attrs.gid
489
+ assert_equal 0765, attrs.permissions
490
+ assert_equal 123456789, attrs.atime
491
+ assert_equal 234567890, attrs.mtime
492
+ end
493
+
494
+ def test_v1_rename_should_be_unimplemented
495
+ assert_not_implemented 1, :rename, "from", "to"
496
+ end
497
+
498
+ def test_v2_rename_should_send_rename_packet
499
+ expect_sftp_session :server_version => 2 do |channel|
500
+ channel.sends_packet(FXP_RENAME, :long, 0, :string, "from", :string, "to")
501
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
502
+ end
503
+
504
+ assert_command_with_callback(:rename, "from", "to")
505
+ end
506
+
507
+ def test_v5_rename_should_send_rename_packet_and_default_flags
508
+ expect_sftp_session :server_version => 5 do |channel|
509
+ channel.sends_packet(FXP_RENAME, :long, 0, :string, "from", :string, "to", :long, 0)
510
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
511
+ end
512
+
513
+ assert_command_with_callback(:rename, "from", "to")
514
+ end
515
+
516
+ def test_v5_rename_should_send_rename_packet_and_honor_flags
517
+ expect_sftp_session :server_version => 5 do |channel|
518
+ channel.sends_packet(FXP_RENAME, :long, 0, :string, "from", :string, "to", :long, 1)
519
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
520
+ end
521
+
522
+ assert_command_with_callback(:rename, "from", "to", 1)
523
+ end
524
+
525
+ def test_rename_bang_should_block_and_return_response
526
+ expect_sftp_session :server_version => 2 do |channel|
527
+ channel.sends_packet(FXP_RENAME, :long, 0, :string, "from", :string, "to")
528
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
529
+ end
530
+
531
+ response = assert_synchronous_command(:rename!, "from", "to")
532
+ assert response.ok?
533
+ end
534
+
535
+ def test_v2_readlink_should_be_unimplemented
536
+ assert_not_implemented 2, :readlink, "/path/to/link"
537
+ end
538
+
539
+ def test_v3_readlink_should_send_readlink_packet
540
+ expect_sftp_session :server_version => 3 do |channel|
541
+ channel.sends_packet(FXP_READLINK, :long, 0, :string, "/path/to/link")
542
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 2)
543
+ end
544
+
545
+ assert_command_with_callback(:readlink, "/path/to/link")
546
+ end
547
+
548
+ def test_readlink_bang_should_block_and_return_name
549
+ expect_sftp_session :server_version => 3 do |channel|
550
+ channel.sends_packet(FXP_READLINK, :long, 0, :string, "/path/to/link")
551
+ channel.gets_packet(FXP_NAME, :long, 0, :long, 1, :string, "target", :string, "longtarget", :long, 0x0)
552
+ end
553
+
554
+ name = assert_synchronous_command(:readlink!, "/path/to/link")
555
+ assert_equal "target", name.name
556
+ end
557
+
558
+ def test_v2_symlink_should_be_unimplemented
559
+ assert_not_implemented 2, :symlink, "/path/to/source", "/path/to/link"
560
+ end
561
+
562
+ def test_v3_symlink_should_send_symlink_packet
563
+ expect_sftp_session :server_version => 3 do |channel|
564
+ channel.sends_packet(FXP_SYMLINK, :long, 0, :string, "/path/to/source", :string, "/path/to/link")
565
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
566
+ end
567
+
568
+ assert_command_with_callback(:symlink, "/path/to/source", "/path/to/link")
569
+ end
570
+
571
+ def test_v6_symlink_should_send_link_packet
572
+ expect_sftp_session :server_version => 6 do |channel|
573
+ channel.sends_packet(FXP_LINK, :long, 0, :string, "/path/to/link", :string, "/path/to/source", :bool, true)
574
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
575
+ end
576
+
577
+ assert_command_with_callback(:symlink, "/path/to/link", "/path/to/source")
578
+ end
579
+
580
+ def test_symlink_bang_should_block_and_return_response
581
+ expect_sftp_session :server_version => 3 do |channel|
582
+ channel.sends_packet(FXP_SYMLINK, :long, 0, :string, "/path/to/source", :string, "/path/to/link")
583
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
584
+ end
585
+
586
+ response = assert_synchronous_command(:symlink!, "/path/to/source", "/path/to/link")
587
+ assert response.ok?
588
+ end
589
+
590
+ def test_v5_link_should_be_unimplemented
591
+ assert_not_implemented 5, :link, "/path/to/source", "/path/to/link", true
592
+ end
593
+
594
+ def test_v6_link_should_send_link_packet
595
+ expect_sftp_session :server_version => 6 do |channel|
596
+ channel.sends_packet(FXP_LINK, :long, 0, :string, "/path/to/link", :string, "/path/to/source", :bool, true)
597
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
598
+ end
599
+
600
+ assert_command_with_callback(:link, "/path/to/link", "/path/to/source", true)
601
+ end
602
+
603
+ def test_link_bang_should_block_and_return_response
604
+ expect_sftp_session :server_version => 6 do |channel|
605
+ channel.sends_packet(FXP_LINK, :long, 0, :string, "/path/to/link", :string, "/path/to/source", :bool, true)
606
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
607
+ end
608
+
609
+ response = assert_synchronous_command(:link!, "/path/to/link", "/path/to/source", true)
610
+ assert response.ok?
611
+ end
612
+
613
+ def test_v5_block_should_be_unimplemented
614
+ assert_not_implemented 5, :block, "handle", 12345, 67890, 0xabcd
615
+ end
616
+
617
+ def test_v6_block_should_send_block_packet
618
+ expect_sftp_session :server_version => 6 do |channel|
619
+ channel.sends_packet(FXP_BLOCK, :long, 0, :string, "handle", :int64, 12345, :int64, 67890, :long, 0xabcd)
620
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
621
+ end
622
+
623
+ assert_command_with_callback(:block, "handle", 12345, 67890, 0xabcd)
624
+ end
625
+
626
+ def test_block_bang_should_block_and_return_response
627
+ expect_sftp_session :server_version => 6 do |channel|
628
+ channel.sends_packet(FXP_BLOCK, :long, 0, :string, "handle", :int64, 12345, :int64, 67890, :long, 0xabcd)
629
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
630
+ end
631
+
632
+ response = assert_synchronous_command(:block!, "handle", 12345, 67890, 0xabcd)
633
+ assert response.ok?
634
+ end
635
+
636
+ def test_v5_unblock_should_be_unimplemented
637
+ assert_not_implemented 5, :unblock, "handle", 12345, 67890
638
+ end
639
+
640
+ def test_v6_unblock_should_send_block_packet
641
+ expect_sftp_session :server_version => 6 do |channel|
642
+ channel.sends_packet(FXP_UNBLOCK, :long, 0, :string, "handle", :int64, 12345, :int64, 67890)
643
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
644
+ end
645
+
646
+ assert_command_with_callback(:unblock, "handle", 12345, 67890)
647
+ end
648
+
649
+ def test_unblock_bang_should_block_and_return_response
650
+ expect_sftp_session :server_version => 6 do |channel|
651
+ channel.sends_packet(FXP_UNBLOCK, :long, 0, :string, "handle", :int64, 12345, :int64, 67890)
652
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, 0)
653
+ end
654
+
655
+ response = assert_synchronous_command(:unblock!, "handle", 12345, 67890)
656
+ assert response.ok?
657
+ end
658
+
659
+ private
660
+
661
+ def assert_not_implemented(server_version, command, *args)
662
+ expect_sftp_session :server_version => 1
663
+ sftp.connect!
664
+ assert_raises(NotImplementedError) { sftp.send(command, *args) }
665
+ end
666
+
667
+ def assert_command_with_callback(command, *args)
668
+ called = false
669
+ assert_scripted_command do
670
+ sftp.send(command, *args) do |response|
671
+ called = true
672
+ yield response if block_given?
673
+ end
674
+ end
675
+ assert called, "expected callback to be invoked, but it wasn't"
676
+ end
677
+
678
+ def assert_synchronous_command(command, *args)
679
+ assert_scripted_command do
680
+ sequence = [:start]
681
+ result = sftp.send(command, *args) do |response|
682
+ sequence << :done
683
+ yield response if block_given?
684
+ end
685
+ sequence << :after
686
+ assert_equal [:start, :done, :after], sequence, "expected #{command} to be synchronous"
687
+ return result
688
+ end
689
+ end
690
+
691
+ def assert_successful_open(*args)
692
+ assert_command_with_callback(:open, *args) do |response|
693
+ assert response.ok?
694
+ assert_equal "handle", response[:handle]
695
+ end
696
+ end
697
+
698
+ def expect_open(path, mode, perms, options={})
699
+ version = options[:server_version] || 6
700
+
701
+ fail = options.delete(:fail)
702
+
703
+ attrs = [:long, perms ? 0x4 : 0]
704
+ attrs += [:byte, 1] if version >= 4
705
+ attrs += [:long, perms] if perms
706
+
707
+ expect_sftp_session(options) do |channel|
708
+ if version >= 5
709
+ flags, access = case mode
710
+ when "r" then
711
+ [FV5::OPEN_EXISTING, ACE::Mask::READ_DATA | ACE::Mask::READ_ATTRIBUTES]
712
+ when "w" then
713
+ [FV5::CREATE_TRUNCATE, ACE::Mask::WRITE_DATA | ACE::Mask::WRITE_ATTRIBUTES]
714
+ when "rw" then
715
+ [FV5::OPEN_OR_CREATE, ACE::Mask::READ_DATA | ACE::Mask::READ_ATTRIBUTES | ACE::Mask::WRITE_DATA | ACE::Mask::WRITE_ATTRIBUTES]
716
+ when "a" then
717
+ [FV5::OPEN_OR_CREATE | FV5::APPEND_DATA, ACE::Mask::WRITE_DATA | ACE::Mask::WRITE_ATTRIBUTES | ACE::Mask::APPEND_DATA]
718
+ else raise ArgumentError, "unsupported mode #{mode.inspect}"
719
+ end
720
+
721
+ channel.sends_packet(FXP_OPEN, :long, 0, :string, path, :long, access, :long, flags, *attrs)
722
+ else
723
+ flags = case mode
724
+ when "r" then FV1::READ
725
+ when "w" then FV1::WRITE | FV1::TRUNC | FV1::CREAT
726
+ when "rw" then FV1::WRITE | FV1::READ
727
+ when "a" then FV1::APPEND | FV1::WRITE | FV1::CREAT
728
+ else raise ArgumentError, "unsupported mode #{mode.inspect}"
729
+ end
730
+
731
+ channel.sends_packet(FXP_OPEN, :long, 0, :string, path, :long, flags, *attrs)
732
+ end
733
+
734
+ if fail
735
+ channel.gets_packet(FXP_STATUS, :long, 0, :long, fail)
736
+ else
737
+ channel.gets_packet(FXP_HANDLE, :long, 0, :string, "handle")
738
+ end
739
+ end
740
+ end
741
+ end