lumberg 1.0.1 → 2.0.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (248) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +8 -7
  3. data/LICENSE +1 -1
  4. data/README.md +130 -23
  5. data/Rakefile +3 -1
  6. data/lib/lumberg/config.rb +19 -0
  7. data/lib/lumberg/cpanel/addon_domain.rb +50 -0
  8. data/lib/lumberg/cpanel/backups.rb +16 -0
  9. data/lib/lumberg/cpanel/base.rb +56 -0
  10. data/lib/lumberg/cpanel/box_trapper.rb +18 -0
  11. data/lib/lumberg/cpanel/branding.rb +89 -0
  12. data/lib/lumberg/cpanel/contact.rb +38 -0
  13. data/lib/lumberg/cpanel/cron.rb +89 -0
  14. data/lib/lumberg/cpanel/dns_lookup.rb +23 -0
  15. data/lib/lumberg/cpanel/domain_keys.rb +37 -0
  16. data/lib/lumberg/cpanel/domain_lookup.rb +71 -0
  17. data/lib/lumberg/cpanel/email.rb +491 -0
  18. data/lib/lumberg/cpanel/file_manager.rb +146 -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/net.rb +28 -0
  24. data/lib/lumberg/cpanel/park.rb +58 -0
  25. data/lib/lumberg/cpanel/password.rb +52 -0
  26. data/lib/lumberg/cpanel/random_data.rb +25 -0
  27. data/lib/lumberg/cpanel/redirect.rb +44 -0
  28. data/lib/lumberg/cpanel/ssl.rb +206 -0
  29. data/lib/lumberg/cpanel/sub_domain.rb +61 -0
  30. data/lib/lumberg/cpanel/support.rb +29 -0
  31. data/lib/lumberg/cpanel/zone_edit.rb +134 -0
  32. data/lib/lumberg/cpanel.rb +29 -0
  33. data/lib/lumberg/format_whm.rb +125 -0
  34. data/lib/lumberg/version.rb +1 -1
  35. data/lib/lumberg/whm/account.rb +28 -105
  36. data/lib/lumberg/whm/base.rb +3 -7
  37. data/lib/lumberg/whm/cert.rb +76 -0
  38. data/lib/lumberg/whm/dns.rb +49 -77
  39. data/lib/lumberg/whm/reseller.rb +24 -117
  40. data/lib/lumberg/whm/server.rb +111 -230
  41. data/lib/lumberg/whm.rb +2 -1
  42. data/lib/lumberg.rb +34 -8
  43. data/lumberg.gemspec +7 -4
  44. data/spec/config_spec.rb +28 -0
  45. data/spec/cpanel/addon_domain_spec.rb +84 -0
  46. data/spec/cpanel/backups_spec.rb +22 -0
  47. data/spec/cpanel/base_spec.rb +128 -0
  48. data/spec/cpanel/box_trapper_spec.rb +22 -0
  49. data/spec/cpanel/branding_spec.rb +46 -0
  50. data/spec/cpanel/contact_spec.rb +50 -0
  51. data/spec/cpanel/cron_spec.rb +161 -0
  52. data/spec/cpanel/dns_lookup_spec.rb +22 -0
  53. data/spec/cpanel/domain_keys_spec.rb +46 -0
  54. data/spec/cpanel/domain_lookup_spec.rb +77 -0
  55. data/spec/cpanel/email_spec.rb +615 -0
  56. data/spec/cpanel/file_manager_spec.rb +73 -0
  57. data/spec/cpanel/gpg_spec.rb +48 -0
  58. data/spec/cpanel/locale_spec.rb +23 -0
  59. data/spec/cpanel/mime_spec.rb +0 -0
  60. data/spec/cpanel/mysql_spec.rb +0 -0
  61. data/spec/cpanel/net_spec.rb +30 -0
  62. data/spec/cpanel/park_spec.rb +94 -0
  63. data/spec/cpanel/password_spec.rb +35 -0
  64. data/spec/cpanel/random_data_spec.rb +24 -0
  65. data/spec/cpanel/redirect_spec.rb +0 -0
  66. data/spec/cpanel/ssl_spec.rb +148 -0
  67. data/spec/cpanel/sub_domain_spec.rb +72 -0
  68. data/spec/cpanel/support_spec.rb +38 -0
  69. data/spec/cpanel/zone_edit_spec.rb +0 -0
  70. data/spec/sample_certs/cpanel.crt +28 -0
  71. data/spec/sample_certs/cpanel.key +28 -0
  72. data/spec/sample_certs/main.crt +27 -0
  73. data/spec/sample_certs/sample.crt +26 -0
  74. data/spec/sample_certs/sample.key +27 -0
  75. data/spec/spec_helper.rb +9 -3
  76. data/spec/support/cpanel_matchers.rb +17 -0
  77. data/spec/vcr_cassettes/cpanel/addon_domain/add.yml +77 -0
  78. data/spec/vcr_cassettes/cpanel/addon_domain/list.yml +77 -0
  79. data/spec/vcr_cassettes/cpanel/addon_domain/remove.yml +77 -0
  80. data/spec/vcr_cassettes/cpanel/backups/list.yml +40 -0
  81. data/spec/vcr_cassettes/cpanel/box_trapper/list.yml +40 -0
  82. data/spec/vcr_cassettes/cpanel/branding/list_icons.yml +40 -0
  83. data/spec/vcr_cassettes/cpanel/branding/list_image_types.yml +40 -0
  84. data/spec/vcr_cassettes/cpanel/branding/list_object_types.yml +40 -0
  85. data/spec/vcr_cassettes/cpanel/branding/list_pkgs.yml +40 -0
  86. data/spec/vcr_cassettes/cpanel/branding/list_sprites.yml +40 -0
  87. data/spec/vcr_cassettes/cpanel/contact/show.yml +40 -0
  88. data/spec/vcr_cassettes/cpanel/contact/update.yml +40 -0
  89. data/spec/vcr_cassettes/cpanel/cron/add.yml +77 -0
  90. data/spec/vcr_cassettes/cpanel/cron/edit.yml +114 -0
  91. data/spec/vcr_cassettes/cpanel/cron/email.yml +77 -0
  92. data/spec/vcr_cassettes/cpanel/cron/list.yml +77 -0
  93. data/spec/vcr_cassettes/cpanel/cron/remove.yml +151 -0
  94. data/spec/vcr_cassettes/cpanel/cron/set_email.yml +77 -0
  95. data/spec/vcr_cassettes/cpanel/dns_lookup/name_to_ip.yml +40 -0
  96. data/spec/vcr_cassettes/cpanel/domain_keys/add.yml +40 -0
  97. data/spec/vcr_cassettes/cpanel/domain_keys/available.yml +40 -0
  98. data/spec/vcr_cassettes/cpanel/domain_keys/installed.yml +40 -0
  99. data/spec/vcr_cassettes/cpanel/domain_keys/remove.yml +40 -0
  100. data/spec/vcr_cassettes/cpanel/domain_lookup/count.yml +40 -0
  101. data/spec/vcr_cassettes/cpanel/domain_lookup/docroot.yml +40 -0
  102. data/spec/vcr_cassettes/cpanel/domain_lookup/docroots.yml +40 -0
  103. data/spec/vcr_cassettes/cpanel/domain_lookup/document_root.yml +40 -0
  104. data/spec/vcr_cassettes/cpanel/domain_lookup/document_roots.yml +40 -0
  105. data/spec/vcr_cassettes/cpanel/domain_lookup/list.yml +40 -0
  106. data/spec/vcr_cassettes/cpanel/email/acceptable_encodings.yml +40 -0
  107. data/spec/vcr_cassettes/cpanel/email/accounts.yml +188 -0
  108. data/spec/vcr_cassettes/cpanel/email/add_account.yml +77 -0
  109. data/spec/vcr_cassettes/cpanel/email/add_filter.yml +77 -0
  110. data/spec/vcr_cassettes/cpanel/email/add_forwarder.yml +77 -0
  111. data/spec/vcr_cassettes/cpanel/email/add_mailing_list.yml +73 -0
  112. data/spec/vcr_cassettes/cpanel/email/add_mx.yml +40 -0
  113. data/spec/vcr_cassettes/cpanel/email/change_mx.yml +40 -0
  114. data/spec/vcr_cassettes/cpanel/email/check_local_delivery_local.yml +77 -0
  115. data/spec/vcr_cassettes/cpanel/email/check_local_delivery_remote.yml +77 -0
  116. data/spec/vcr_cassettes/cpanel/email/default_address.yml +40 -0
  117. data/spec/vcr_cassettes/cpanel/email/delete_mx.yml +40 -0
  118. data/spec/vcr_cassettes/cpanel/email/disk_usage.yml +77 -0
  119. data/spec/vcr_cassettes/cpanel/email/domains.yml +40 -0
  120. data/spec/vcr_cassettes/cpanel/email/domains_with_aliases.yml +77 -0
  121. data/spec/vcr_cassettes/cpanel/email/edit_quota.yml +112 -0
  122. data/spec/vcr_cassettes/cpanel/email/filters.yml +114 -0
  123. data/spec/vcr_cassettes/cpanel/email/forwarders.yml +77 -0
  124. data/spec/vcr_cassettes/cpanel/email/mail_dir.yml +77 -0
  125. data/spec/vcr_cassettes/cpanel/email/mail_dirs.yml +77 -0
  126. data/spec/vcr_cassettes/cpanel/email/mailing_lists.yml +73 -0
  127. data/spec/vcr_cassettes/cpanel/email/main_discard.yml +40 -0
  128. data/spec/vcr_cassettes/cpanel/email/mx.yml +40 -0
  129. data/spec/vcr_cassettes/cpanel/email/remove.yml +77 -0
  130. data/spec/vcr_cassettes/cpanel/email/set_mail_delivery_local.yml +77 -0
  131. data/spec/vcr_cassettes/cpanel/email/set_mail_delivery_remote.yml +77 -0
  132. data/spec/vcr_cassettes/cpanel/email/set_mx_type.yml +40 -0
  133. data/spec/vcr_cassettes/cpanel/file_manager/disk_usage.yml +38 -0
  134. data/spec/vcr_cassettes/cpanel/file_manager/list.yml +38 -0
  135. data/spec/vcr_cassettes/cpanel/file_manager/operate.yml +77 -0
  136. data/spec/vcr_cassettes/cpanel/file_manager/show.yml +40 -0
  137. data/spec/vcr_cassettes/cpanel/file_manager/stat.yml +38 -0
  138. data/spec/vcr_cassettes/cpanel/gpg/count.yml +40 -0
  139. data/spec/vcr_cassettes/cpanel/gpg/count_private.yml +40 -0
  140. data/spec/vcr_cassettes/cpanel/gpg/list.yml +40 -0
  141. data/spec/vcr_cassettes/cpanel/gpg/list_private.yml +40 -0
  142. data/spec/vcr_cassettes/cpanel/locale/show.yml +40 -0
  143. data/spec/vcr_cassettes/cpanel/net/query_hostname.yml +40 -0
  144. data/spec/vcr_cassettes/cpanel/net/traceroute.yml +40 -0
  145. data/spec/vcr_cassettes/cpanel/park/add.yml +77 -0
  146. data/spec/vcr_cassettes/cpanel/park/list.yml +77 -0
  147. data/spec/vcr_cassettes/cpanel/park/list_addon_domains.yml +77 -0
  148. data/spec/vcr_cassettes/cpanel/park/remove.yml +77 -0
  149. data/spec/vcr_cassettes/cpanel/password/digest_authentication.yml +77 -0
  150. data/spec/vcr_cassettes/cpanel/password/modify.yml +77 -0
  151. data/spec/vcr_cassettes/cpanel/random_data/show.yml +40 -0
  152. data/spec/vcr_cassettes/cpanel/ssl/fetchcabundle.yml +40 -0
  153. data/spec/vcr_cassettes/cpanel/ssl/gencrt.yml +43 -0
  154. data/spec/vcr_cassettes/cpanel/ssl/gencsr.yml +43 -0
  155. data/spec/vcr_cassettes/cpanel/ssl/genkey.yml +40 -0
  156. data/spec/vcr_cassettes/cpanel/ssl/installssl.yml +40 -0
  157. data/spec/vcr_cassettes/cpanel/ssl/listcrts.yml +40 -0
  158. data/spec/vcr_cassettes/cpanel/ssl/listcsrs.yml +40 -0
  159. data/spec/vcr_cassettes/cpanel/ssl/listkeys.yml +40 -0
  160. data/spec/vcr_cassettes/cpanel/ssl/listsslitems.yml +40 -0
  161. data/spec/vcr_cassettes/cpanel/ssl/showcrt.yml +38 -0
  162. data/spec/vcr_cassettes/cpanel/ssl/showcsr.yml +38 -0
  163. data/spec/vcr_cassettes/cpanel/ssl/showkey.yml +38 -0
  164. data/spec/vcr_cassettes/cpanel/ssl/uploadcrt.yml +40 -0
  165. data/spec/vcr_cassettes/cpanel/sub_domain/add.yml +77 -0
  166. data/spec/vcr_cassettes/cpanel/sub_domain/list.yml +77 -0
  167. data/spec/vcr_cassettes/cpanel/sub_domain/remove.yml +77 -0
  168. data/spec/vcr_cassettes/cpanel/support/contactable.yml +40 -0
  169. data/spec/vcr_cassettes/whm/account/accountsummary.yml +41 -29
  170. data/spec/vcr_cassettes/whm/account/changepackage.yml +73 -43
  171. data/spec/vcr_cassettes/whm/account/createacct.yml +101 -31
  172. data/spec/vcr_cassettes/whm/account/domainuserdata.yml +43 -29
  173. data/spec/vcr_cassettes/whm/account/editquota.yml +78 -57
  174. data/spec/vcr_cassettes/whm/account/limitbw.yml +79 -57
  175. data/spec/vcr_cassettes/whm/account/listaccts.yml +195 -100
  176. data/spec/vcr_cassettes/whm/account/listsuspended.yml +41 -29
  177. data/spec/vcr_cassettes/whm/account/modifyacct.yml +61 -42
  178. data/spec/vcr_cassettes/whm/account/myprivs.yml +41 -29
  179. data/spec/vcr_cassettes/whm/account/passwd.yml +44 -29
  180. data/spec/vcr_cassettes/whm/account/removeacct.yml +134 -57
  181. data/spec/vcr_cassettes/whm/account/restoreaccount.yml +310 -135
  182. data/spec/vcr_cassettes/whm/account/setsiteip.yml +166 -127
  183. data/spec/vcr_cassettes/whm/account/suspend.yml +75 -43
  184. data/spec/vcr_cassettes/whm/account/unsuspend.yml +46 -29
  185. data/spec/vcr_cassettes/whm/cert/fetchsslinfo.yml +38 -0
  186. data/spec/vcr_cassettes/whm/cert/generatessl.yml +94 -0
  187. data/spec/vcr_cassettes/whm/cert/installssl.yml +38 -0
  188. data/spec/vcr_cassettes/whm/cert/listcrts.yml +38 -0
  189. data/spec/vcr_cassettes/whm/dns/adddns.yml +61 -43
  190. data/spec/vcr_cassettes/whm/dns/addzonerecord.yml +42 -29
  191. data/spec/vcr_cassettes/whm/dns/dumpzone.yml +44 -29
  192. data/spec/vcr_cassettes/whm/dns/editzonerecord.yml +61 -43
  193. data/spec/vcr_cassettes/whm/dns/getzonerecord.yml +60 -43
  194. data/spec/vcr_cassettes/whm/dns/killdns.yml +42 -29
  195. data/spec/vcr_cassettes/whm/dns/listmxs.yml +23 -15
  196. data/spec/vcr_cassettes/whm/dns/listzones.yml +22 -15
  197. data/spec/vcr_cassettes/whm/dns/lookupnsip.yml +40 -29
  198. data/spec/vcr_cassettes/whm/dns/removezonerecord.yml +61 -43
  199. data/spec/vcr_cassettes/whm/dns/resetzone.yml +42 -29
  200. data/spec/vcr_cassettes/whm/dns/resolvedomainname.yml +40 -29
  201. data/spec/vcr_cassettes/whm/dns/savemxs.yml +23 -15
  202. data/spec/vcr_cassettes/whm/reseller/acctcounts.yml +41 -29
  203. data/spec/vcr_cassettes/whm/reseller/listacls.yml +22 -15
  204. data/spec/vcr_cassettes/whm/reseller/listresellers.yml +22 -15
  205. data/spec/vcr_cassettes/whm/reseller/resellerstats.yml +42 -29
  206. data/spec/vcr_cassettes/whm/reseller/saveacllist.yml +76 -57
  207. data/spec/vcr_cassettes/whm/reseller/setacls.yml +40 -29
  208. data/spec/vcr_cassettes/whm/reseller/setresellerips.yml +42 -28
  209. data/spec/vcr_cassettes/whm/reseller/setresellerlimits.yml +41 -29
  210. data/spec/vcr_cassettes/whm/reseller/setresellermainip.yml +59 -43
  211. data/spec/vcr_cassettes/whm/reseller/setresellernameservers.yml +58 -43
  212. data/spec/vcr_cassettes/whm/reseller/setresellerpackagelimit.yml +61 -43
  213. data/spec/vcr_cassettes/whm/reseller/setupreseller.yml +41 -29
  214. data/spec/vcr_cassettes/whm/reseller/suspendreseller.yml +75 -44
  215. data/spec/vcr_cassettes/whm/reseller/terminatereseller.yml +83 -46
  216. data/spec/vcr_cassettes/whm/reseller/unsetupreseller.yml +41 -29
  217. data/spec/vcr_cassettes/whm/reseller/unsuspendreseller.yml +46 -29
  218. data/spec/vcr_cassettes/whm/server/addip.yml +24 -15
  219. data/spec/vcr_cassettes/whm/server/applist.yml +22 -15
  220. data/spec/vcr_cassettes/whm/server/delip.yml +23 -15
  221. data/spec/vcr_cassettes/whm/server/gethostname.yml +22 -15
  222. data/spec/vcr_cassettes/whm/server/getlanglist.yml +22 -15
  223. data/spec/vcr_cassettes/whm/server/gettweaksetting.yml +44 -0
  224. data/spec/vcr_cassettes/whm/server/listips.yml +22 -15
  225. data/spec/vcr_cassettes/whm/server/loadavg.yml +26 -19
  226. data/spec/vcr_cassettes/whm/server/my_function.yml +59 -43
  227. data/spec/vcr_cassettes/whm/server/nvget.yml +22 -15
  228. data/spec/vcr_cassettes/whm/server/nvset.yml +22 -15
  229. data/spec/vcr_cassettes/whm/server/reboot.yml +22 -15
  230. data/spec/vcr_cassettes/whm/server/sethostname.yml +24 -15
  231. data/spec/vcr_cassettes/whm/server/setresolvers.yml +23 -15
  232. data/spec/vcr_cassettes/whm/server/settweaksetting.yml +44 -0
  233. data/spec/vcr_cassettes/whm/server/showbw.yml +22 -15
  234. data/spec/vcr_cassettes/whm/server/systemloadavg.yml +40 -29
  235. data/spec/vcr_cassettes/whm/server/themes.yml +38 -0
  236. data/spec/vcr_cassettes/whm/server/version.yml +22 -15
  237. data/spec/whm/account_spec.rb +40 -199
  238. data/spec/whm/base_spec.rb +0 -4
  239. data/spec/whm/cert_spec.rb +99 -0
  240. data/spec/whm/dns_spec.rb +5 -123
  241. data/spec/whm/reseller_spec.rb +11 -79
  242. data/spec/whm/server_spec.rb +85 -142
  243. metadata +367 -47
  244. data/.rvmrc +0 -49
  245. data/lib/lumberg/whm/args.rb +0 -113
  246. data/lib/net_http_hacked.rb +0 -42
  247. data/spec/vcr_cassettes/whm/server/response_type.yml +0 -85
  248. data/spec/whm/args_spec.rb +0 -179
