lumberg 1.1.1 → 2.0.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +1 -6
  3. data/README.md +130 -23
  4. data/lib/lumberg.rb +2 -0
  5. data/lib/lumberg/cpanel.rb +29 -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 +491 -0
  17. data/lib/lumberg/cpanel/file_manager.rb +146 -0
  18. data/lib/lumberg/cpanel/gpg.rb +36 -0
  19. data/lib/lumberg/cpanel/locale.rb +15 -0
  20. data/lib/lumberg/cpanel/mime.rb +34 -0
  21. data/lib/lumberg/cpanel/mysql.rb +66 -0
  22. data/lib/lumberg/cpanel/net.rb +28 -0
  23. data/lib/lumberg/cpanel/park.rb +58 -0
  24. data/lib/lumberg/cpanel/password.rb +52 -0
  25. data/lib/lumberg/cpanel/random_data.rb +25 -0
  26. data/lib/lumberg/cpanel/redirect.rb +44 -0
  27. data/lib/lumberg/cpanel/ssl.rb +198 -0
  28. data/lib/lumberg/cpanel/sub_domain.rb +61 -0
  29. data/lib/lumberg/cpanel/support.rb +29 -0
  30. data/lib/lumberg/cpanel/zone_edit.rb +134 -0
  31. data/lib/lumberg/format_whm.rb +24 -1
  32. data/lib/lumberg/version.rb +1 -1
  33. data/lib/lumberg/whm.rb +2 -1
  34. data/lib/lumberg/whm/account.rb +4 -4
  35. data/lib/lumberg/whm/cert.rb +69 -0
  36. data/lib/lumberg/whm/dns.rb +28 -4
  37. data/lib/lumberg/whm/reseller.rb +4 -4
  38. data/lib/lumberg/whm/server.rb +64 -15
  39. data/lumberg.gemspec +4 -3
  40. data/spec/config_spec.rb +2 -2
  41. data/spec/cpanel/addon_domain_spec.rb +84 -0
  42. data/spec/cpanel/backups_spec.rb +22 -0
  43. data/spec/cpanel/base_spec.rb +128 -0
  44. data/spec/cpanel/box_trapper_spec.rb +22 -0
  45. data/spec/cpanel/branding_spec.rb +46 -0
  46. data/spec/cpanel/contact_spec.rb +50 -0
  47. data/spec/cpanel/cron_spec.rb +161 -0
  48. data/spec/cpanel/dns_lookup_spec.rb +22 -0
  49. data/spec/cpanel/domain_keys_spec.rb +46 -0
  50. data/spec/cpanel/domain_lookup_spec.rb +77 -0
  51. data/spec/cpanel/email_spec.rb +615 -0
  52. data/spec/cpanel/file_manager_spec.rb +73 -0
  53. data/spec/cpanel/gpg_spec.rb +48 -0
  54. data/spec/cpanel/locale_spec.rb +23 -0
  55. data/spec/cpanel/mime_spec.rb +0 -0
  56. data/spec/cpanel/mysql_spec.rb +0 -0
  57. data/spec/cpanel/net_spec.rb +30 -0
  58. data/spec/cpanel/park_spec.rb +94 -0
  59. data/spec/cpanel/password_spec.rb +35 -0
  60. data/spec/cpanel/random_data_spec.rb +24 -0
  61. data/spec/cpanel/redirect_spec.rb +0 -0
  62. data/spec/cpanel/ssl_spec.rb +138 -0
  63. data/spec/cpanel/sub_domain_spec.rb +72 -0
  64. data/spec/cpanel/support_spec.rb +38 -0
  65. data/spec/cpanel/zone_edit_spec.rb +0 -0
  66. data/spec/sample_certs/cpanel.crt +28 -0
  67. data/spec/sample_certs/cpanel.key +28 -0
  68. data/spec/sample_certs/main.crt +27 -0
  69. data/spec/sample_certs/sample.crt +26 -0
  70. data/spec/sample_certs/sample.key +27 -0
  71. data/spec/spec_helper.rb +7 -1
  72. data/spec/support/cpanel_matchers.rb +17 -0
  73. data/spec/vcr_cassettes/cpanel/addon_domain/add.yml +77 -0
  74. data/spec/vcr_cassettes/cpanel/addon_domain/list.yml +77 -0
  75. data/spec/vcr_cassettes/cpanel/addon_domain/remove.yml +77 -0
  76. data/spec/vcr_cassettes/cpanel/backups/list.yml +40 -0
  77. data/spec/vcr_cassettes/cpanel/box_trapper/list.yml +40 -0
  78. data/spec/vcr_cassettes/cpanel/branding/list_icons.yml +40 -0
  79. data/spec/vcr_cassettes/cpanel/branding/list_image_types.yml +40 -0
  80. data/spec/vcr_cassettes/cpanel/branding/list_object_types.yml +40 -0
  81. data/spec/vcr_cassettes/cpanel/branding/list_pkgs.yml +40 -0
  82. data/spec/vcr_cassettes/cpanel/branding/list_sprites.yml +40 -0
  83. data/spec/vcr_cassettes/cpanel/contact/show.yml +40 -0
  84. data/spec/vcr_cassettes/cpanel/contact/update.yml +40 -0
  85. data/spec/vcr_cassettes/cpanel/cron/add.yml +77 -0
  86. data/spec/vcr_cassettes/cpanel/cron/edit.yml +114 -0
  87. data/spec/vcr_cassettes/cpanel/cron/email.yml +77 -0
  88. data/spec/vcr_cassettes/cpanel/cron/list.yml +77 -0
  89. data/spec/vcr_cassettes/cpanel/cron/remove.yml +151 -0
  90. data/spec/vcr_cassettes/cpanel/cron/set_email.yml +77 -0
  91. data/spec/vcr_cassettes/cpanel/dns_lookup/name_to_ip.yml +40 -0
  92. data/spec/vcr_cassettes/cpanel/domain_keys/add.yml +40 -0
  93. data/spec/vcr_cassettes/cpanel/domain_keys/available.yml +40 -0
  94. data/spec/vcr_cassettes/cpanel/domain_keys/installed.yml +40 -0
  95. data/spec/vcr_cassettes/cpanel/domain_keys/remove.yml +40 -0
  96. data/spec/vcr_cassettes/cpanel/domain_lookup/count.yml +40 -0
  97. data/spec/vcr_cassettes/cpanel/domain_lookup/docroot.yml +40 -0
  98. data/spec/vcr_cassettes/cpanel/domain_lookup/docroots.yml +40 -0
  99. data/spec/vcr_cassettes/cpanel/domain_lookup/document_root.yml +40 -0
  100. data/spec/vcr_cassettes/cpanel/domain_lookup/document_roots.yml +40 -0
  101. data/spec/vcr_cassettes/cpanel/domain_lookup/list.yml +40 -0
  102. data/spec/vcr_cassettes/cpanel/email/acceptable_encodings.yml +40 -0
  103. data/spec/vcr_cassettes/cpanel/email/accounts.yml +188 -0
  104. data/spec/vcr_cassettes/cpanel/email/add_account.yml +77 -0
  105. data/spec/vcr_cassettes/cpanel/email/add_filter.yml +77 -0
  106. data/spec/vcr_cassettes/cpanel/email/add_forwarder.yml +77 -0
  107. data/spec/vcr_cassettes/cpanel/email/add_mailing_list.yml +73 -0
  108. data/spec/vcr_cassettes/cpanel/email/add_mx.yml +40 -0
  109. data/spec/vcr_cassettes/cpanel/email/change_mx.yml +40 -0
  110. data/spec/vcr_cassettes/cpanel/email/check_local_delivery_local.yml +77 -0
  111. data/spec/vcr_cassettes/cpanel/email/check_local_delivery_remote.yml +77 -0
  112. data/spec/vcr_cassettes/cpanel/email/default_address.yml +40 -0
  113. data/spec/vcr_cassettes/cpanel/email/delete_mx.yml +40 -0
  114. data/spec/vcr_cassettes/cpanel/email/disk_usage.yml +77 -0
  115. data/spec/vcr_cassettes/cpanel/email/domains.yml +40 -0
  116. data/spec/vcr_cassettes/cpanel/email/domains_with_aliases.yml +77 -0
  117. data/spec/vcr_cassettes/cpanel/email/edit_quota.yml +112 -0
  118. data/spec/vcr_cassettes/cpanel/email/filters.yml +114 -0
  119. data/spec/vcr_cassettes/cpanel/email/forwarders.yml +77 -0
  120. data/spec/vcr_cassettes/cpanel/email/mail_dir.yml +77 -0
  121. data/spec/vcr_cassettes/cpanel/email/mail_dirs.yml +77 -0
  122. data/spec/vcr_cassettes/cpanel/email/mailing_lists.yml +73 -0
  123. data/spec/vcr_cassettes/cpanel/email/main_discard.yml +40 -0
  124. data/spec/vcr_cassettes/cpanel/email/mx.yml +40 -0
  125. data/spec/vcr_cassettes/cpanel/email/remove.yml +77 -0
  126. data/spec/vcr_cassettes/cpanel/email/set_mail_delivery_local.yml +77 -0
  127. data/spec/vcr_cassettes/cpanel/email/set_mail_delivery_remote.yml +77 -0
  128. data/spec/vcr_cassettes/cpanel/email/set_mx_type.yml +40 -0
  129. data/spec/vcr_cassettes/cpanel/file_manager/disk_usage.yml +38 -0
  130. data/spec/vcr_cassettes/cpanel/file_manager/list.yml +38 -0
  131. data/spec/vcr_cassettes/cpanel/file_manager/operate.yml +77 -0
  132. data/spec/vcr_cassettes/cpanel/file_manager/show.yml +40 -0
  133. data/spec/vcr_cassettes/cpanel/file_manager/stat.yml +38 -0
  134. data/spec/vcr_cassettes/cpanel/gpg/count.yml +40 -0
  135. data/spec/vcr_cassettes/cpanel/gpg/count_private.yml +40 -0
  136. data/spec/vcr_cassettes/cpanel/gpg/list.yml +40 -0
  137. data/spec/vcr_cassettes/cpanel/gpg/list_private.yml +40 -0
  138. data/spec/vcr_cassettes/cpanel/locale/show.yml +40 -0
  139. data/spec/vcr_cassettes/cpanel/net/query_hostname.yml +40 -0
  140. data/spec/vcr_cassettes/cpanel/net/traceroute.yml +40 -0
  141. data/spec/vcr_cassettes/cpanel/park/add.yml +77 -0
  142. data/spec/vcr_cassettes/cpanel/park/list.yml +77 -0
  143. data/spec/vcr_cassettes/cpanel/park/list_addon_domains.yml +77 -0
  144. data/spec/vcr_cassettes/cpanel/park/remove.yml +77 -0
  145. data/spec/vcr_cassettes/cpanel/password/digest_authentication.yml +77 -0
  146. data/spec/vcr_cassettes/cpanel/password/modify.yml +77 -0
  147. data/spec/vcr_cassettes/cpanel/random_data/show.yml +40 -0
  148. data/spec/vcr_cassettes/cpanel/ssl/fetchcabundle.yml +40 -0
  149. data/spec/vcr_cassettes/cpanel/ssl/gencrt.yml +40 -0
  150. data/spec/vcr_cassettes/cpanel/ssl/gencsr.yml +40 -0
  151. data/spec/vcr_cassettes/cpanel/ssl/genkey.yml +40 -0
  152. data/spec/vcr_cassettes/cpanel/ssl/installssl.yml +40 -0
  153. data/spec/vcr_cassettes/cpanel/ssl/listcrts.yml +40 -0
  154. data/spec/vcr_cassettes/cpanel/ssl/listcsrs.yml +40 -0
  155. data/spec/vcr_cassettes/cpanel/ssl/listkeys.yml +40 -0
  156. data/spec/vcr_cassettes/cpanel/ssl/listsslitems.yml +40 -0
  157. data/spec/vcr_cassettes/cpanel/ssl/showcrt.yml +38 -0
  158. data/spec/vcr_cassettes/cpanel/ssl/showcsr.yml +38 -0
  159. data/spec/vcr_cassettes/cpanel/ssl/showkey.yml +38 -0
  160. data/spec/vcr_cassettes/cpanel/ssl/uploadcrt.yml +40 -0
  161. data/spec/vcr_cassettes/cpanel/sub_domain/add.yml +77 -0
  162. data/spec/vcr_cassettes/cpanel/sub_domain/list.yml +77 -0
  163. data/spec/vcr_cassettes/cpanel/sub_domain/remove.yml +77 -0
  164. data/spec/vcr_cassettes/cpanel/support/contactable.yml +40 -0
  165. data/spec/vcr_cassettes/whm/cert/fetchsslinfo.yml +38 -0
  166. data/spec/vcr_cassettes/whm/cert/generatessl.yml +38 -0
  167. data/spec/vcr_cassettes/whm/cert/installssl.yml +38 -0
  168. data/spec/vcr_cassettes/whm/cert/listcrts.yml +38 -0
  169. data/spec/vcr_cassettes/whm/server/gettweaksetting.yml +44 -0
  170. data/spec/vcr_cassettes/whm/server/settweaksetting.yml +44 -0
  171. data/spec/vcr_cassettes/whm/server/themes.yml +38 -0
  172. data/spec/whm/cert_spec.rb +62 -0
  173. data/spec/whm/server_spec.rb +79 -3
  174. metadata +376 -34
  175. data/.rvmrc +0 -49
