lumberg 1.0.1 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (306) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +1 -1
  3. data/README.md +184 -70
  4. data/Rakefile +3 -1
  5. data/lib/lumberg/config.rb +19 -0
  6. data/lib/lumberg/cpanel/addon_domain.rb +50 -0
  7. data/lib/lumberg/cpanel/backups.rb +16 -0
  8. data/lib/lumberg/cpanel/base.rb +56 -0
  9. data/lib/lumberg/cpanel/box_trapper.rb +18 -0
  10. data/lib/lumberg/cpanel/branding.rb +89 -0
  11. data/lib/lumberg/cpanel/contact.rb +38 -0
  12. data/lib/lumberg/cpanel/cron.rb +89 -0
  13. data/lib/lumberg/cpanel/dns_lookup.rb +23 -0
  14. data/lib/lumberg/cpanel/domain_keys.rb +37 -0
  15. data/lib/lumberg/cpanel/domain_lookup.rb +71 -0
  16. data/lib/lumberg/cpanel/email.rb +522 -0
  17. data/lib/lumberg/cpanel/file_manager.rb +146 -0
  18. data/lib/lumberg/cpanel/ftp.rb +101 -0
  19. data/lib/lumberg/cpanel/gpg.rb +36 -0
  20. data/lib/lumberg/cpanel/locale.rb +15 -0
  21. data/lib/lumberg/cpanel/mime.rb +34 -0
  22. data/lib/lumberg/cpanel/mysql.rb +66 -0
  23. data/lib/lumberg/cpanel/mysql_db.rb +190 -0
  24. data/lib/lumberg/cpanel/net.rb +28 -0
  25. data/lib/lumberg/cpanel/park.rb +58 -0
  26. data/lib/lumberg/cpanel/password.rb +52 -0
  27. data/lib/lumberg/cpanel/password_strength.rb +63 -0
  28. data/lib/lumberg/cpanel/random_data.rb +25 -0
  29. data/lib/lumberg/cpanel/redirect.rb +44 -0
  30. data/lib/lumberg/cpanel/ssl.rb +220 -0
  31. data/lib/lumberg/cpanel/sub_domain.rb +61 -0
  32. data/lib/lumberg/cpanel/support.rb +29 -0
  33. data/lib/lumberg/cpanel/zone_edit.rb +134 -0
  34. data/lib/lumberg/cpanel.rb +32 -0
  35. data/lib/lumberg/format_whm.rb +162 -0
  36. data/lib/lumberg/version.rb +1 -1
  37. data/lib/lumberg/whm/account.rb +29 -106
  38. data/lib/lumberg/whm/base.rb +3 -7
  39. data/lib/lumberg/whm/cert.rb +88 -0
  40. data/lib/lumberg/whm/dns.rb +49 -77
  41. data/lib/lumberg/whm/reseller.rb +25 -118
  42. data/lib/lumberg/whm/server.rb +163 -222
  43. data/lib/lumberg/whm/transfer_tool.rb +165 -0
  44. data/lib/lumberg/whm.rb +11 -9
  45. data/lib/lumberg/whostmgr/base.rb +13 -0
  46. data/lib/lumberg/whostmgr/ssl.rb +57 -0
  47. data/lib/lumberg/whostmgr.rb +6 -0
  48. data/lib/lumberg.rb +35 -8
  49. data/spec/config_spec.rb +28 -0
  50. data/spec/cpanel/addon_domain_spec.rb +84 -0
  51. data/spec/cpanel/backups_spec.rb +22 -0
  52. data/spec/cpanel/base_spec.rb +128 -0
  53. data/spec/cpanel/box_trapper_spec.rb +22 -0
  54. data/spec/cpanel/branding_spec.rb +46 -0
  55. data/spec/cpanel/contact_spec.rb +50 -0
  56. data/spec/cpanel/cron_spec.rb +161 -0
  57. data/spec/cpanel/dns_lookup_spec.rb +22 -0
  58. data/spec/cpanel/domain_keys_spec.rb +46 -0
  59. data/spec/cpanel/domain_lookup_spec.rb +77 -0
  60. data/spec/cpanel/email_spec.rb +639 -0
  61. data/spec/cpanel/file_manager_spec.rb +73 -0
  62. data/spec/cpanel/ftp_spec.rb +71 -0
  63. data/spec/cpanel/gpg_spec.rb +48 -0
  64. data/spec/cpanel/locale_spec.rb +23 -0
  65. data/spec/cpanel/mime_spec.rb +0 -0
  66. data/spec/cpanel/mysql_db_spec.rb +119 -0
  67. data/spec/cpanel/mysql_spec.rb +0 -0
  68. data/spec/cpanel/net_spec.rb +30 -0
  69. data/spec/cpanel/park_spec.rb +94 -0
  70. data/spec/cpanel/password_spec.rb +35 -0
  71. data/spec/cpanel/password_strength_spec.rb +50 -0
  72. data/spec/cpanel/random_data_spec.rb +24 -0
  73. data/spec/cpanel/redirect_spec.rb +0 -0
  74. data/spec/cpanel/ssl_spec.rb +158 -0
  75. data/spec/cpanel/sub_domain_spec.rb +72 -0
  76. data/spec/cpanel/support_spec.rb +38 -0
  77. data/spec/cpanel/zone_edit_spec.rb +0 -0
  78. data/spec/format_whm_spec.rb +53 -0
  79. data/spec/sample_certs/cpanel.crt +28 -0
  80. data/spec/sample_certs/cpanel.key +28 -0
  81. data/spec/sample_certs/main.crt +27 -0
  82. data/spec/sample_certs/sample.crt +26 -0
  83. data/spec/sample_certs/sample.key +27 -0
  84. data/spec/spec_helper.rb +10 -3
  85. data/spec/support/cpanel_matchers.rb +17 -0
  86. data/spec/vcr_cassettes/cpanel/addon_domain/add.yml +77 -0
  87. data/spec/vcr_cassettes/cpanel/addon_domain/list.yml +77 -0
  88. data/spec/vcr_cassettes/cpanel/addon_domain/remove.yml +77 -0
  89. data/spec/vcr_cassettes/cpanel/backups/list.yml +40 -0
  90. data/spec/vcr_cassettes/cpanel/box_trapper/list.yml +40 -0
  91. data/spec/vcr_cassettes/cpanel/branding/list_icons.yml +40 -0
  92. data/spec/vcr_cassettes/cpanel/branding/list_image_types.yml +40 -0
  93. data/spec/vcr_cassettes/cpanel/branding/list_object_types.yml +40 -0
  94. data/spec/vcr_cassettes/cpanel/branding/list_pkgs.yml +40 -0
  95. data/spec/vcr_cassettes/cpanel/branding/list_sprites.yml +40 -0
  96. data/spec/vcr_cassettes/cpanel/contact/show.yml +40 -0
  97. data/spec/vcr_cassettes/cpanel/contact/update.yml +40 -0
  98. data/spec/vcr_cassettes/cpanel/cron/add.yml +77 -0
  99. data/spec/vcr_cassettes/cpanel/cron/edit.yml +114 -0
  100. data/spec/vcr_cassettes/cpanel/cron/email.yml +77 -0
  101. data/spec/vcr_cassettes/cpanel/cron/list.yml +77 -0
  102. data/spec/vcr_cassettes/cpanel/cron/remove.yml +151 -0
  103. data/spec/vcr_cassettes/cpanel/cron/set_email.yml +77 -0
  104. data/spec/vcr_cassettes/cpanel/dns_lookup/name_to_ip.yml +40 -0
  105. data/spec/vcr_cassettes/cpanel/domain_keys/add.yml +40 -0
  106. data/spec/vcr_cassettes/cpanel/domain_keys/available.yml +40 -0
  107. data/spec/vcr_cassettes/cpanel/domain_keys/installed.yml +40 -0
  108. data/spec/vcr_cassettes/cpanel/domain_keys/remove.yml +40 -0
  109. data/spec/vcr_cassettes/cpanel/domain_lookup/count.yml +40 -0
  110. data/spec/vcr_cassettes/cpanel/domain_lookup/docroot.yml +40 -0
  111. data/spec/vcr_cassettes/cpanel/domain_lookup/docroots.yml +40 -0
  112. data/spec/vcr_cassettes/cpanel/domain_lookup/document_root.yml +40 -0
  113. data/spec/vcr_cassettes/cpanel/domain_lookup/document_roots.yml +40 -0
  114. data/spec/vcr_cassettes/cpanel/domain_lookup/list.yml +40 -0
  115. data/spec/vcr_cassettes/cpanel/email/acceptable_encodings.yml +40 -0
  116. data/spec/vcr_cassettes/cpanel/email/accounts.yml +188 -0
  117. data/spec/vcr_cassettes/cpanel/email/add_account.yml +77 -0
  118. data/spec/vcr_cassettes/cpanel/email/add_filter.yml +77 -0
  119. data/spec/vcr_cassettes/cpanel/email/add_forwarder.yml +77 -0
  120. data/spec/vcr_cassettes/cpanel/email/add_mailing_list.yml +73 -0
  121. data/spec/vcr_cassettes/cpanel/email/add_mx.yml +40 -0
  122. data/spec/vcr_cassettes/cpanel/email/change_mx.yml +40 -0
  123. data/spec/vcr_cassettes/cpanel/email/change_password.yml +43 -0
  124. data/spec/vcr_cassettes/cpanel/email/check_local_delivery_local.yml +77 -0
  125. data/spec/vcr_cassettes/cpanel/email/check_local_delivery_remote.yml +77 -0
  126. data/spec/vcr_cassettes/cpanel/email/default_address.yml +40 -0
  127. data/spec/vcr_cassettes/cpanel/email/delete_mx.yml +40 -0
  128. data/spec/vcr_cassettes/cpanel/email/disk_usage.yml +77 -0
  129. data/spec/vcr_cassettes/cpanel/email/domains.yml +40 -0
  130. data/spec/vcr_cassettes/cpanel/email/domains_with_aliases.yml +77 -0
  131. data/spec/vcr_cassettes/cpanel/email/edit_quota.yml +112 -0
  132. data/spec/vcr_cassettes/cpanel/email/filters.yml +114 -0
  133. data/spec/vcr_cassettes/cpanel/email/forwarders.yml +77 -0
  134. data/spec/vcr_cassettes/cpanel/email/mail_dir.yml +77 -0
  135. data/spec/vcr_cassettes/cpanel/email/mail_dirs.yml +77 -0
  136. data/spec/vcr_cassettes/cpanel/email/mailing_lists.yml +73 -0
  137. data/spec/vcr_cassettes/cpanel/email/main_discard.yml +40 -0
  138. data/spec/vcr_cassettes/cpanel/email/mx.yml +40 -0
  139. data/spec/vcr_cassettes/cpanel/email/remove.yml +77 -0
  140. data/spec/vcr_cassettes/cpanel/email/set_default_address.yml +43 -0
  141. data/spec/vcr_cassettes/cpanel/email/set_mail_delivery_local.yml +77 -0
  142. data/spec/vcr_cassettes/cpanel/email/set_mail_delivery_remote.yml +77 -0
  143. data/spec/vcr_cassettes/cpanel/email/set_mx_type.yml +40 -0
  144. data/spec/vcr_cassettes/cpanel/file_manager/disk_usage.yml +38 -0
  145. data/spec/vcr_cassettes/cpanel/file_manager/list.yml +38 -0
  146. data/spec/vcr_cassettes/cpanel/file_manager/operate.yml +77 -0
  147. data/spec/vcr_cassettes/cpanel/file_manager/show.yml +40 -0
  148. data/spec/vcr_cassettes/cpanel/file_manager/stat.yml +38 -0
  149. data/spec/vcr_cassettes/cpanel/ftp/addftp.yml +43 -0
  150. data/spec/vcr_cassettes/cpanel/ftp/delftp.yml +43 -0
  151. data/spec/vcr_cassettes/cpanel/ftp/listftp.yml +43 -0
  152. data/spec/vcr_cassettes/cpanel/ftp/listftpsessions.yml +43 -0
  153. data/spec/vcr_cassettes/cpanel/ftp/listftpwithdisk.yml +95 -0
  154. data/spec/vcr_cassettes/cpanel/ftp/passwd.yml +43 -0
  155. data/spec/vcr_cassettes/cpanel/ftp/setquota.yml +43 -0
  156. data/spec/vcr_cassettes/cpanel/gpg/count.yml +40 -0
  157. data/spec/vcr_cassettes/cpanel/gpg/count_private.yml +40 -0
  158. data/spec/vcr_cassettes/cpanel/gpg/list.yml +40 -0
  159. data/spec/vcr_cassettes/cpanel/gpg/list_private.yml +40 -0
  160. data/spec/vcr_cassettes/cpanel/locale/show.yml +40 -0
  161. data/spec/vcr_cassettes/cpanel/mysql_db/add_db.yml +42 -0
  162. data/spec/vcr_cassettes/cpanel/mysql_db/add_host.yml +42 -0
  163. data/spec/vcr_cassettes/cpanel/mysql_db/add_user.yml +42 -0
  164. data/spec/vcr_cassettes/cpanel/mysql_db/add_user_db.yml +42 -0
  165. data/spec/vcr_cassettes/cpanel/mysql_db/check_db.yml +42 -0
  166. data/spec/vcr_cassettes/cpanel/mysql_db/del_db.yml +42 -0
  167. data/spec/vcr_cassettes/cpanel/mysql_db/del_host.yml +42 -0
  168. data/spec/vcr_cassettes/cpanel/mysql_db/del_user.yml +42 -0
  169. data/spec/vcr_cassettes/cpanel/mysql_db/del_user_db.yml +42 -0
  170. data/spec/vcr_cassettes/cpanel/mysql_db/init_cache.yml +42 -0
  171. data/spec/vcr_cassettes/cpanel/mysql_db/number_of_dbs.yml +42 -0
  172. data/spec/vcr_cassettes/cpanel/mysql_db/repair_db.yml +42 -0
  173. data/spec/vcr_cassettes/cpanel/mysql_db/update_privs.yml +42 -0
  174. data/spec/vcr_cassettes/cpanel/net/query_hostname.yml +40 -0
  175. data/spec/vcr_cassettes/cpanel/net/traceroute.yml +40 -0
  176. data/spec/vcr_cassettes/cpanel/park/add.yml +77 -0
  177. data/spec/vcr_cassettes/cpanel/park/list.yml +77 -0
  178. data/spec/vcr_cassettes/cpanel/park/list_addon_domains.yml +77 -0
  179. data/spec/vcr_cassettes/cpanel/park/remove.yml +77 -0
  180. data/spec/vcr_cassettes/cpanel/password/digest_authentication.yml +77 -0
  181. data/spec/vcr_cassettes/cpanel/password/modify.yml +77 -0
  182. data/spec/vcr_cassettes/cpanel/password_strength/all_required_strengths.yml +43 -0
  183. data/spec/vcr_cassettes/cpanel/password_strength/required_strength.yml +43 -0
  184. data/spec/vcr_cassettes/cpanel/password_strength/strength.yml +83 -0
  185. data/spec/vcr_cassettes/cpanel/random_data/show.yml +40 -0
  186. data/spec/vcr_cassettes/cpanel/ssl/fetchcabundle.yml +40 -0
  187. data/spec/vcr_cassettes/cpanel/ssl/gencrt.yml +43 -0
  188. data/spec/vcr_cassettes/cpanel/ssl/gencsr.yml +43 -0
  189. data/spec/vcr_cassettes/cpanel/ssl/genkey.yml +40 -0
  190. data/spec/vcr_cassettes/cpanel/ssl/installssl.yml +40 -0
  191. data/spec/vcr_cassettes/cpanel/ssl/listcrts.yml +40 -0
  192. data/spec/vcr_cassettes/cpanel/ssl/listcsrs.yml +40 -0
  193. data/spec/vcr_cassettes/cpanel/ssl/listkeys.yml +40 -0
  194. data/spec/vcr_cassettes/cpanel/ssl/listsslitems.yml +40 -0
  195. data/spec/vcr_cassettes/cpanel/ssl/remove.yml +43 -0
  196. data/spec/vcr_cassettes/cpanel/ssl/showcrt.yml +38 -0
  197. data/spec/vcr_cassettes/cpanel/ssl/showcsr.yml +38 -0
  198. data/spec/vcr_cassettes/cpanel/ssl/showkey.yml +38 -0
  199. data/spec/vcr_cassettes/cpanel/ssl/uploadcrt.yml +40 -0
  200. data/spec/vcr_cassettes/cpanel/sub_domain/add.yml +77 -0
  201. data/spec/vcr_cassettes/cpanel/sub_domain/list.yml +77 -0
  202. data/spec/vcr_cassettes/cpanel/sub_domain/remove.yml +77 -0
  203. data/spec/vcr_cassettes/cpanel/support/contactable.yml +40 -0
  204. data/spec/vcr_cassettes/whm/account/accountsummary.yml +41 -29
  205. data/spec/vcr_cassettes/whm/account/changepackage.yml +73 -43
  206. data/spec/vcr_cassettes/whm/account/createacct.yml +101 -31
  207. data/spec/vcr_cassettes/whm/account/domainuserdata.yml +43 -29
  208. data/spec/vcr_cassettes/whm/account/editquota.yml +78 -57
  209. data/spec/vcr_cassettes/whm/account/limitbw.yml +79 -57
  210. data/spec/vcr_cassettes/whm/account/listaccts.yml +195 -100
  211. data/spec/vcr_cassettes/whm/account/listsuspended.yml +41 -29
  212. data/spec/vcr_cassettes/whm/account/modifyacct.yml +61 -42
  213. data/spec/vcr_cassettes/whm/account/myprivs.yml +41 -29
  214. data/spec/vcr_cassettes/whm/account/passwd.yml +44 -29
  215. data/spec/vcr_cassettes/whm/account/removeacct.yml +134 -57
  216. data/spec/vcr_cassettes/whm/account/restoreaccount.yml +310 -135
  217. data/spec/vcr_cassettes/whm/account/setsiteip.yml +166 -127
  218. data/spec/vcr_cassettes/whm/account/suspend.yml +75 -43
  219. data/spec/vcr_cassettes/whm/account/unsuspend.yml +46 -29
  220. data/spec/vcr_cassettes/whm/cert/fetch_ssl_vhosts.yml +44 -0
  221. data/spec/vcr_cassettes/whm/cert/fetchsslinfo.yml +38 -0
  222. data/spec/vcr_cassettes/whm/cert/generatessl.yml +94 -0
  223. data/spec/vcr_cassettes/whm/cert/installssl.yml +38 -0
  224. data/spec/vcr_cassettes/whm/cert/listcrts.yml +38 -0
  225. data/spec/vcr_cassettes/whm/dns/adddns.yml +61 -43
  226. data/spec/vcr_cassettes/whm/dns/addzonerecord.yml +42 -29
  227. data/spec/vcr_cassettes/whm/dns/dumpzone.yml +44 -29
  228. data/spec/vcr_cassettes/whm/dns/editzonerecord.yml +61 -43
  229. data/spec/vcr_cassettes/whm/dns/getzonerecord.yml +60 -43
  230. data/spec/vcr_cassettes/whm/dns/killdns.yml +42 -29
  231. data/spec/vcr_cassettes/whm/dns/listmxs.yml +23 -15
  232. data/spec/vcr_cassettes/whm/dns/listzones.yml +22 -15
  233. data/spec/vcr_cassettes/whm/dns/lookupnsip.yml +40 -29
  234. data/spec/vcr_cassettes/whm/dns/removezonerecord.yml +61 -43
  235. data/spec/vcr_cassettes/whm/dns/resetzone.yml +42 -29
  236. data/spec/vcr_cassettes/whm/dns/resolvedomainname.yml +40 -29
  237. data/spec/vcr_cassettes/whm/dns/savemxs.yml +23 -15
  238. data/spec/vcr_cassettes/whm/reseller/acctcounts.yml +41 -29
  239. data/spec/vcr_cassettes/whm/reseller/listacls.yml +22 -15
  240. data/spec/vcr_cassettes/whm/reseller/listresellers.yml +22 -15
  241. data/spec/vcr_cassettes/whm/reseller/resellerstats.yml +42 -29
  242. data/spec/vcr_cassettes/whm/reseller/saveacllist.yml +76 -57
  243. data/spec/vcr_cassettes/whm/reseller/setacls.yml +40 -29
  244. data/spec/vcr_cassettes/whm/reseller/setresellerips.yml +42 -28
  245. data/spec/vcr_cassettes/whm/reseller/setresellerlimits.yml +41 -29
  246. data/spec/vcr_cassettes/whm/reseller/setresellermainip.yml +59 -43
  247. data/spec/vcr_cassettes/whm/reseller/setresellernameservers.yml +58 -43
  248. data/spec/vcr_cassettes/whm/reseller/setresellerpackagelimit.yml +61 -43
  249. data/spec/vcr_cassettes/whm/reseller/setupreseller.yml +41 -29
  250. data/spec/vcr_cassettes/whm/reseller/suspendreseller.yml +75 -44
  251. data/spec/vcr_cassettes/whm/reseller/terminatereseller.yml +83 -46
  252. data/spec/vcr_cassettes/whm/reseller/unsetupreseller.yml +41 -29
  253. data/spec/vcr_cassettes/whm/reseller/unsuspendreseller.yml +46 -29
  254. data/spec/vcr_cassettes/whm/server/addip.yml +24 -15
  255. data/spec/vcr_cassettes/whm/server/applist.yml +22 -15
  256. data/spec/vcr_cassettes/whm/server/delip.yml +23 -15
  257. data/spec/vcr_cassettes/whm/server/disk_usage.yml +45 -0
  258. data/spec/vcr_cassettes/whm/server/edit_hook.yml +44 -0
  259. data/spec/vcr_cassettes/whm/server/gethostname.yml +22 -15
  260. data/spec/vcr_cassettes/whm/server/getlanglist.yml +22 -15
  261. data/spec/vcr_cassettes/whm/server/gettweaksetting.yml +44 -0
  262. data/spec/vcr_cassettes/whm/server/list_hooks.yml +44 -0
  263. data/spec/vcr_cassettes/whm/server/listips.yml +22 -15
  264. data/spec/vcr_cassettes/whm/server/loadavg.yml +26 -19
  265. data/spec/vcr_cassettes/whm/server/lookup_nameserver_ip.yml +44 -0
  266. data/spec/vcr_cassettes/whm/server/my_function.yml +59 -43
  267. data/spec/vcr_cassettes/whm/server/nvget.yml +22 -15
  268. data/spec/vcr_cassettes/whm/server/nvset.yml +22 -15
  269. data/spec/vcr_cassettes/whm/server/reboot.yml +22 -15
  270. data/spec/vcr_cassettes/whm/server/sethostname.yml +24 -15
  271. data/spec/vcr_cassettes/whm/server/setresolvers.yml +23 -15
  272. data/spec/vcr_cassettes/whm/server/settweaksetting.yml +44 -0
  273. data/spec/vcr_cassettes/whm/server/showbw.yml +22 -15
  274. data/spec/vcr_cassettes/whm/server/systemloadavg.yml +40 -29
  275. data/spec/vcr_cassettes/whm/server/themes.yml +38 -0
  276. data/spec/vcr_cassettes/whm/server/version.yml +22 -15
  277. data/spec/vcr_cassettes/whm/transfer_tool/check.yml +44 -0
  278. data/spec/vcr_cassettes/whm/transfer_tool/create.yml +72 -0
  279. data/spec/vcr_cassettes/whm/transfer_tool/enqueue.yml +44 -0
  280. data/spec/vcr_cassettes/whm/transfer_tool/pause.yml +44 -0
  281. data/spec/vcr_cassettes/whm/transfer_tool/show_log.yml +44 -0
  282. data/spec/vcr_cassettes/whm/transfer_tool/start.yml +44 -0
  283. data/spec/vcr_cassettes/whm/transfer_tool/status.yml +44 -0
  284. data/spec/vcr_cassettes/whm/transfer_tool/validate_user.yml +44 -0
  285. data/spec/vcr_cassettes/whostmgr/ssl/create.yml +219 -0
  286. data/spec/vcr_cassettes/whostmgr/ssl/remove.yml +172 -0
  287. data/spec/vcr_cassettes/whostmgr/ssl/remove_data.yml +179 -0
  288. data/spec/whm/account_spec.rb +90 -249
  289. data/spec/whm/base_spec.rb +3 -7
  290. data/spec/whm/cert_spec.rb +110 -0
  291. data/spec/whm/dns_spec.rb +37 -155
  292. data/spec/whm/reseller_spec.rb +46 -114
  293. data/spec/whm/server_spec.rb +142 -156
  294. data/spec/whm/transfer_tool_spec.rb +172 -0
  295. data/spec/whm/whm_spec.rb +8 -8
  296. data/spec/whostmgr/ssl_spec.rb +55 -0
  297. metadata +528 -108
  298. data/.gitignore +0 -10
  299. data/.rspec +0 -2
  300. data/.rvmrc +0 -49
  301. data/.travis.yml +0 -11
  302. data/lib/lumberg/whm/args.rb +0 -113
  303. data/lib/net_http_hacked.rb +0 -42
  304. data/lumberg.gemspec +0 -28
  305. data/spec/vcr_cassettes/whm/server/response_type.yml +0 -85
  306. data/spec/whm/args_spec.rb +0 -179
