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,161 @@
1
+ require 'openssl'
2
+
3
+ unless defined?(OpenSSL::PKey::EC)
4
+ puts "Skipping tests for ecdh-sha2-nistp256 key exchange"
5
+ else
6
+ require 'common'
7
+ require 'transport/kex/test_diffie_hellman_group1_sha1'
8
+ require 'net/ssh/transport/kex/ecdh_sha2_nistp256'
9
+ require 'ostruct'
10
+
11
+ module Transport; module Kex
12
+
13
+ class TestEcdhSHA2NistP256 < Test::Unit::TestCase
14
+ include Net::SSH::Transport::Constants
15
+
16
+ def setup
17
+ @ecdh = @algorithms = @connection = @server_key =
18
+ @packet_data = @shared_secret = nil
19
+ end
20
+
21
+ def test_exchange_keys_should_return_expected_results_when_successful
22
+ result = exchange!
23
+ assert_equal session_id, result[:session_id]
24
+ assert_equal server_host_key.to_blob, result[:server_key].to_blob
25
+ assert_equal shared_secret, result[:shared_secret]
26
+ assert_equal digester, result[:hashing_algorithm]
27
+ end
28
+
29
+ def test_exchange_keys_with_unverifiable_host_should_raise_exception
30
+ connection.verifier { false }
31
+ assert_raises(Net::SSH::Exception) { exchange! }
32
+ end
33
+
34
+ def test_exchange_keys_with_signature_key_type_mismatch_should_raise_exception
35
+ assert_raises(Net::SSH::Exception) { exchange! :key_type => "ssh-dss" }
36
+ end
37
+
38
+ def test_exchange_keys_with_host_key_type_mismatch_should_raise_exception
39
+ algorithms :host_key => "ssh-dss"
40
+ assert_raises(Net::SSH::Exception) { exchange! :key_type => "ssh-dss" }
41
+ end
42
+
43
+ def test_exchange_keys_when_server_signature_could_not_be_verified_should_raise_exception
44
+ @signature = "1234567890"
45
+ assert_raises(Net::SSH::Exception) { exchange! }
46
+ end
47
+
48
+ def test_exchange_keys_should_pass_expected_parameters_to_host_key_verifier
49
+ verified = false
50
+ connection.verifier do |data|
51
+ verified = true
52
+ assert_equal server_host_key.to_blob, data[:key].to_blob
53
+
54
+ blob = b(:key, data[:key]).to_s
55
+ fingerprint = OpenSSL::Digest::MD5.hexdigest(blob).scan(/../).join(":")
56
+
57
+ assert_equal blob, data[:key_blob]
58
+ assert_equal fingerprint, data[:fingerprint]
59
+ assert_equal connection, data[:session]
60
+
61
+ true
62
+ end
63
+
64
+ assert_nothing_raised { exchange! }
65
+ assert verified
66
+ end
67
+
68
+ private
69
+
70
+ def digester
71
+ OpenSSL::Digest::SHA256
72
+ end
73
+
74
+ def subject
75
+ Net::SSH::Transport::Kex::EcdhSHA2NistP256
76
+ end
77
+
78
+ def ecparam
79
+ "prime256v1"
80
+ end
81
+
82
+ def key_type
83
+ "ecdsa-sha2-nistp256"
84
+ end
85
+
86
+ def exchange!(options={})
87
+ connection.expect do |t, buffer|
88
+ assert_equal KEXECDH_INIT, buffer.type
89
+ assert_equal ecdh.ecdh.public_key.to_bn.to_s(2), buffer.read_string
90
+ t.return(KEXECDH_REPLY,
91
+ :string, b(:key, server_host_key),
92
+ :string, server_ecdh_pubkey.to_bn.to_s(2),
93
+ :string, b(:string, options[:key_type] || key_type,
94
+ :string, signature))
95
+ connection.expect do |t2, buffer2|
96
+ assert_equal NEWKEYS, buffer2.type
97
+ t2.return(NEWKEYS)
98
+ end
99
+ end
100
+ ecdh.exchange_keys
101
+ end
102
+
103
+ def ecdh
104
+ @ecdh ||= subject.new(algorithms, connection, packet_data)
105
+ end
106
+
107
+ def algorithms(options={})
108
+ @algorithms ||= OpenStruct.new(:host_key => options[:server_host_key] || "ecdsa-sha2-nistp256")
109
+ end
110
+
111
+ def connection
112
+ @connection ||= MockTransport.new
113
+ end
114
+
115
+ def server_key
116
+ @server_key ||= OpenSSL::PKey::EC.new(ecparam).generate_key
117
+ end
118
+
119
+ def server_host_key
120
+ @server_host_key ||= OpenSSL::PKey::EC.new("prime256v1").generate_key
121
+ end
122
+
123
+ def packet_data
124
+ @packet_data ||= { :client_version_string => "client version string",
125
+ :server_version_string => "server version string",
126
+ :server_algorithm_packet => "server algorithm packet",
127
+ :client_algorithm_packet => "client algorithm packet" }
128
+ end
129
+
130
+ def server_ecdh_pubkey
131
+ @server_ecdh_pubkey ||= server_key.public_key
132
+ end
133
+
134
+ def shared_secret
135
+ @shared_secret ||= OpenSSL::BN.new(ecdh.ecdh.dh_compute_key(server_ecdh_pubkey), 2)
136
+ end
137
+
138
+ def session_id
139
+ @session_id ||= begin
140
+ buffer = Net::SSH::Buffer.from(:string, packet_data[:client_version_string],
141
+ :string, packet_data[:server_version_string],
142
+ :string, packet_data[:client_algorithm_packet],
143
+ :string, packet_data[:server_algorithm_packet],
144
+ :string, Net::SSH::Buffer.from(:key, server_host_key),
145
+ :string, ecdh.ecdh.public_key.to_bn.to_s(2),
146
+ :string, server_ecdh_pubkey.to_bn.to_s(2),
147
+ :bignum, shared_secret)
148
+ digester.digest(buffer.to_s)
149
+ end
150
+ end
151
+
152
+ def signature
153
+ @signature ||= server_host_key.ssh_do_sign(session_id)
154
+ end
155
+
156
+ def b(*args)
157
+ Net::SSH::Buffer.from(*args)
158
+ end
159
+ end
160
+ end; end;
161
+ end
@@ -0,0 +1,37 @@
1
+ require 'openssl'
2
+
3
+ unless defined?(OpenSSL::PKey::EC)
4
+ puts "Skipping tests for ecdh-sha2-nistp384 key exchange"
5
+ else
6
+ module Transport; module Kex
7
+ class TestEcdhSHA2NistP384 < TestEcdhSHA2NistP256
8
+
9
+ def setup
10
+ @ecdh = @algorithms = @connection = @server_key =
11
+ @packet_data = @shared_secret = nil
12
+ end
13
+
14
+ def test_exchange_keys_should_return_expected_results_when_successful
15
+ result = exchange!
16
+ assert_equal session_id, result[:session_id]
17
+ assert_equal server_host_key.to_blob, result[:server_key].to_blob
18
+ assert_equal shared_secret, result[:shared_secret]
19
+ assert_equal digester, result[:hashing_algorithm]
20
+ end
21
+
22
+ private
23
+
24
+ def digester
25
+ OpenSSL::Digest::SHA384
26
+ end
27
+
28
+ def subject
29
+ Net::SSH::Transport::Kex::EcdhSHA2NistP384
30
+ end
31
+
32
+ def ecparam
33
+ "secp384r1"
34
+ end
35
+ end
36
+ end; end
37
+ end
@@ -0,0 +1,37 @@
1
+ require 'openssl'
2
+
3
+ unless defined?(OpenSSL::PKey::EC)
4
+ puts "Skipping tests for ecdh-sha2-nistp521 key exchange"
5
+ else
6
+ module Transport; module Kex
7
+ class TestEcdhSHA2NistP521 < TestEcdhSHA2NistP256
8
+
9
+ def setup
10
+ @ecdh = @algorithms = @connection = @server_key =
11
+ @packet_data = @shared_secret = nil
12
+ end
13
+
14
+ def test_exchange_keys_should_return_expected_results_when_successful
15
+ result = exchange!
16
+ assert_equal session_id, result[:session_id]
17
+ assert_equal server_host_key.to_blob, result[:server_key].to_blob
18
+ assert_equal shared_secret, result[:shared_secret]
19
+ assert_equal digester, result[:hashing_algorithm]
20
+ end
21
+
22
+ private
23
+
24
+ def digester
25
+ OpenSSL::Digest::SHA512
26
+ end
27
+
28
+ def subject
29
+ Net::SSH::Transport::Kex::EcdhSHA2NistP521
30
+ end
31
+
32
+ def ecparam
33
+ "secp521r1"
34
+ end
35
+ end
36
+ end; end
37
+ end
@@ -0,0 +1,330 @@
1
+ require 'common'
2
+ require 'net/ssh/transport/algorithms'
3
+
4
+ module Transport
5
+
6
+ class TestAlgorithms < Test::Unit::TestCase
7
+ include Net::SSH::Transport::Constants
8
+
9
+ def test_allowed_packets
10
+ (0..255).each do |type|
11
+ packet = stub("packet", :type => type)
12
+ case type
13
+ when 1..4, 6..19, 21..49 then assert(Net::SSH::Transport::Algorithms.allowed_packet?(packet), "#{type} should be allowed during key exchange")
14
+ else assert(!Net::SSH::Transport::Algorithms.allowed_packet?(packet), "#{type} should not be allowed during key exchange")
15
+ end
16
+ end
17
+ end
18
+
19
+ def test_constructor_should_build_default_list_of_preferred_algorithms
20
+ if defined?(OpenSSL::PKey::EC)
21
+ assert_equal %w(ssh-rsa ssh-dss ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521), algorithms[:host_key]
22
+ assert_equal %w(diffie-hellman-group-exchange-sha1 diffie-hellman-group1-sha1 diffie-hellman-group14-sha1 diffie-hellman-group-exchange-sha256 ecdh-sha2-nistp256 ecdh-sha2-nistp384 ecdh-sha2-nistp521), algorithms[:kex]
23
+ else
24
+ assert_equal %w(ssh-rsa ssh-dss), algorithms[:host_key]
25
+ assert_equal %w(diffie-hellman-group-exchange-sha1 diffie-hellman-group1-sha1 diffie-hellman-group14-sha1 diffie-hellman-group-exchange-sha256), algorithms[:kex]
26
+ end
27
+ assert_equal %w(aes128-cbc 3des-cbc blowfish-cbc cast128-cbc aes192-cbc aes256-cbc rijndael-cbc@lysator.liu.se idea-cbc none arcfour128 arcfour256 arcfour aes128-ctr aes192-ctr aes256-ctr camellia128-cbc camellia192-cbc camellia256-cbc camellia128-cbc@openssh.org camellia192-cbc@openssh.org camellia256-cbc@openssh.org camellia128-ctr camellia192-ctr camellia256-ctr camellia128-ctr@openssh.org camellia192-ctr@openssh.org camellia256-ctr@openssh.org cast128-ctr blowfish-ctr 3des-ctr), algorithms[:encryption]
28
+ if defined?(OpenSSL::Digest::SHA256)
29
+ assert_equal %w(hmac-sha1 hmac-md5 hmac-sha1-96 hmac-md5-96 hmac-ripemd160 hmac-ripemd160@openssh.com hmac-sha2-256 hmac-sha2-512 hmac-sha2-256-96 hmac-sha2-512-96 none), algorithms[:hmac]
30
+ else
31
+ assert_equal %w(hmac-sha1 hmac-md5 hmac-sha1-96 hmac-md5-96 hmac-ripemd160 hmac-ripemd160@openssh.com none), algorithms[:hmac]
32
+ end
33
+ assert_equal %w(none zlib@openssh.com zlib), algorithms[:compression]
34
+ assert_equal %w(), algorithms[:language]
35
+ end
36
+
37
+ def test_constructor_should_set_client_and_server_prefs_identically
38
+ %w(encryption hmac compression language).each do |key|
39
+ assert_equal algorithms[key.to_sym], algorithms[:"#{key}_client"], key
40
+ assert_equal algorithms[key.to_sym], algorithms[:"#{key}_server"], key
41
+ end
42
+ end
43
+
44
+ def test_constructor_with_preferred_host_key_type_should_put_preferred_host_key_type_first
45
+ if defined?(OpenSSL::PKey::EC)
46
+ assert_equal %w(ssh-dss ssh-rsa ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521), algorithms(:host_key => "ssh-dss")[:host_key]
47
+ else
48
+ assert_equal %w(ssh-dss ssh-rsa), algorithms(:host_key => "ssh-dss")[:host_key]
49
+ end
50
+ end
51
+
52
+ def test_constructor_with_known_hosts_reporting_known_host_key_should_use_that_host_key_type
53
+ Net::SSH::KnownHosts.expects(:search_for).with("net.ssh.test,127.0.0.1", {}).returns([stub("key", :ssh_type => "ssh-dss")])
54
+ if defined?(OpenSSL::PKey::EC)
55
+ assert_equal %w(ssh-dss ssh-rsa ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521), algorithms[:host_key]
56
+ else
57
+ assert_equal %w(ssh-dss ssh-rsa), algorithms[:host_key]
58
+ end
59
+ end
60
+
61
+ def test_constructor_with_unrecognized_host_key_type_should_raise_exception
62
+ assert_raises(NotImplementedError) { algorithms(:host_key => "bogus") }
63
+ end
64
+
65
+ def test_constructor_with_preferred_kex_should_put_preferred_kex_first
66
+ if defined?(OpenSSL::PKey::EC)
67
+ assert_equal %w(diffie-hellman-group1-sha1 diffie-hellman-group-exchange-sha1 diffie-hellman-group14-sha1 diffie-hellman-group-exchange-sha256 ecdh-sha2-nistp256 ecdh-sha2-nistp384 ecdh-sha2-nistp521), algorithms(:kex => "diffie-hellman-group1-sha1")[:kex]
68
+ else
69
+ assert_equal %w(diffie-hellman-group1-sha1 diffie-hellman-group-exchange-sha1 diffie-hellman-group14-sha1 diffie-hellman-group-exchange-sha256), algorithms(:kex => "diffie-hellman-group1-sha1")[:kex]
70
+ end
71
+ end
72
+
73
+ def test_constructor_with_unrecognized_kex_should_raise_exception
74
+ assert_raises(NotImplementedError) { algorithms(:kex => "bogus") }
75
+ end
76
+
77
+ def test_constructor_with_preferred_encryption_should_put_preferred_encryption_first
78
+ assert_equal %w(aes256-cbc aes128-cbc 3des-cbc blowfish-cbc cast128-cbc aes192-cbc rijndael-cbc@lysator.liu.se idea-cbc none arcfour128 arcfour256 arcfour aes128-ctr aes192-ctr aes256-ctr camellia128-cbc camellia192-cbc camellia256-cbc camellia128-cbc@openssh.org camellia192-cbc@openssh.org camellia256-cbc@openssh.org camellia128-ctr camellia192-ctr camellia256-ctr camellia128-ctr@openssh.org camellia192-ctr@openssh.org camellia256-ctr@openssh.org cast128-ctr blowfish-ctr 3des-ctr), algorithms(:encryption => "aes256-cbc")[:encryption]
79
+ end
80
+
81
+ def test_constructor_with_multiple_preferred_encryption_should_put_all_preferred_encryption_first
82
+ assert_equal %w(aes256-cbc 3des-cbc idea-cbc aes128-cbc blowfish-cbc cast128-cbc aes192-cbc rijndael-cbc@lysator.liu.se none arcfour128 arcfour256 arcfour aes128-ctr aes192-ctr aes256-ctr camellia128-cbc camellia192-cbc camellia256-cbc camellia128-cbc@openssh.org camellia192-cbc@openssh.org camellia256-cbc@openssh.org camellia128-ctr camellia192-ctr camellia256-ctr camellia128-ctr@openssh.org camellia192-ctr@openssh.org camellia256-ctr@openssh.org cast128-ctr blowfish-ctr 3des-ctr), algorithms(:encryption => %w(aes256-cbc 3des-cbc idea-cbc))[:encryption]
83
+ end
84
+
85
+ def test_constructor_with_unrecognized_encryption_should_raise_exception
86
+ assert_raises(NotImplementedError) { algorithms(:encryption => "bogus") }
87
+ end
88
+
89
+ def test_constructor_with_preferred_hmac_should_put_preferred_hmac_first
90
+ assert_equal %w(hmac-md5-96 hmac-sha1 hmac-md5 hmac-sha1-96 hmac-ripemd160 hmac-ripemd160@openssh.com hmac-sha2-256 hmac-sha2-512 hmac-sha2-256-96 hmac-sha2-512-96 none), algorithms(:hmac => "hmac-md5-96")[:hmac]
91
+ end
92
+
93
+ def test_constructor_with_multiple_preferred_hmac_should_put_all_preferred_hmac_first
94
+ assert_equal %w(hmac-md5-96 hmac-sha1-96 hmac-sha1 hmac-md5 hmac-ripemd160 hmac-ripemd160@openssh.com hmac-sha2-256 hmac-sha2-512 hmac-sha2-256-96 hmac-sha2-512-96 none), algorithms(:hmac => %w(hmac-md5-96 hmac-sha1-96))[:hmac]
95
+ end
96
+
97
+ def test_constructor_with_unrecognized_hmac_should_raise_exception
98
+ assert_raises(NotImplementedError) { algorithms(:hmac => "bogus") }
99
+ end
100
+
101
+ def test_constructor_with_preferred_compression_should_put_preferred_compression_first
102
+ assert_equal %w(zlib none zlib@openssh.com), algorithms(:compression => "zlib")[:compression]
103
+ end
104
+
105
+ def test_constructor_with_multiple_preferred_compression_should_put_all_preferred_compression_first
106
+ assert_equal %w(zlib@openssh.com zlib none), algorithms(:compression => %w(zlib@openssh.com zlib))[:compression]
107
+ end
108
+
109
+ def test_constructor_with_general_preferred_compression_should_put_none_last
110
+ assert_equal %w(zlib@openssh.com zlib none), algorithms(:compression => true)[:compression]
111
+ end
112
+
113
+ def test_constructor_with_unrecognized_compression_should_raise_exception
114
+ assert_raises(NotImplementedError) { algorithms(:compression => "bogus") }
115
+ end
116
+
117
+ def test_initial_state_should_be_neither_pending_nor_initialized
118
+ assert !algorithms.pending?
119
+ assert !algorithms.initialized?
120
+ end
121
+
122
+ def test_key_exchange_when_initiated_by_server
123
+ transport.expect do |t, buffer|
124
+ assert_kexinit(buffer)
125
+ install_mock_key_exchange(buffer)
126
+ end
127
+
128
+ install_mock_algorithm_lookups
129
+ algorithms.accept_kexinit(kexinit)
130
+
131
+ assert_exchange_results
132
+ end
133
+
134
+ def test_key_exchange_when_initiated_by_client
135
+ state = nil
136
+ transport.expect do |t, buffer|
137
+ assert_kexinit(buffer)
138
+ state = :sent_kexinit
139
+ install_mock_key_exchange(buffer)
140
+ end
141
+
142
+ algorithms.rekey!
143
+ assert_equal state, :sent_kexinit
144
+ assert algorithms.pending?
145
+
146
+ install_mock_algorithm_lookups
147
+ algorithms.accept_kexinit(kexinit)
148
+
149
+ assert_exchange_results
150
+ end
151
+
152
+ def test_key_exchange_when_server_does_not_support_preferred_kex_should_fallback_to_secondary
153
+ kexinit :kex => "diffie-hellman-group1-sha1"
154
+ transport.expect do |t,buffer|
155
+ assert_kexinit(buffer)
156
+ install_mock_key_exchange(buffer, :kex => Net::SSH::Transport::Kex::DiffieHellmanGroup1SHA1)
157
+ end
158
+ algorithms.accept_kexinit(kexinit)
159
+ end
160
+
161
+ def test_key_exchange_when_server_does_not_support_any_preferred_kex_should_raise_error
162
+ kexinit :kex => "something-obscure"
163
+ transport.expect { |t,buffer| assert_kexinit(buffer) }
164
+ assert_raises(Net::SSH::Exception) { algorithms.accept_kexinit(kexinit) }
165
+ end
166
+
167
+ def test_allow_when_not_pending_should_be_true_for_all_packets
168
+ (0..255).each do |type|
169
+ packet = stub("packet", :type => type)
170
+ assert algorithms.allow?(packet), type.to_s
171
+ end
172
+ end
173
+
174
+ def test_allow_when_pending_should_be_true_only_for_packets_valid_during_key_exchange
175
+ transport.expect!
176
+ algorithms.rekey!
177
+ assert algorithms.pending?
178
+
179
+ (0..255).each do |type|
180
+ packet = stub("packet", :type => type)
181
+ case type
182
+ when 1..4, 6..19, 21..49 then assert(algorithms.allow?(packet), "#{type} should be allowed during key exchange")
183
+ else assert(!algorithms.allow?(packet), "#{type} should not be allowed during key exchange")
184
+ end
185
+ end
186
+ end
187
+
188
+ def test_exchange_with_zlib_compression_enabled_sets_compression_to_standard
189
+ algorithms :compression => "zlib"
190
+
191
+ transport.expect do |t, buffer|
192
+ assert_kexinit(buffer, :compression_client => "zlib,none,zlib@openssh.com", :compression_server => "zlib,none,zlib@openssh.com")
193
+ install_mock_key_exchange(buffer)
194
+ end
195
+
196
+ install_mock_algorithm_lookups
197
+ algorithms.accept_kexinit(kexinit)
198
+
199
+ assert_equal :standard, transport.client_options[:compression]
200
+ assert_equal :standard, transport.server_options[:compression]
201
+ end
202
+
203
+ def test_exchange_with_zlib_at_openssh_dot_com_compression_enabled_sets_compression_to_delayed
204
+ algorithms :compression => "zlib@openssh.com"
205
+
206
+ transport.expect do |t, buffer|
207
+ assert_kexinit(buffer, :compression_client => "zlib@openssh.com,none,zlib", :compression_server => "zlib@openssh.com,none,zlib")
208
+ install_mock_key_exchange(buffer)
209
+ end
210
+
211
+ install_mock_algorithm_lookups
212
+ algorithms.accept_kexinit(kexinit)
213
+
214
+ assert_equal :delayed, transport.client_options[:compression]
215
+ assert_equal :delayed, transport.server_options[:compression]
216
+ end
217
+
218
+ private
219
+
220
+ def install_mock_key_exchange(buffer, options={})
221
+ kex = options[:kex] || Net::SSH::Transport::Kex::DiffieHellmanGroupExchangeSHA1
222
+
223
+ Net::SSH::Transport::Kex::MAP.each do |name, klass|
224
+ next if klass == kex
225
+ klass.expects(:new).never
226
+ end
227
+
228
+ kex.expects(:new).
229
+ with(algorithms, transport,
230
+ :client_version_string => Net::SSH::Transport::ServerVersion::PROTO_VERSION,
231
+ :server_version_string => transport.server_version.version,
232
+ :server_algorithm_packet => kexinit.to_s,
233
+ :client_algorithm_packet => buffer.to_s,
234
+ :need_bytes => 20,
235
+ :logger => nil).
236
+ returns(stub("kex", :exchange_keys => { :shared_secret => shared_secret, :session_id => session_id, :hashing_algorithm => hashing_algorithm }))
237
+ end
238
+
239
+ def install_mock_algorithm_lookups(options={})
240
+ params = { :shared => shared_secret.to_ssh, :hash => session_id, :digester => hashing_algorithm }
241
+ Net::SSH::Transport::CipherFactory.expects(:get).
242
+ with(options[:client_cipher] || "aes128-cbc", params.merge(:iv => key("A"), :key => key("C"), :encrypt => true)).
243
+ returns(:client_cipher)
244
+
245
+ Net::SSH::Transport::CipherFactory.expects(:get).
246
+ with(options[:server_cipher] || "aes128-cbc", params.merge(:iv => key("B"), :key => key("D"), :decrypt => true)).
247
+ returns(:server_cipher)
248
+
249
+ Net::SSH::Transport::HMAC.expects(:get).with(options[:client_hmac] || "hmac-sha1", key("E"), params).returns(:client_hmac)
250
+ Net::SSH::Transport::HMAC.expects(:get).with(options[:server_hmac] || "hmac-sha1", key("F"), params).returns(:server_hmac)
251
+ end
252
+
253
+ def shared_secret
254
+ @shared_secret ||= OpenSSL::BN.new("1234567890", 10)
255
+ end
256
+
257
+ def session_id
258
+ @session_id ||= "this is the session id"
259
+ end
260
+
261
+ def hashing_algorithm
262
+ OpenSSL::Digest::SHA1
263
+ end
264
+
265
+ def key(salt)
266
+ hashing_algorithm.digest(shared_secret.to_ssh + session_id + salt + session_id)
267
+ end
268
+
269
+ def cipher(type, options={})
270
+ Net::SSH::Transport::CipherFactory.get(type, options)
271
+ end
272
+
273
+ def kexinit(options={})
274
+ @kexinit ||= P(:byte, KEXINIT,
275
+ :long, rand(0xFFFFFFFF), :long, rand(0xFFFFFFFF), :long, rand(0xFFFFFFFF), :long, rand(0xFFFFFFFF),
276
+ :string, options[:kex] || "diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha256",
277
+ :string, options[:host_key] || "ssh-rsa,ssh-dss",
278
+ :string, options[:encryption_client] || "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,idea-cbc",
279
+ :string, options[:encryption_server] || "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,idea-cbc",
280
+ :string, options[:hmac_client] || "hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96",
281
+ :string, options[:hmac_server] || "hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96",
282
+ :string, options[:compmression_client] || "none,zlib@openssh.com,zlib",
283
+ :string, options[:compmression_server] || "none,zlib@openssh.com,zlib",
284
+ :string, options[:language_client] || "",
285
+ :string, options[:langauge_server] || "",
286
+ :bool, options[:first_kex_follows])
287
+ end
288
+
289
+ def assert_kexinit(buffer, options={})
290
+ assert_equal KEXINIT, buffer.type
291
+ assert_equal 16, buffer.read(16).length
292
+ if defined?(OpenSSL::PKey::EC)
293
+ assert_equal options[:kex] || "diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521", buffer.read_string
294
+ assert_equal options[:host_key] || "ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521", buffer.read_string
295
+ else
296
+ assert_equal options[:kex] || "diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha256", buffer.read_string
297
+ assert_equal options[:host_key] || "ssh-rsa,ssh-dss", buffer.read_string
298
+ end
299
+ assert_equal options[:encryption_client] || "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,idea-cbc,none,arcfour128,arcfour256,arcfour,aes128-ctr,aes192-ctr,aes256-ctr,camellia128-cbc,camellia192-cbc,camellia256-cbc,camellia128-cbc@openssh.org,camellia192-cbc@openssh.org,camellia256-cbc@openssh.org,camellia128-ctr,camellia192-ctr,camellia256-ctr,camellia128-ctr@openssh.org,camellia192-ctr@openssh.org,camellia256-ctr@openssh.org,cast128-ctr,blowfish-ctr,3des-ctr", buffer.read_string
300
+ assert_equal options[:encryption_server] || "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,idea-cbc,none,arcfour128,arcfour256,arcfour,aes128-ctr,aes192-ctr,aes256-ctr,camellia128-cbc,camellia192-cbc,camellia256-cbc,camellia128-cbc@openssh.org,camellia192-cbc@openssh.org,camellia256-cbc@openssh.org,camellia128-ctr,camellia192-ctr,camellia256-ctr,camellia128-ctr@openssh.org,camellia192-ctr@openssh.org,camellia256-ctr@openssh.org,cast128-ctr,blowfish-ctr,3des-ctr", buffer.read_string
301
+ assert_equal options[:hmac_client] || "hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha2-256-96,hmac-sha2-512-96,none", buffer.read_string
302
+ assert_equal options[:hmac_server] || "hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha2-256-96,hmac-sha2-512-96,none", buffer.read_string
303
+ assert_equal options[:compression_client] || "none,zlib@openssh.com,zlib", buffer.read_string
304
+ assert_equal options[:compression_server] || "none,zlib@openssh.com,zlib", buffer.read_string
305
+ assert_equal options[:language_client] || "", buffer.read_string
306
+ assert_equal options[:language_server] || "", buffer.read_string
307
+ assert_equal options[:first_kex_follows] || false, buffer.read_bool
308
+ end
309
+
310
+ def assert_exchange_results
311
+ assert algorithms.initialized?
312
+ assert !algorithms.pending?
313
+ assert !transport.client_options[:compression]
314
+ assert !transport.server_options[:compression]
315
+ assert_equal :client_cipher, transport.client_options[:cipher]
316
+ assert_equal :server_cipher, transport.server_options[:cipher]
317
+ assert_equal :client_hmac, transport.client_options[:hmac]
318
+ assert_equal :server_hmac, transport.server_options[:hmac]
319
+ end
320
+
321
+ def algorithms(options={})
322
+ @algorithms ||= Net::SSH::Transport::Algorithms.new(transport, options)
323
+ end
324
+
325
+ def transport
326
+ @transport ||= MockTransport.new
327
+ end
328
+ end
329
+
330
+ end