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.
- checksums.yaml +7 -0
- data/.travis.yml +1 -6
- data/README.md +130 -23
- data/lib/lumberg.rb +2 -0
- data/lib/lumberg/cpanel.rb +29 -0
- data/lib/lumberg/cpanel/addon_domain.rb +50 -0
- data/lib/lumberg/cpanel/backups.rb +16 -0
- data/lib/lumberg/cpanel/base.rb +56 -0
- data/lib/lumberg/cpanel/box_trapper.rb +18 -0
- data/lib/lumberg/cpanel/branding.rb +89 -0
- data/lib/lumberg/cpanel/contact.rb +38 -0
- data/lib/lumberg/cpanel/cron.rb +89 -0
- data/lib/lumberg/cpanel/dns_lookup.rb +23 -0
- data/lib/lumberg/cpanel/domain_keys.rb +37 -0
- data/lib/lumberg/cpanel/domain_lookup.rb +71 -0
- data/lib/lumberg/cpanel/email.rb +491 -0
- data/lib/lumberg/cpanel/file_manager.rb +146 -0
- data/lib/lumberg/cpanel/gpg.rb +36 -0
- data/lib/lumberg/cpanel/locale.rb +15 -0
- data/lib/lumberg/cpanel/mime.rb +34 -0
- data/lib/lumberg/cpanel/mysql.rb +66 -0
- data/lib/lumberg/cpanel/net.rb +28 -0
- data/lib/lumberg/cpanel/park.rb +58 -0
- data/lib/lumberg/cpanel/password.rb +52 -0
- data/lib/lumberg/cpanel/random_data.rb +25 -0
- data/lib/lumberg/cpanel/redirect.rb +44 -0
- data/lib/lumberg/cpanel/ssl.rb +198 -0
- data/lib/lumberg/cpanel/sub_domain.rb +61 -0
- data/lib/lumberg/cpanel/support.rb +29 -0
- data/lib/lumberg/cpanel/zone_edit.rb +134 -0
- data/lib/lumberg/format_whm.rb +24 -1
- data/lib/lumberg/version.rb +1 -1
- data/lib/lumberg/whm.rb +2 -1
- data/lib/lumberg/whm/account.rb +4 -4
- data/lib/lumberg/whm/cert.rb +69 -0
- data/lib/lumberg/whm/dns.rb +28 -4
- data/lib/lumberg/whm/reseller.rb +4 -4
- data/lib/lumberg/whm/server.rb +64 -15
- data/lumberg.gemspec +4 -3
- data/spec/config_spec.rb +2 -2
- data/spec/cpanel/addon_domain_spec.rb +84 -0
- data/spec/cpanel/backups_spec.rb +22 -0
- data/spec/cpanel/base_spec.rb +128 -0
- data/spec/cpanel/box_trapper_spec.rb +22 -0
- data/spec/cpanel/branding_spec.rb +46 -0
- data/spec/cpanel/contact_spec.rb +50 -0
- data/spec/cpanel/cron_spec.rb +161 -0
- data/spec/cpanel/dns_lookup_spec.rb +22 -0
- data/spec/cpanel/domain_keys_spec.rb +46 -0
- data/spec/cpanel/domain_lookup_spec.rb +77 -0
- data/spec/cpanel/email_spec.rb +615 -0
- data/spec/cpanel/file_manager_spec.rb +73 -0
- data/spec/cpanel/gpg_spec.rb +48 -0
- data/spec/cpanel/locale_spec.rb +23 -0
- data/spec/cpanel/mime_spec.rb +0 -0
- data/spec/cpanel/mysql_spec.rb +0 -0
- data/spec/cpanel/net_spec.rb +30 -0
- data/spec/cpanel/park_spec.rb +94 -0
- data/spec/cpanel/password_spec.rb +35 -0
- data/spec/cpanel/random_data_spec.rb +24 -0
- data/spec/cpanel/redirect_spec.rb +0 -0
- data/spec/cpanel/ssl_spec.rb +138 -0
- data/spec/cpanel/sub_domain_spec.rb +72 -0
- data/spec/cpanel/support_spec.rb +38 -0
- data/spec/cpanel/zone_edit_spec.rb +0 -0
- data/spec/sample_certs/cpanel.crt +28 -0
- data/spec/sample_certs/cpanel.key +28 -0
- data/spec/sample_certs/main.crt +27 -0
- data/spec/sample_certs/sample.crt +26 -0
- data/spec/sample_certs/sample.key +27 -0
- data/spec/spec_helper.rb +7 -1
- data/spec/support/cpanel_matchers.rb +17 -0
- data/spec/vcr_cassettes/cpanel/addon_domain/add.yml +77 -0
- data/spec/vcr_cassettes/cpanel/addon_domain/list.yml +77 -0
- data/spec/vcr_cassettes/cpanel/addon_domain/remove.yml +77 -0
- data/spec/vcr_cassettes/cpanel/backups/list.yml +40 -0
- data/spec/vcr_cassettes/cpanel/box_trapper/list.yml +40 -0
- data/spec/vcr_cassettes/cpanel/branding/list_icons.yml +40 -0
- data/spec/vcr_cassettes/cpanel/branding/list_image_types.yml +40 -0
- data/spec/vcr_cassettes/cpanel/branding/list_object_types.yml +40 -0
- data/spec/vcr_cassettes/cpanel/branding/list_pkgs.yml +40 -0
- data/spec/vcr_cassettes/cpanel/branding/list_sprites.yml +40 -0
- data/spec/vcr_cassettes/cpanel/contact/show.yml +40 -0
- data/spec/vcr_cassettes/cpanel/contact/update.yml +40 -0
- data/spec/vcr_cassettes/cpanel/cron/add.yml +77 -0
- data/spec/vcr_cassettes/cpanel/cron/edit.yml +114 -0
- data/spec/vcr_cassettes/cpanel/cron/email.yml +77 -0
- data/spec/vcr_cassettes/cpanel/cron/list.yml +77 -0
- data/spec/vcr_cassettes/cpanel/cron/remove.yml +151 -0
- data/spec/vcr_cassettes/cpanel/cron/set_email.yml +77 -0
- data/spec/vcr_cassettes/cpanel/dns_lookup/name_to_ip.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_keys/add.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_keys/available.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_keys/installed.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_keys/remove.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_lookup/count.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_lookup/docroot.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_lookup/docroots.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_lookup/document_root.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_lookup/document_roots.yml +40 -0
- data/spec/vcr_cassettes/cpanel/domain_lookup/list.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/acceptable_encodings.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/accounts.yml +188 -0
- data/spec/vcr_cassettes/cpanel/email/add_account.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/add_filter.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/add_forwarder.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/add_mailing_list.yml +73 -0
- data/spec/vcr_cassettes/cpanel/email/add_mx.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/change_mx.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/check_local_delivery_local.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/check_local_delivery_remote.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/default_address.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/delete_mx.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/disk_usage.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/domains.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/domains_with_aliases.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/edit_quota.yml +112 -0
- data/spec/vcr_cassettes/cpanel/email/filters.yml +114 -0
- data/spec/vcr_cassettes/cpanel/email/forwarders.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/mail_dir.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/mail_dirs.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/mailing_lists.yml +73 -0
- data/spec/vcr_cassettes/cpanel/email/main_discard.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/mx.yml +40 -0
- data/spec/vcr_cassettes/cpanel/email/remove.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/set_mail_delivery_local.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/set_mail_delivery_remote.yml +77 -0
- data/spec/vcr_cassettes/cpanel/email/set_mx_type.yml +40 -0
- data/spec/vcr_cassettes/cpanel/file_manager/disk_usage.yml +38 -0
- data/spec/vcr_cassettes/cpanel/file_manager/list.yml +38 -0
- data/spec/vcr_cassettes/cpanel/file_manager/operate.yml +77 -0
- data/spec/vcr_cassettes/cpanel/file_manager/show.yml +40 -0
- data/spec/vcr_cassettes/cpanel/file_manager/stat.yml +38 -0
- data/spec/vcr_cassettes/cpanel/gpg/count.yml +40 -0
- data/spec/vcr_cassettes/cpanel/gpg/count_private.yml +40 -0
- data/spec/vcr_cassettes/cpanel/gpg/list.yml +40 -0
- data/spec/vcr_cassettes/cpanel/gpg/list_private.yml +40 -0
- data/spec/vcr_cassettes/cpanel/locale/show.yml +40 -0
- data/spec/vcr_cassettes/cpanel/net/query_hostname.yml +40 -0
- data/spec/vcr_cassettes/cpanel/net/traceroute.yml +40 -0
- data/spec/vcr_cassettes/cpanel/park/add.yml +77 -0
- data/spec/vcr_cassettes/cpanel/park/list.yml +77 -0
- data/spec/vcr_cassettes/cpanel/park/list_addon_domains.yml +77 -0
- data/spec/vcr_cassettes/cpanel/park/remove.yml +77 -0
- data/spec/vcr_cassettes/cpanel/password/digest_authentication.yml +77 -0
- data/spec/vcr_cassettes/cpanel/password/modify.yml +77 -0
- data/spec/vcr_cassettes/cpanel/random_data/show.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/fetchcabundle.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/gencrt.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/gencsr.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/genkey.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/installssl.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/listcrts.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/listcsrs.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/listkeys.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/listsslitems.yml +40 -0
- data/spec/vcr_cassettes/cpanel/ssl/showcrt.yml +38 -0
- data/spec/vcr_cassettes/cpanel/ssl/showcsr.yml +38 -0
- data/spec/vcr_cassettes/cpanel/ssl/showkey.yml +38 -0
- data/spec/vcr_cassettes/cpanel/ssl/uploadcrt.yml +40 -0
- data/spec/vcr_cassettes/cpanel/sub_domain/add.yml +77 -0
- data/spec/vcr_cassettes/cpanel/sub_domain/list.yml +77 -0
- data/spec/vcr_cassettes/cpanel/sub_domain/remove.yml +77 -0
- data/spec/vcr_cassettes/cpanel/support/contactable.yml +40 -0
- data/spec/vcr_cassettes/whm/cert/fetchsslinfo.yml +38 -0
- data/spec/vcr_cassettes/whm/cert/generatessl.yml +38 -0
- data/spec/vcr_cassettes/whm/cert/installssl.yml +38 -0
- data/spec/vcr_cassettes/whm/cert/listcrts.yml +38 -0
- data/spec/vcr_cassettes/whm/server/gettweaksetting.yml +44 -0
- data/spec/vcr_cassettes/whm/server/settweaksetting.yml +44 -0
- data/spec/vcr_cassettes/whm/server/themes.yml +38 -0
- data/spec/whm/cert_spec.rb +62 -0
- data/spec/whm/server_spec.rb +79 -3
- metadata +376 -34
- 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
|