@@ -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
@@ -0,0 +1,48 @@
1
+ require "spec_helper"
2
+
3
+ module Lumberg
4
+ describe Cpanel::Gpg do
5
+ let(:server) { Whm::Server.new(:host => @whm_host, :hash => @whm_hash) }
6
+ let(:api_username) { "lumberg" }
7
+ let(:gpg) do
8
+ described_class.new(
9
+ :server => server,
10
+ :api_username => api_username
11
+ )
12
+ end
13
+
14
+ describe "#list" do
15
+ use_vcr_cassette "cpanel/gpg/list"
16
+
17
+ subject { gpg.list[:params][:data] }
18
+
19
+ it { should be_an(Array) }
20
+ end
21
+
22
+ describe "#count" do
23
+ use_vcr_cassette "cpanel/gpg/count"
24
+
25
+ subject { gpg.count[:params][:data][0][:count] }
26
+
27
+ it { should be_a(Integer) }
28
+ end
29
+
30
+ describe "#list_private" do
31
+ use_vcr_cassette "cpanel/gpg/list_private"
32
+
33
+ subject { gpg.list_private[:params][:data] }
34
+
35
+ it { should be_an(Array) }
36
+ end
37
+
38
+ describe "#count_private" do
39
+ use_vcr_cassette "cpanel/gpg/count_private"
40
+
41
+ subject { gpg.count_private[:params][:data][0][:count] }
42
+
43
+ it { should be_a(Integer) }
44
+ end
45
+
46
+ end
47
+ end
48
+
@@ -0,0 +1,23 @@
1
+ require "spec_helper"
2
+
3
+ module Lumberg
4
+ describe Cpanel::Locale do
5
+ let(:server) { Whm::Server.new(:host => @whm_host, :hash => @whm_hash) }
6
+ let(:api_username) { "lumberg" }
7
+ let(:locale) do
8
+ described_class.new(
9
+ :server => server,
10
+ :api_username => api_username
11
+ )
12
+ end
13
+
14
+ describe "#show" do
15
+ use_vcr_cassette "cpanel/locale/show"
16
+
17
+ subject { locale.show[:params][:data][0][:encoding] }
18
+
19
+ it { should be_a(String) }
20
+ end
21
+ end
22
+ end
23
+
File without changes
File without changes
@@ -0,0 +1,30 @@
1
+ require "spec_helper"
2
+
3
+ module Lumberg
4
+ describe Cpanel::Net do
5
+ let(:server) { Whm::Server.new(:host => @whm_host, :hash => @whm_hash) }
6
+ let(:api_username) { "lumberg" }
7
+ let(:net) do
8
+ described_class.new(
9
+ :server => server,
10
+ :api_username => api_username
11
+ )
12
+ end
13
+
14
+ describe "#traceroute" do
15
+ use_vcr_cassette "cpanel/net/traceroute"
16
+
17
+ subject { net.traceroute[:params][:data] }
18
+
19
+ it { should be_an(Array) }
20
+ end
21
+
22
+ describe "#query_hostname" do
23
+ use_vcr_cassette "cpanel/net/query_hostname"
24
+
25
+ subject { net.query_hostname({ :host => 'google.com' })[:params][:data] }
26
+
27
+ it { should be_an(Array) }
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,94 @@
1
+ require "spec_helper"
2
+
3
+ module Lumberg
4
+ describe Cpanel::Park do
5
+ before(:each) do
6
+ @login = { :host => @whm_host, :hash => @whm_hash }
7
+ @server = Whm::Server.new(@login.dup)
8
+
9
+ @api_username = "lumberg"
10
+ @park = Cpanel::Park.new(
11
+ :server => @server.dup,
12
+ :api_username => @api_username
13
+ )
14
+ end
15
+
16
+ describe "#add" do
17
+ use_vcr_cassette "cpanel/park/add"
18
+
19
+ it "creates a new parked domain" do
20
+ # Remove first
21
+ @park.remove(:domain => "test-park.com")
22
+
23
+ result = @park.add(:domain => "test-park.com")
24
+ result[:params][:data].first[:result].should == 1
25
+ end
26
+ end
27
+
28
+ describe "#remove" do
29
+ use_vcr_cassette "cpanel/park/remove"
30
+
31
+ it "removes a parked domain" do
32
+ # Add first
33
+ @park.add(:domain => "test-park.com")
34
+
35
+ result = @park.remove(:domain => "test-park.com")
36
+ result[:params][:data].first[:result].should == 1
37
+ end
38
+ end
39
+
40
+ describe "#list" do
41
+ use_vcr_cassette "cpanel/park/list"
42
+
43
+ context "parked domains exist on the account" do
44
+ let(:result) { @park.list }
45
+ subject { result[:params][:data] }
46
+
47
+ it "returns an array with info for each parked domain" do
48
+ subject.should be_an(Array)
49
+ subject.each {|info|
50
+ info.keys.should include(
51
+ :status, :reldir, :dir, :basedir, :domain
52
+ )
53
+ }
54
+ end
55
+ end
56
+
57
+ context "no parked domains exist on the account" do
58
+ before { @park.api_username = "minimal" }
59
+ after { @park.api_username = "lumberg" }
60
+
61
+ it "returns an empty array" do
62
+ @park.list[:params][:data].should be_empty
63
+ end
64
+ end
65
+ end
66
+
67
+ describe "#list_addon_domains" do
68
+ use_vcr_cassette "cpanel/park/list_addon_domains"
69
+
70
+ context "addon domains exist on the account" do
71
+ let(:result) { @park.list_addon_domains }
72
+ subject { result[:params][:data] }
73
+
74
+ it "returns an array with info for each addon domain" do
75
+ subject.should be_an(Array)
76
+ subject.each {|info|
77
+ info.keys.should include(
78
+ :status, :reldir, :dir, :basedir, :domain
79
+ )
80
+ }
81
+ end
82
+ end
83
+
84
+ context "no addon domains exist on the account" do
85
+ before { @park.api_username = "minimal" }
86
+ after { @park.api_username = "lumberg" }
87
+
88
+ it "returns an empty array" do
89
+ @park.list_addon_domains[:params][:data].should be_empty
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+
3
+ module Lumberg
4
+ describe Cpanel::Password do
5
+ let(:server) { Whm::Server.new(:host => @whm_host, :hash => @whm_hash) }
6
+ let(:api_username) { "lumberg" }
7
+ let(:password) do
8
+ described_class.new(
9
+ :server => server,
10
+ :api_username => api_username
11
+ )
12
+ end
13
+
14
+ let(:random_password) { "realtopsecretpassword" }
15
+
16
+ describe "#modify" do
17
+ use_vcr_cassette "cpanel/password/modify"
18
+
19
+ it "sets a new password for account" do
20
+ result = password.modify({ :old => '12345', :new => random_password })
21
+ result[:params][:data][0].should be_a(Hash)
22
+ end
23
+ end
24
+
25
+ describe "#digest_authentication" do
26
+ use_vcr_cassette "cpanel/password/digest_authentication"
27
+
28
+ it "enables digest authentication for account" do
29
+ result = password.digest_authentication({ :password => random_password, :enable => true })
30
+ result[:params][:data][0].should be_a(Hash)
31
+ end
32
+ end
33
+ end
34
+ end
35
+
@@ -0,0 +1,24 @@
1
+ require "spec_helper"
2
+
3
+ module Lumberg
4
+ describe Cpanel::RandomData do
5
+ let(:server) { Whm::Server.new(:host => @whm_host, :hash => @whm_hash) }
6
+ let(:api_username) { "lumberg" }
7
+ let(:random_data) do
8
+ described_class.new(
9
+ :server => server,
10
+ :api_username => api_username
11
+ )
12
+ end
13
+
14
+ describe "#show" do
15
+ use_vcr_cassette "cpanel/random_data/show"
16
+
17
+ it "gets a random string" do
18
+ result = random_data.show({ :length => 10 })[:params][:data]
19
+ result[0][:random].size.should === 10
20
+ end
21
+ end
22
+
23
+ end
24
+ end
File without changes
@@ -0,0 +1,138 @@
1
+ require "spec_helper"
2
+
3
+
4
+ module Lumberg
5
+ describe Cpanel::Ssl do
6
+ let(:domain) { "lumberg-test.com" }
7
+ let(:server) { Whm::Server.new(:host => @whm_host, :hash => @whm_hash) }
8
+ let(:api_username) { "lumberg" }
9
+
10
+ CP_CERT = File.read('./spec/sample_certs/cpanel.crt')
11
+ CP_KEY = File.read('./spec/sample_certs/cpanel.key')
12
+
13
+ let(:cert_params) {{ :user => :api_username, :city => "Chicago", :company => "Initech",
14
+ :companydivision => "TPS", :country => "US", :state => "IL",
15
+ :email => "lumberg@initech.com", :host => domain,
16
+ :pass => "Tru3St0ry", :key => CP_KEY}}
17
+
18
+ let(:ssl) do
19
+ described_class.new(
20
+ :server => server,
21
+ :api_username => api_username
22
+ )
23
+ end
24
+
25
+ describe "#installssl" do
26
+ use_vcr_cassette("cpanel/ssl/installssl")
27
+
28
+ it "installs a certificate for a cPanel account" do
29
+ ssl.installssl(:user => :api_username, :crt => CP_CERT,
30
+ :domain => domain, :key => CP_KEY)[:params][:data][0][:result].should eq(1)
31
+ end
32
+ end
33
+
34
+ describe "#listcsrs" do
35
+ use_vcr_cassette("cpanel/ssl/listcsrs")
36
+
37
+ it "prints the csrs for a cPanel account" do
38
+ ssl.listcsrs(:user => :api_username
39
+ )[:params][:data][0][:host].should == domain
40
+ end
41
+ end
42
+
43
+ describe "#showcsr" do
44
+ use_vcr_cassette("cpanel/ssl/showcsr")
45
+
46
+ it "prints the current csr for a domain" do
47
+ ssl.showcsr(:user => :api_username, :domain => domain, :textmode => 0
48
+ )[:params].to_s.should =~ /CERTIFICATE REQUEST/
49
+ end
50
+ end
51
+
52
+ describe "#showkey" do
53
+ use_vcr_cassette("cpanel/ssl/showkey")
54
+
55
+ it "prints the current key for a domain" do
56
+ ssl.showkey(:user => :api_username, :domain => domain, :textmode => 0
57
+ )[:params].to_s.should =~ /PRIVATE KEY/
58
+ end
59
+ end
60
+
61
+ describe "#showcrt" do
62
+ use_vcr_cassette("cpanel/ssl/showcrt")
63
+
64
+ it "prints the current cert for a domain" do
65
+ ssl.showcrt(:user => :api_username, :domain => domain, :textmode => 0
66
+ )[:params].to_s.should =~ /BEGIN CERTIFICATE/
67
+ end
68
+ end
69
+
70
+ describe "#listcrts" do
71
+ use_vcr_cassette("cpanel/ssl/listcrts")
72
+
73
+ it "lists the certs installed for an account " do
74
+ ssl.listcrts(:user => :api_username)[:params][:data][0][:ssltxt].to_s.should \
75
+ =~ /Certificate/
76
+ end
77
+ end
78
+
79
+ describe "#listkeys" do
80
+ use_vcr_cassette("cpanel/ssl/listkeys")
81
+
82
+ it "lists the keys installed for an account" do
83
+ ssl.listkeys(:user => :api_username)[:params][:data][0][:host].should == domain
84
+ end
85
+ end
86
+
87
+ describe "#fetchcabundle" do
88
+ use_vcr_cassette("cpanel/ssl/fetchcabundle")
89
+
90
+ it "fetches the CA bundle tied to the cert if any exist" do
91
+ ssl.listsslitems(:crt => CP_CERT)[:params][:event][:result].should eq(1)
92
+ end
93
+ end
94
+
95
+ describe "#listsslitems" do
96
+ use_vcr_cassette("cpanel/ssl/listsslitems")
97
+
98
+ it "lists keys for a domain" do
99
+ ssl.listsslitems(:domains => domain, :items => 'key')[:params][:data][0][:host].should \
100
+ == domain
101
+ end
102
+ end
103
+
104
+ describe "#gencsr" do
105
+ use_vcr_cassette("cpanel/ssl/gencsr")
106
+
107
+ it "generates a certificate signing request" do
108
+ ssl.gencsr(cert_params)[:params][:data][0][:result].should eq(1)
109
+ end
110
+ end
111
+
112
+ describe "#gencrt" do
113
+ use_vcr_cassette("cpanel/ssl/gencrt")
114
+
115
+ it "generates a certificate" do
116
+ ssl.gencrt(cert_params.merge(:key => CP_KEY))[:params][:data][0][:result].should eq(1)
117
+ end
118
+ end
119
+
120
+ describe "#genkey" do
121
+ use_vcr_cassette("cpanel/ssl/genkey")
122
+
123
+ it "generates a key" do
124
+ ssl.genkey(:user => api_username, :host => domain, :keysize => 2048
125
+ )[:params][:data][0][:result].should eq(1)
126
+ end
127
+ end
128
+
129
+ describe "#uploadcrt" do
130
+ use_vcr_cassette("cpanel/ssl/uploadcrt")
131
+
132
+ it "uploads a certificate " do
133
+ ssl.uploadcrt(:user => api_username, :crt => CP_CERT,
134
+ :host => domain)[:params][:data][0][:result].should eq(1)
135
+ end
136
+ end
137
+ end
138
+ end