@@ -12,34 +12,19 @@ module Lumberg
12
12
  describe "#create" do
13
13
  use_vcr_cassette "whm/account/createacct"
14
14
 
15
- it "requires a username" do
16
- requires_attr('username') { @account.create }
17
- end
18
-
19
- it "requires a domain" do
20
- requires_attr('domain') { @account.create(:username => 'user') }
21
- end
22
-
23
- it "requires a password" do
24
- requires_attr('password') {
25
- @account.create(:username => 'user', :domain => 'example.com')
26
- }
27
- end
28
-
29
15
  it "creates the account with proper params" do
30
16
  result = @account.create(:username => 'valid', :password => 'hummingbird123', :domain => 'valid-thing.com')
31
17
  result[:success].should be_true
32
18
  result[:message].should match(/Account Creation Ok/i)
33
19
  result[:params].should_not be_empty
34
20
  result[:params].should have_key(:options)
35
- result[:params][:options].should include(:nameserver4, :nameserver, :nameserverentry2, :nameserverentry3,
36
- :nameserverentry4, :nameserverentry, :ip, :nameservera2,
37
- :nameservera3, :package, :nameservera4, :nameserver2,
21
+ result[:params][:options].should include(:nameserver4, :nameserver, :nameserverentry2, :nameserverentry3,
22
+ :nameserverentry4, :nameserverentry, :ip, :nameservera2,
23
+ :nameservera3, :package, :nameservera4, :nameserver2,
38
24
  :nameservera, :nameserver3)
39
25
  end
40
26
 
41
27
  it "returns an error on duplicate accounts" do
42
- @account.create(:username => 'invalid', :password => 'hummingbird123', :domain => 'invalid-thing.com')
43
28
  result = @account.create(:username => 'invalid', :password => 'hummingbird123', :domain => 'invalid-thing.com')
44
29
  result[:success].should be(false)
45
30
  result[:message].should match(/username already exists/i)
@@ -49,10 +34,6 @@ module Lumberg
49
34
  describe "#remove" do
50
35
  use_vcr_cassette "whm/account/removeacct"
51
36
 
52
- it "requires a username" do
53
- requires_attr('username') { @account.remove }
54
- end
55
-
56
37
  it "removes a user and keeps DNS by default" do
57
38
  result = @account.remove(:username => 'removeme')
58
39
  result[:success].should be_true
@@ -81,14 +62,6 @@ module Lumberg
81
62
  describe "#change_password" do
82
63
  use_vcr_cassette "whm/account/passwd"
83
64
 
84
- it "requires a username" do
85
- requires_attr('username') { @account.change_password }
86
- end
87
-
88
- it "requires a password" do
89
- requires_attr('password') { @account.change_password(:username => 'changeme') }
90
- end
91
-
92
65
  it "changes the password" do
93
66
  result = @account.change_password(:username => 'changeme', :password => 'superpass')
94
67
  result[:success].should be_true
@@ -105,14 +78,6 @@ module Lumberg
105
78
  describe "#limit bandwidth" do
106
79
  use_vcr_cassette "whm/account/limitbw"
107
80
 
108
- it "requires a user" do
109
- requires_attr('username') { @account.limit_bandwidth(:bwlimit => 99999) }
110
- end
111
-
112
- it "requires a bandwidth" do
113
- requires_attr('bwlimit') { @account.limit_bandwidth(:username => 'changeme') }
114
- end
115
-
116
81
  it "sets the bandwidth limit" do
117
82
  result = @account.limit_bandwidth(:username => 'changeme', :bwlimit => 99999)
118
83
  result[:success].should be_true
@@ -122,11 +87,11 @@ module Lumberg
122
87
  end
123
88
 
124
89
  it "isn't successful when the user doesn't exist" do
125
- expect {
126
- @account.limit_bandwidth(:username => 'notexists', :bwlimit => 99999)
90
+ expect {
91
+ @account.limit_bandwidth(:username => 'notexists', :bwlimit => 99999)
127
92
  }.to raise_error(WhmInvalidUser, /User notexists does not exist/i)
128
93
  end
129
- end
94
+ end
130
95
 
131
96
  describe "#list" do
132
97
  use_vcr_cassette "whm/account/listaccts"
@@ -166,7 +131,7 @@ module Lumberg
166
131
  result[:success].should be_true
167
132
  result[:params][:acct].should have(1).account
168
133
  end
169
- end
134
+ end
170
135
 
171
136
  describe "#modify" do
172
137
  use_vcr_cassette "whm/account/modifyacct"
@@ -185,7 +150,7 @@ module Lumberg
185
150
 
186
151
  it "returns the bandwidth limit" do
187
152
  result = @account.modify(:username => 'changeme')
188
- result[:params][:newcfg][:cpuser][:BWLIMIT].should == "unlimited"
153
+ result[:params][:newcfg][:cpuser][:BWLIMIT].should == "unlimited"
189
154
  end
190
155
 
191
156
  it "returns the primary contact email" do
@@ -207,7 +172,7 @@ module Lumberg
207
172
  result = @account.modify(:username => 'changeme')
208
173
  result[:params][:newcfg][:cpuser][:HASCGI].should be_true
209
174
  end
210
- end
175
+ end
211
176
 
212
177
  describe "#editquota" do
213
178
  use_vcr_cassette "whm/account/editquota"
@@ -233,9 +198,6 @@ module Lumberg
233
198
 
234
199
  describe "#summary" do
235
200
  use_vcr_cassette "whm/account/accountsummary"
236
- it "requires a user" do
237
- requires_attr('username') { @account.create }
238
- end
239
201
 
240
202
  it "returns an error for invalid users" do
241
203
  result = @account.summary(:username => 'notexists')
@@ -248,15 +210,11 @@ module Lumberg
248
210
  result[:success].should be_true
249
211
  result[:message].should match(/ok/i)
250
212
  end
251
- end
213
+ end
252
214
 
253
215
  describe "#suspend" do
254
216
  use_vcr_cassette "whm/account/suspend"
255
217
 
256
- it "requires a username" do
257
- requires_attr('username') { @account.suspend }
258
- end
259
-
260
218
  it "returns an error for invalid users" do
261
219
  result = @account.suspend(:username => 'notexists')
262
220
  result[:success].should_not be_true
@@ -273,13 +231,10 @@ module Lumberg
273
231
  @account.server.should_receive(:perform_request).with('suspendacct', hash_including(:user => 'suspendme', :reason => 'abusive user'))
274
232
  @account.suspend(:username => 'suspendme', :reason => 'abusive user')
275
233
  end
276
- end
234
+ end
277
235
 
278
236
  describe "#unsuspend" do
279
237
  use_vcr_cassette "whm/account/unsuspend"
280
- it "require a username" do
281
- requires_attr('username') { @account.unsuspend }
282
- end
283
238
 
284
239
  it "returns an error for invalid users" do
285
240
  result = @account.unsuspend(:username => 'notexists')
@@ -292,10 +247,11 @@ module Lumberg
292
247
  result[:success].should be_true
293
248
  result[:message].should match(/unsuspending .* account/i)
294
249
  end
295
- end
250
+ end
296
251
 
297
252
  describe "#list_suspended" do
298
253
  use_vcr_cassette 'whm/account/listsuspended'
254
+
299
255
  it "returns non-empty result" do
300
256
  # empty isn't a real param. VCR Hacks
301
257
  result = @account.list_suspended(:empty => true)
@@ -309,7 +265,7 @@ module Lumberg
309
265
  result[:success].should be_true
310
266
  result[:params][:accts].should be_empty
311
267
  end
312
- end
268
+ end
313
269
 
314
270
  describe "#change package" do
315
271
  use_vcr_cassette "whm/account/changepackage"
@@ -320,14 +276,6 @@ module Lumberg
320
276
  result[:message].should match(/user notexists does not exist/i)
321
277
  end
322
278
 
323
- it "requires a username" do
324
- requires_attr('username') { @account.change_package(:pkg => '') }
325
- end
326
-
327
- it "requires a pkg" do
328
- requires_attr('pkg') { @account.change_package(:username => 'changeme') }
329
- end
330
-
331
279
  it "fails if the package was not found" do
332
280
  result = @account.change_package(:username => 'changeme', :pkg => 'fakepackage')
333
281
  result[:success].should_not be_true
@@ -339,13 +287,10 @@ module Lumberg
339
287
  result[:success].should be_true
340
288
  result[:message].should match(/Account Upgrade\/Downgrade Complete for changeme/i)
341
289
  end
342
- end
290
+ end
343
291
 
344
292
  describe "#privs" do
345
293
  use_vcr_cassette 'whm/account/myprivs'
346
- it "requires a user" do
347
- requires_attr('username') { @account.privs }
348
- end
349
294
 
350
295
  it "has a result" do
351
296
  result = @account.privs(:username => 'privs')
@@ -353,12 +298,12 @@ module Lumberg
353
298
 
354
299
  params = result[:params]
355
300
  expected = {
356
- :kill_dns => false, :edit_dns => false, :edit_mx => false, :add_pkg => false,
357
- :suspend_acct => false, :add_pkg_shell => false, :viewglobalpackages => false,
358
- :resftp => false, :list_accts => false, :all => true, :passwd => false, :quota => false,
359
- :park_dns => false, :rearrange_accts => false, :allow_addoncreate => false, :demo => false,
360
- :news => false, :edit_account => false, :allow_unlimited_disk_pkgs => false, :allow_parkedcreate => false,
361
- :frontpage => false, :restart => false, :ssl_gencrt => false, :allow_unlimited_pkgs => false,
301
+ :kill_dns => false, :edit_dns => false, :edit_mx => false, :add_pkg => false,
302
+ :suspend_acct => false, :add_pkg_shell => false, :viewglobalpackages => false,
303
+ :resftp => false, :list_accts => false, :all => true, :passwd => false, :quota => false,
304
+ :park_dns => false, :rearrange_accts => false, :allow_addoncreate => false, :demo => false,
305
+ :news => false, :edit_account => false, :allow_unlimited_disk_pkgs => false, :allow_parkedcreate => false,
306
+ :frontpage => false, :restart => false, :ssl_gencrt => false, :allow_unlimited_pkgs => false,
362
307
  :add_pkg_ip => false, :disallow_shell => false, :res_cart => false, :ssl_buy => false, :kill_acct => false,
363
308
  :allow_unlimited_bw_pkgs => false, :create_dns => false, :mailcheck => false, :clustering => false, :ssl => false,
364
309
  :edit_pkg => false, :locale_edit => false, :show_bandwidth => false, :upgrade_account => false, :thirdparty => false,
@@ -366,7 +311,7 @@ module Lumberg
366
311
 
367
312
  params.should include(expected)
368
313
  end
369
- end
314
+ end
370
315
 
371
316
  describe "#domainuserdata" do
372
317
  use_vcr_cassette "whm/account/domainuserdata"
@@ -377,10 +322,6 @@ module Lumberg
377
322
  result[:message].should match(/Unable to determine account owner for domain\./i)
378
323
  end
379
324
 
380
- it "requires a domain" do
381
- requires_attr('domain') { @account.domain_user_data }
382
- end
383
-
384
325
  it "returns the correct data" do
385
326
  result = @account.domain_user_data(:domain => 'example.com')
386
327
  result[:success].should be_true
@@ -398,19 +339,11 @@ module Lumberg
398
339
  result[:params][:servername].should == "example.com"
399
340
  result[:params][:user].should == "changeme"
400
341
  end
401
- end
342
+ end
402
343
 
403
344
  describe "#setsiteip" do
404
345
  use_vcr_cassette "whm/account/setsiteip"
405
346
 
406
- it "requires an ip" do
407
- requires_attr('ip') { @account.set_site_ip }
408
- end
409
-
410
- it "requires a username or a domain" do
411
- expect { @account.set_site_ip(:ip => '1.1.1.1') }.to raise_error(WhmArgumentError, /may include only one of 'username, domain'/i)
412
- end
413
-
414
347
  it "accepts a username for the account to use" do
415
348
  result = @account.set_site_ip(:ip => '192.1.2.3', :username => 'changeme')
416
349
  result[:success].should be_true
@@ -426,131 +359,39 @@ module Lumberg
426
359
  result[:success].should be_true
427
360
  result[:message].should match(/OK/i)
428
361
  end
429
- end
362
+ end
430
363
 
431
364
  describe "#restore" do
432
365
  # 11.27/11.28+ only
433
366
  use_vcr_cassette "whm/account/restoreaccount"
434
- it "requires api.version" do
435
- requires_attr('api.version') {
436
- @account.restore_account(:username => 'changeme',
437
- :type => 'monthly',
438
- :all => false,
439
- :ip => false,
440
- :mail => false,
441
- :mysql => false,
442
- :subs => false)
443
- }
444
- end
445
-
446
- it "requires a username" do
447
- requires_attr('username') {
448
- @account.restore_account("api.version".to_sym => 1,
449
- :type => 'monthly',
450
- :all => false,
451
- :ip => false,
452
- :mail => false,
453
- :mysql => false,
454
- :subs => false)
455
- }
456
- end
457
-
458
- it "requires type" do
459
- requires_attr('type') {
460
- @account.restore_account("api.version".to_sym => 1,
461
- :username => 'changeme',
462
- :all => false,
463
- :ip => false,
464
- :mail => false,
465
- :mysql => false,
466
- :subs => false)
467
- }
468
- end
469
-
470
- it "requires all" do
471
- requires_attr('all') {
472
- @account.restore_account("api.version".to_sym => 1,
473
- :username => 'changeme',
474
- :type => 'monthly',
475
- :ip => false,
476
- :mail => false,
477
- :mysql => false,
478
- :subs => false)
479
- }
480
- end
481
-
482
- it "requires ip" do
483
- requires_attr('ip') {
484
- @account.restore_account("api.version".to_sym => 1,
485
- :username => 'changeme',
486
- :type => 'monthly',
487
- :all => false,
488
- :mail => false,
489
- :mysql => false,
490
- :subs => false)
491
- }
492
- end
493
-
494
- it "requires mail" do
495
- requires_attr('mail') { @account.restore_account("api.version".to_sym => 1,
496
- :username => 'changeme',
497
- :type => 'monthly',
498
- :all => false,
499
- :ip => false,
500
- :mysql => false,
501
- :subs => false)
502
- }
503
- end
504
-
505
- it "requires mysql" do
506
- requires_attr('mysql') { @account.restore_account("api.version".to_sym => 1,
507
- :username => 'changeme',
508
- :type => 'monthly',
509
- :all => false,
510
- :ip => false,
511
- :mail => false,
512
- :subs => false)
513
- }
514
- end
515
-
516
- it "require subs" do
517
- requires_attr('subs') { @account.restore_account("api.version".to_sym => 1,
518
- :username => 'changeme',
519
- :type => 'monthly',
520
- :all => false,
521
- :ip => false,
522
- :mail => false,
523
- :mysql => false)
524
- }
525
- end
526
367
 
527
368
  it "returns an error if it can't find the backup" do
528
- result = @account.restore_account("api.version".to_sym => 1,
529
- :username => 'notexists',
530
- :type => 'daily',
531
- :all => false,
532
- :ip => false,
533
- :mail => false,
534
- :mysql => false,
369
+ result = @account.restore_account("api.version".to_sym => 1,
370
+ :username => 'notexists',
371
+ :type => 'daily',
372
+ :all => false,
373
+ :ip => false,
374
+ :mail => false,
375
+ :mysql => false,
535
376
  :subs => false)
536
377
  result[:params][:result].to_i.should == 0
537
378
  result[:params][:reason].should match(/Unable to find archive/i)
538
379
  end
539
380
 
540
381
  it "restores the account" do
541
- result = @account.restore_account("api.version".to_sym => 1,
542
- :username => 'changeme',
543
- :type => 'daily',
544
- :all => false,
545
- :ip => false,
546
- :mail => false,
547
- :mysql => false,
382
+ result = @account.restore_account("api.version".to_sym => 1,
383
+ :username => 'changeme',
384
+ :type => 'daily',
385
+ :all => false,
386
+ :ip => false,
387
+ :mail => false,
388
+ :mysql => false,
548
389
  :subs => false)
549
390
  result[:params][:result].to_i.should == 1
550
391
  result[:params][:reason].should == "OK"
551
392
  result[:params][:output][:raw].should match(/Account Restore Complete/i)
552
393
  end
553
- end
394
+ end
554
395
 
555
396
  describe "#verify_user" do
556
397
  use_vcr_cassette "whm/account/accountsummary"
@@ -559,7 +400,7 @@ module Lumberg
559
400
 
560
401
  it "does not call the block if the user doesn't exist" do
561
402
  @something.should_not_receive(:gold)
562
- expect {
403
+ expect {
563
404
  @account.send(:verify_user, 'notexists') do
564
405
  @something.gold
565
406
  end
@@ -10,10 +10,6 @@ module Lumberg
10
10
  end
11
11
 
12
12
  describe "#initialize" do
13
- it "creates a new instance of server" do
14
- expect { Whm::Base.new }.to raise_error(WhmArgumentError, /Missing required param/)
15
- end
16
-
17
13
  it "allows a server instance to be passed in" do
18
14
  @base.server.should be_a(Whm::Server)
19
15
  end
@@ -0,0 +1,99 @@
1
+ require 'spec_helper'
2
+ require 'lumberg/whm'
3
+ CERT = File.read('./spec/sample_certs/main.crt')
4
+ SELF_CERT = File.read('./spec/sample_certs/sample.crt')
5
+ SELF_KEY = File.read('./spec/sample_certs/sample.key')
6
+
7
+ module Lumberg
8
+ describe Whm::Cert do
9
+ before(:each) do
10
+ @login = { :host => @whm_host, :hash => @whm_hash }
11
+ @server = Whm::Server.new(@login.dup)
12
+ @cert = Whm::Cert.new(:server => @server.dup)
13
+ end
14
+
15
+ describe "#listcrts" do
16
+ use_vcr_cassette "whm/cert/listcrts"
17
+
18
+ it "lists installed certificates" do
19
+ result = @cert.listcrts
20
+ result[:success].should be_true
21
+ result[:message].should be_true
22
+ end
23
+ end
24
+
25
+ describe "#fetchsslinfo" do
26
+ use_vcr_cassette "whm/cert/fetchsslinfo"
27
+
28
+ it "displays the SSL certificate, private key, and CA bundle/intermediate certificate associated with a specified domain" do
29
+ result = @cert.fetchsslinfo(:domain => "myhost.com", :crtdata => CERT)
30
+ result[:success].should be_true
31
+ result[:message].should match("ok")
32
+ result[:params][:crt].should match(/.*BEGIN CERTIFICATE.*/)
33
+ result[:params][:key].should match(/.*KEY.*/)
34
+ end
35
+ end
36
+
37
+ describe "#generatessl" do
38
+ use_vcr_cassette "whm/cert/generatessl"
39
+
40
+ context "generating a new CSR" do
41
+ subject do
42
+ @cert.generatessl(
43
+ :city => "houston",
44
+ :host => "myhost.com",
45
+ :country => "US",
46
+ :state => "TX",
47
+ :company => "Company",
48
+ :company_division => "Dept",
49
+ :email => "test@myhost.com",
50
+ :pass => "abc123",
51
+ :xemail => "",
52
+ :noemail => 1
53
+ )
54
+ end
55
+
56
+ its([:success]) { should be_true }
57
+ its([:message]) { should == "Key, Certificate, and CSR generated OK" }
58
+
59
+ its([:params]) { should have_key :csr }
60
+ its([:params]) { should have_key :key }
61
+ its([:params]) { should have_key :cert }
62
+ end
63
+
64
+ context "generating a new CSR with an ampersand in company name" do
65
+ subject do
66
+ @cert.generatessl(
67
+ :city => "houston",
68
+ :host => "myhost.com",
69
+ :country => "US",
70
+ :state => "TX",
71
+ :company => "Foo & Bar",
72
+ :company_division => "Dept",
73
+ :email => "test@myhost.com",
74
+ :pass => "abc123",
75
+ :xemail => "",
76
+ :noemail => 1
77
+ )
78
+ end
79
+
80
+ its([:success]) { should be_true }
81
+ its([:message]) { should == "Key, Certificate, and CSR generated OK" }
82
+
83
+ its([:params]) { should have_key :csr }
84
+ its([:params]) { should have_key :key }
85
+ its([:params]) { should have_key :cert }
86
+ end
87
+ end
88
+
89
+ describe "#installssl" do
90
+ use_vcr_cassette "whm/cert/installssl"
91
+
92
+ it "installs a certificate" do
93
+ result = @cert.installssl(:domain => 'check.com', :user => "nobody", :cert => SELF_CERT, :key => SELF_KEY, :ip => '192.1.2.3')
94
+ result[:success].should be_true
95
+ result[:message].should match(/Certificate successfully installed/)
96
+ end
97
+ end
98
+ end
99
+ end