@@ -0,0 +1,639 @@
1
+ require "spec_helper"
2
+
3
+ module Lumberg
4
+ describe Cpanel::Email do
5
+ let(:domain) { "lumberg-test.com" }
6
+ let(:server) { Whm::Server.new(host: @whm_host, hash: @whm_hash) }
7
+ let(:api_username) { "lumberg" }
8
+ let(:email) do
9
+ described_class.new(
10
+ server: server,
11
+ api_username: api_username
12
+ )
13
+ end
14
+
15
+ describe "#main_discard" do
16
+ use_vcr_cassette("cpanel/email/main_discard")
17
+
18
+ it "gets info about main email account undeliverable mail handling" do
19
+ email.main_discard[:params][:data][0].should have_key(:status)
20
+ end
21
+ end
22
+
23
+ describe "#add_mailing_list" do
24
+ use_vcr_cassette("cpanel/email/add_mailing_list")
25
+
26
+ it "adds a mailing list" do
27
+ email.add_mailing_list(
28
+ list: "add-test",
29
+ domain: domain,
30
+ password: "s3cr3t5"
31
+ )
32
+
33
+ email.mailing_lists[:params][:data].find {|l|
34
+ l[:list] == "add-test@#{domain}"
35
+ }.should_not be_nil
36
+ end
37
+ end
38
+
39
+ describe "#mailing_lists" do
40
+ use_vcr_cassette("cpanel/email/mailing_lists")
41
+
42
+ before do
43
+ email.add_mailing_list(
44
+ list: "test-list",
45
+ domain: domain,
46
+ password: "s3cr3t5"
47
+ )
48
+ end
49
+
50
+ it "returns a list of mailing lists" do
51
+ email.mailing_lists[:params][:data].find {|l|
52
+ l[:list] == "test-list@#{domain}"
53
+ }.should_not be_nil
54
+ end
55
+ end
56
+
57
+ describe "#add_forwarder" do
58
+ let(:local) { "fwd-test" }
59
+
60
+ use_vcr_cassette("cpanel/email/add_forwarder")
61
+
62
+ it "adds a forwarder" do
63
+ email.add_forwarder(
64
+ domain: domain,
65
+ email: local,
66
+ fwdopt: :fwd,
67
+ fwdemail: "foo@bar.com"
68
+ )
69
+
70
+ email.forwarders[:params][:data].find {|f|
71
+ f[:dest] == "#{local}@#{domain}"
72
+ }.should_not be_nil
73
+ end
74
+ end
75
+
76
+ describe "#forwarders" do
77
+ let(:local) { "test-fwd" }
78
+
79
+ use_vcr_cassette("cpanel/email/forwarders")
80
+
81
+ before do
82
+ email.add_forwarder(
83
+ domain: domain,
84
+ email: local,
85
+ fwdopt: :fwd,
86
+ fwdemail: "foo@bar.com"
87
+ )
88
+ end
89
+
90
+ it "returns a list of forwarders" do
91
+ email.forwarders[:params][:data].find {|f|
92
+ f[:dest] == "#{local}@#{domain}"
93
+ }.should_not be_nil
94
+ end
95
+ end
96
+
97
+ describe "#domains_with_aliases" do
98
+ let(:local) { "alias-test" }
99
+
100
+ use_vcr_cassette("cpanel/email/domains_with_aliases")
101
+
102
+ before do
103
+ email.add_forwarder(
104
+ domain: domain,
105
+ email: local,
106
+ fwdopt: :fwd,
107
+ fwdemail: "foo@bar.com"
108
+ )
109
+ end
110
+
111
+ it "gets a list of domains that have aliases" do
112
+ email.domains_with_aliases[:params][:data][0][:domain].should == domain
113
+ end
114
+ end
115
+
116
+ describe "#add_account" do
117
+ let(:local) { "account-test" }
118
+
119
+ use_vcr_cassette "cpanel/email/add_account"
120
+
121
+ it "adds an email account" do
122
+ email.add_account(
123
+ domain: domain,
124
+ email: local,
125
+ password: "magicpants",
126
+ quota: 0
127
+ )
128
+
129
+ email.accounts[:params][:data].find {|a|
130
+ a[:email] == "#{local}@#{domain}"
131
+ }.should_not be_nil
132
+ end
133
+ end
134
+
135
+ describe "#edit_quota" do
136
+ let(:local) { "account-test" }
137
+
138
+ use_vcr_cassette "cpanel/email/edit_quota"
139
+
140
+ it "modifies an email account quota" do
141
+ old_quota = email.accounts[:params][:data].find { |a|
142
+ a[:email] == "#{local}@#{domain}"
143
+ }[:_diskquota]
144
+
145
+ email.edit_quota(
146
+ domain: domain,
147
+ email: local,
148
+ quota: 10
149
+ )
150
+
151
+ new_quota = email.accounts[:params][:data].find {|a|
152
+ a[:email] == "#{local}@#{domain}"
153
+ }[:_diskquota].to_i
154
+
155
+ new_quota.should_not == old_quota
156
+ end
157
+ end
158
+
159
+ describe "#remove" do
160
+ let(:local) { "account-test" }
161
+
162
+ use_vcr_cassette "cpanel/email/remove"
163
+
164
+ it "removes an email account" do
165
+ email.remove(
166
+ domain: domain,
167
+ email: "#{local}@#{domain}"
168
+ )
169
+
170
+ email.accounts[:params][:data].find {|a|
171
+ a[:email] == "#{local}@#{domain}"
172
+ }.should be_nil
173
+ end
174
+ end
175
+
176
+
177
+ describe "#accounts" do
178
+ let(:local) { "test-account" }
179
+ let(:email_address) { "#{local}@#{domain}" }
180
+
181
+ use_vcr_cassette("cpanel/email/accounts")
182
+
183
+ before(:each) do
184
+ email.add_account(
185
+ domain: domain,
186
+ email: local,
187
+ password: "sauce",
188
+ quota: 0
189
+ )
190
+ end
191
+
192
+ context ":style option is :with_disk" do
193
+ it "uses Email::listpopswithdisk" do
194
+ email.should_receive(:perform_request).with(
195
+ hash_including(api_function: "listpopswithdisk")
196
+ )
197
+
198
+ email.accounts(style: :with_disk)
199
+ end
200
+
201
+ it "is the default seting" do
202
+ email.should_receive(:perform_request).with(
203
+ hash_including(api_function: "listpopswithdisk")
204
+ )
205
+
206
+ email.accounts
207
+ end
208
+
209
+ it "returns a list of email accounts" do
210
+ data = email.accounts(style: :with_disk)[:params][:data]
211
+ data.any? {|d| d[:email] == email_address }.should be_true
212
+ end
213
+ end
214
+
215
+ context ":style option is :without_disk" do
216
+ it "uses Email::listpops" do
217
+ email.should_receive(:perform_request).with(
218
+ hash_including(api_function: "listpops")
219
+ )
220
+
221
+ email.accounts(style: :without_disk)
222
+ end
223
+
224
+ it "returns a list of email accounts" do
225
+ data = email.accounts(style: :without_disk)[:params][:data]
226
+ data.any? {|d| d[:email] == email_address }.should be_true
227
+ end
228
+ end
229
+
230
+ context ":style option is :with_image" do
231
+ it "uses Email::listpopswithimage" do
232
+ email.should_receive(:perform_request).with(
233
+ hash_including(api_function: "listpopswithimage")
234
+ )
235
+
236
+ email.accounts(style: :with_image)
237
+ end
238
+
239
+ it "returns a list of email accounts" do
240
+ data = email.accounts(style: :with_image)[:params][:data]
241
+ data.any? {|d| d[:email] == email_address }.should be_true
242
+ end
243
+ end
244
+
245
+ context ":style option is :single" do
246
+ it "uses Email::listpopssingle" do
247
+ email.should_receive(:perform_request).with(
248
+ hash_including(api_function: "listpopssingle")
249
+ )
250
+
251
+ email.accounts(style: :single)
252
+ end
253
+
254
+ it "returns a list of email accounts" do
255
+ data = email.accounts(style: :single)[:params][:data]
256
+ data.any? {|d| d[:email] == email_address }.should be_true
257
+ end
258
+ end
259
+ end
260
+
261
+ describe "#domains" do
262
+ use_vcr_cassette("cpanel/email/domains")
263
+
264
+ it "returns a list of domains" do
265
+ email.domains[:params][:data].find {|d|
266
+ d[:domain] == domain
267
+ }.should_not be_nil
268
+ end
269
+ end
270
+
271
+ describe "#add_mx" do
272
+ use_vcr_cassette("cpanel/email/add_mx")
273
+
274
+ it "adds an mx record" do
275
+ email.add_mx(
276
+ domain: domain,
277
+ exchange: "mail.#{domain}",
278
+ preference: 2
279
+ )[:params][:data][0][:status].should eq(1)
280
+ end
281
+ end
282
+
283
+ describe "#change_mx" do
284
+ use_vcr_cassette("cpanel/email/change_mx")
285
+
286
+ it "changes an existing mx record" do
287
+ email.add_mx(
288
+ domain: domain,
289
+ exchange: "mail.#{domain}",
290
+ oldpreference: 2,
291
+ preference: 1
292
+ )[:params][:data][0][:status].should eq(1)
293
+ end
294
+ end
295
+
296
+ describe "#mx" do
297
+ use_vcr_cassette("cpanel/email/mx")
298
+
299
+ it "returns info for each mail exchanger" do
300
+ email.mx[:params][:data][0][:entries].find {|m|
301
+ m[:domain] == domain
302
+ }.should_not be_nil
303
+ end
304
+ end
305
+
306
+ describe "#delete_mx" do
307
+ use_vcr_cassette("cpanel/email/delete_mx")
308
+
309
+ it "delete an existing mx record" do
310
+ email.delete_mx(
311
+ domain: domain,
312
+ exchange: "mail.#{domain}",
313
+ preference: 1
314
+ )[:params][:data][0][:status].should eq(1)
315
+ end
316
+ end
317
+
318
+ describe "#set_mx_type" do
319
+ use_vcr_cassette("cpanel/email/set_mx_type")
320
+
321
+ it "sets an existing mx record to use remote" do
322
+ email.set_mx_type(
323
+ domain: domain,
324
+ mxcheck: "remote"
325
+ )[:params][:data][0][:detected].should == "remote"
326
+ end
327
+ end
328
+
329
+ describe "#set_mail_delivery" do
330
+ let(:detected) do
331
+ email.mx(domain: domain)[:params][:data][0][:detected]
332
+ end
333
+
334
+ use_vcr_cassette("cpanel/email/set_mail_delivery")
335
+
336
+ context "remote delivery" do
337
+ use_vcr_cassette("cpanel/email/set_mail_delivery.remote")
338
+
339
+ it "sets remote mail delivery" do
340
+ email.set_mail_delivery(
341
+ domain: domain,
342
+ delivery: :remote
343
+ )
344
+
345
+ detected.should == "remote"
346
+ end
347
+ end
348
+
349
+ context "local delivery" do
350
+ use_vcr_cassette("cpanel/email/set_mail_delivery.local")
351
+
352
+ it "sets local mail delivery" do
353
+ email.set_mail_delivery(
354
+ domain: domain,
355
+ delivery: :local
356
+ )
357
+
358
+ detected.should == "local"
359
+ end
360
+ end
361
+ end
362
+
363
+ describe "#check_local_delivery" do
364
+ context "local delivery" do
365
+ use_vcr_cassette("cpanel/email/check_local_delivery.local")
366
+
367
+ before do
368
+ email.set_mail_delivery(
369
+ domain: domain,
370
+ delivery: :local
371
+ )
372
+ end
373
+
374
+ it "returns 1" do
375
+ email.check_local_delivery(
376
+ domain: domain
377
+ )[:params][:data][0][:alwaysaccept].should == 1
378
+ end
379
+ end
380
+
381
+ context "remote delivery" do
382
+ use_vcr_cassette("cpanel/email/check_local_delivery.remote")
383
+
384
+ before do
385
+ email.set_mail_delivery(
386
+ domain: domain,
387
+ delivery: :remote
388
+ )
389
+ end
390
+
391
+ it "returns 0" do
392
+ email.check_local_delivery(
393
+ domain: domain
394
+ )[:params][:data][0][:alwaysaccept].should == 0
395
+ end
396
+ end
397
+ end
398
+
399
+ describe "#add_filter" do
400
+ let(:local) { "filters-test" }
401
+ let(:filter_name) { "fail filter" }
402
+
403
+ use_vcr_cassette("cpanel/email/add_filter")
404
+
405
+ before do
406
+ email.add_account(
407
+ email: local,
408
+ domain: domain,
409
+ password: "abcdefg",
410
+ quota: 0
411
+ )
412
+ end
413
+
414
+ it "adds an email filter" do
415
+ result = email.add_filter(
416
+ account: "#{local}@#{domain}",
417
+ filtername: filter_name,
418
+ action1: "fail",
419
+ match1: "is",
420
+ opt1: "and",
421
+ part1: "$header_from:",
422
+ val1: "hi"
423
+ )[:params][:data][0]
424
+
425
+ result[:error].should == 0
426
+ result[:account].should == "#{local}@#{domain}"
427
+ result[:ok].should == 1
428
+ end
429
+ end
430
+
431
+ describe "#filters" do
432
+ let(:local) { "filters-test" }
433
+ let(:filter_name) { "fail filter" }
434
+
435
+ use_vcr_cassette("cpanel/email/filters")
436
+
437
+ before do
438
+ email.add_account(
439
+ email: local,
440
+ domain: domain,
441
+ password: "abcdefg",
442
+ quota: 0
443
+ )
444
+
445
+ email.add_filter(
446
+ account: "#{local}@#{domain}",
447
+ filtername: filter_name,
448
+ action1: "fail",
449
+ match1: "is",
450
+ opt1: "and",
451
+ part1: "$header_from:",
452
+ val1: "hi"
453
+ )
454
+ end
455
+
456
+ it "returns a list of email filters" do
457
+ email.filters(
458
+ account: "#{local}@#{domain}"
459
+ )[:params][:data][0][:filtername].should == filter_name
460
+ end
461
+
462
+ context ":old_style option truthy" do
463
+ it "uses deprecated Email::listfilters" do
464
+ email.should_receive(:perform_request).with(
465
+ hash_including(api_function: "listfilters")
466
+ )
467
+
468
+ email.filters(
469
+ account: "#{local}@#{domain}",
470
+ old_style: true
471
+ )
472
+ end
473
+ end
474
+
475
+ context ":old_style option falsy" do
476
+ it "uses Email::filterlist" do
477
+ email.should_receive(:perform_request).with(
478
+ hash_including(api_function: "filterlist")
479
+ )
480
+
481
+ email.filters(
482
+ account: "#{local}@#{domain}",
483
+ old_style: false
484
+ )
485
+ end
486
+
487
+ it "is the default setting" do
488
+ email.should_receive(:perform_request).with(
489
+ hash_including(api_function: "filterlist")
490
+ )
491
+
492
+ email.filters
493
+ end
494
+ end
495
+ end
496
+
497
+ describe "#acceptable_encodings" do
498
+ use_vcr_cassette "cpanel/email/acceptable_encodings"
499
+
500
+ subject do
501
+ email.acceptable_encodings[:params][:data].find { |m| m[:map] == "utf-8" }[:map]
502
+ end
503
+
504
+ it "lists Cpanel's acceptable character encodings" do
505
+ should == "utf-8"
506
+ end
507
+ end
508
+
509
+ describe "#listautoresponders" do
510
+ use_vcr_cassette("cpanel/email/listautoresponders")
511
+ subject { email.listautoresponders[:params][:data][0] }
512
+ should { be_nil }
513
+ end
514
+
515
+ describe "#listdomainforwards" do
516
+ use_vcr_cassette("cpanel/email/listdomainforwards")
517
+ subject { email.listdomainforwards[:params][:data][0] }
518
+ should { be_nil }
519
+ end
520
+
521
+ describe "#disk_usage" do
522
+ let(:local) { "disk-usage-test" }
523
+
524
+ use_vcr_cassette("cpanel/email/disk_usage")
525
+
526
+ before do
527
+ email.add_account(
528
+ domain: domain,
529
+ email: local,
530
+ password: "s00pers3cr3t",
531
+ quota: 0
532
+ )
533
+ end
534
+
535
+ it "gets disk usage information for an email account" do
536
+ email.disk_usage(
537
+ domain: domain,
538
+ login: local
539
+ )[:params][:data].find {|d|
540
+ d[:login] == local && d[:domain] == domain
541
+ }.should_not be_nil
542
+ end
543
+ end
544
+
545
+ describe "#mail_dir" do
546
+ let(:local) { "mail-dir-test" }
547
+
548
+ use_vcr_cassette("cpanel/email/mail_dir")
549
+
550
+ before do
551
+ email.add_account(
552
+ domain: domain,
553
+ email: local,
554
+ password: "s00pers3cr3t",
555
+ quota: 0
556
+ )
557
+ end
558
+
559
+ it "gets disk usage information for an email account" do
560
+ email.mail_dir(
561
+ account: "#{local}@#{domain}"
562
+ )[:params][:data][0][:absdir].should match(
563
+ /\/mail\/#{domain}\/#{local}/
564
+ )
565
+ end
566
+ end
567
+
568
+ describe "#mail_dirs" do
569
+ let(:local) { "mail-dirs-test" }
570
+
571
+ use_vcr_cassette("cpanel/email/mail_dirs")
572
+
573
+ before do
574
+ email.add_account(
575
+ domain: domain,
576
+ email: local,
577
+ password: "s00pers3cr3t",
578
+ quota: 0
579
+ )
580
+ end
581
+
582
+ it "gets a list of mail-related directories" do
583
+ email.mail_dirs[:params][:data].find {|m|
584
+ m[:fullpath] =~ /\/mail\/#{domain}/
585
+ }.should_not be_nil
586
+ end
587
+ end
588
+
589
+ describe "#default_address" do
590
+ use_vcr_cassette("cpanel/email/default_address")
591
+
592
+ it "gets default address info for a domain" do
593
+ email.default_address(
594
+ domain: domain
595
+ )[:params][:data][0][:domain].should == domain
596
+ end
597
+ end
598
+
599
+ describe "#set_default_address" do
600
+ use_vcr_cassette("cpanel/email/set_default_address")
601
+
602
+ it "sets the default forwarding address for a domain" do
603
+ email.set_default_address(
604
+ domain: 'hello.com',
605
+ fwdopt: :fwd,
606
+ fwdemail: "foo@bar.com"
607
+ )[:params][:data].first.should == 'success'
608
+ end
609
+ end
610
+
611
+ describe "#listfilterbackups" do
612
+ pending
613
+ end
614
+
615
+ describe "#filterlist" do
616
+ pending
617
+ end
618
+
619
+ describe "#tracefilter" do
620
+ pending
621
+ end
622
+
623
+ describe "#fetchautoresponder" do
624
+ pending
625
+ end
626
+
627
+ describe "#change_password" do
628
+ use_vcr_cassette("cpanel/email/change_password")
629
+
630
+ it "Modifies the password an e-mail account" do
631
+ email.change_password(
632
+ domain: 'myhost.com',
633
+ email: 'test123@myhost.com',
634
+ password: 'test123'
635
+ )[:params][:data].first[:result].should == 1
636
+ end
637
+ end
638
+ end
639
+ end
@@ -0,0 +1,73 @@
1
+ require "spec_helper"
2
+
3
+ module Lumberg
4
+ describe Cpanel::FileManager do
5
+ let(:server) { Whm::Server.new(host: @whm_host, hash: @whm_hash) }
6
+ let(:api_username) { "lumberg" }
7
+ let(:file_manager) do
8
+ described_class.new(
9
+ server: server,
10
+ api_username: api_username
11
+ )
12
+ end
13
+
14
+ let(:wanted_file) { '.lastlogin' }
15
+
16
+ describe "#list" do
17
+ use_vcr_cassette "cpanel/file_manager/list"
18
+
19
+ subject { file_manager.list[:params][:data] }
20
+
21
+ it "lists home directory contents" do
22
+ should be_an(Array)
23
+ end
24
+ end
25
+
26
+ describe "#show" do
27
+ use_vcr_cassette "cpanel/file_manager/show"
28
+
29
+ it "gets information about files and directories" do
30
+ result = file_manager.show({ file: wanted_file })
31
+ result[:params][:data][0][:file].should === wanted_file
32
+ end
33
+ end
34
+
35
+ describe "#stat" do
36
+ use_vcr_cassette "cpanel/file_manager/stat"
37
+
38
+ it "gets system information about files" do
39
+ result = file_manager.stat({ file: wanted_file })
40
+ result[:params][:data][0][:user].should === api_username
41
+ end
42
+ end
43
+
44
+ describe "#disk_usage" do
45
+ use_vcr_cassette "cpanel/file_manager/disk_usage"
46
+
47
+ it "shows disk usage" do
48
+ result = file_manager.disk_usage
49
+ result[:params][:data][0][:spaceused].to_i.should > 0
50
+ end
51
+ end
52
+
53
+ describe "#operate" do
54
+ use_vcr_cassette "cpanel/file_manager/operate"
55
+
56
+ it "copies a non-existent file" do
57
+ file_manager.operate({
58
+ name: "copy",
59
+ source_files: ".shouldneverexist",
60
+ destination_files: ".someotherfile"
61
+ })[:params][:data][0][:result].should == 0
62
+ end
63
+
64
+ it "copies a file" do
65
+ file_manager.operate({
66
+ name: "copy",
67
+ source_files: ".lastlogin",
68
+ destination_files: "sample-last-login.txt"
69
+ })[:params][:data][0][:result].should == 1
70
+ end
71
+ end
72
+ end
73
+ end