lumberg 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +98 -0
- data/LICENSE +20 -0
- data/README.md +178 -0
- data/Rakefile +49 -0
- data/lib/cacert.pem +3910 -0
- data/lib/lumberg.rb +23 -0
- data/lib/lumberg/exceptions.rb +6 -0
- data/lib/lumberg/version.rb +3 -0
- data/lib/lumberg/whm.rb +70 -0
- data/lib/lumberg/whm/account.rb +329 -0
- data/lib/lumberg/whm/args.rb +113 -0
- data/lib/lumberg/whm/base.rb +28 -0
- data/lib/lumberg/whm/dns.rb +205 -0
- data/lib/lumberg/whm/reseller.rb +268 -0
- data/lib/lumberg/whm/server.rb +290 -0
- data/lib/net_http_hacked.rb +42 -0
- data/lumberg.gemspec +28 -0
- data/spec/lumberg_spec.rb +9 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/vcr_cassettes/whm/account/accountsummary.yml +43 -0
- data/spec/vcr_cassettes/whm/account/changepackage.yml +64 -0
- data/spec/vcr_cassettes/whm/account/createacct.yml +43 -0
- data/spec/vcr_cassettes/whm/account/domainuserdata.yml +43 -0
- data/spec/vcr_cassettes/whm/account/editquota.yml +85 -0
- data/spec/vcr_cassettes/whm/account/limitbw.yml +85 -0
- data/spec/vcr_cassettes/whm/account/listaccts.yml +147 -0
- data/spec/vcr_cassettes/whm/account/listsuspended.yml +43 -0
- data/spec/vcr_cassettes/whm/account/modifyacct.yml +63 -0
- data/spec/vcr_cassettes/whm/account/myprivs.yml +43 -0
- data/spec/vcr_cassettes/whm/account/passwd.yml +43 -0
- data/spec/vcr_cassettes/whm/account/removeacct.yml +85 -0
- data/spec/vcr_cassettes/whm/account/restoreaccount.yml +198 -0
- data/spec/vcr_cassettes/whm/account/setsiteip.yml +190 -0
- data/spec/vcr_cassettes/whm/account/suspend.yml +64 -0
- data/spec/vcr_cassettes/whm/account/unsuspend.yml +43 -0
- data/spec/vcr_cassettes/whm/dns/adddns.yml +64 -0
- data/spec/vcr_cassettes/whm/dns/addzonerecord.yml +43 -0
- data/spec/vcr_cassettes/whm/dns/dumpzone.yml +43 -0
- data/spec/vcr_cassettes/whm/dns/editzonerecord.yml +64 -0
- data/spec/vcr_cassettes/whm/dns/getzonerecord.yml +64 -0
- data/spec/vcr_cassettes/whm/dns/killdns.yml +43 -0
- data/spec/vcr_cassettes/whm/dns/listmxs.yml +22 -0
- data/spec/vcr_cassettes/whm/dns/listzones.yml +22 -0
- data/spec/vcr_cassettes/whm/dns/lookupnsip.yml +43 -0
- data/spec/vcr_cassettes/whm/dns/removezonerecord.yml +64 -0
- data/spec/vcr_cassettes/whm/dns/resetzone.yml +43 -0
- data/spec/vcr_cassettes/whm/dns/resolvedomainname.yml +43 -0
- data/spec/vcr_cassettes/whm/dns/savemxs.yml +22 -0
- data/spec/vcr_cassettes/whm/reseller/acctcounts.yml +43 -0
- data/spec/vcr_cassettes/whm/reseller/listacls.yml +22 -0
- data/spec/vcr_cassettes/whm/reseller/listresellers.yml +22 -0
- data/spec/vcr_cassettes/whm/reseller/resellerstats.yml +43 -0
- data/spec/vcr_cassettes/whm/reseller/saveacllist.yml +85 -0
- data/spec/vcr_cassettes/whm/reseller/setacls.yml +43 -0
- data/spec/vcr_cassettes/whm/reseller/setresellerips.yml +42 -0
- data/spec/vcr_cassettes/whm/reseller/setresellerlimits.yml +43 -0
- data/spec/vcr_cassettes/whm/reseller/setresellermainip.yml +64 -0
- data/spec/vcr_cassettes/whm/reseller/setresellernameservers.yml +64 -0
- data/spec/vcr_cassettes/whm/reseller/setresellerpackagelimit.yml +64 -0
- data/spec/vcr_cassettes/whm/reseller/setupreseller.yml +43 -0
- data/spec/vcr_cassettes/whm/reseller/suspendreseller.yml +64 -0
- data/spec/vcr_cassettes/whm/reseller/terminatereseller.yml +64 -0
- data/spec/vcr_cassettes/whm/reseller/unsetupreseller.yml +43 -0
- data/spec/vcr_cassettes/whm/reseller/unsuspendreseller.yml +43 -0
- data/spec/vcr_cassettes/whm/server/applist.yml +22 -0
- data/spec/vcr_cassettes/whm/server/gethostname.yml +22 -0
- data/spec/vcr_cassettes/whm/server/getlanglist.yml +22 -0
- data/spec/vcr_cassettes/whm/server/loadavg.yml +28 -0
- data/spec/vcr_cassettes/whm/server/my_function.yml +64 -0
- data/spec/vcr_cassettes/whm/server/response_type.yml +85 -0
- data/spec/vcr_cassettes/whm/server/systemloadavg.yml +43 -0
- data/spec/vcr_cassettes/whm/server/version.yml +22 -0
- data/spec/whm/account_spec.rb +577 -0
- data/spec/whm/args_spec.rb +179 -0
- data/spec/whm/base_spec.rb +28 -0
- data/spec/whm/dns_spec.rb +352 -0
- data/spec/whm/reseller_spec.rb +359 -0
- data/spec/whm/server_spec.rb +288 -0
- data/spec/whm/whm_spec.rb +41 -0
- metadata +265 -0
@@ -0,0 +1,179 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'lumberg/whm/args'
|
3
|
+
|
4
|
+
module Lumberg
|
5
|
+
describe Whm::Args do
|
6
|
+
context "required_parms" do
|
7
|
+
it "raises an error when missing" do
|
8
|
+
options = {:arg1 => true}
|
9
|
+
args = lambda {
|
10
|
+
Whm::Args.new(options) do |c|
|
11
|
+
c.requires :arg2
|
12
|
+
end
|
13
|
+
}
|
14
|
+
expect { args.call }.to raise_error(WhmArgumentError, /Missing required parameter: arg2/)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "does not raise an error with valid params" do
|
18
|
+
options = {:arg1 => true}
|
19
|
+
args = Whm::Args.new(options) { |c|
|
20
|
+
c.requires :arg1
|
21
|
+
}
|
22
|
+
|
23
|
+
args.required_params.should have(1).value
|
24
|
+
args.required_params.should include(:arg1)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "sets optional_params" do
|
28
|
+
options = {:arg1 => true, :arg2 => 2}
|
29
|
+
args = Whm::Args.new(options) { |c|
|
30
|
+
c.requires :arg1, :arg2
|
31
|
+
}
|
32
|
+
|
33
|
+
args.optional_params.should have(2).values
|
34
|
+
args.required_params.should have(2).values
|
35
|
+
|
36
|
+
args.optional_params.should include(*args.required_params)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "does not set boolean_params" do
|
40
|
+
options = {:arg1 => true, :arg2 => 2}
|
41
|
+
args = Whm::Args.new(options) { |c|
|
42
|
+
c.requires :arg1, :arg2
|
43
|
+
}
|
44
|
+
|
45
|
+
args.boolean_params.should be_empty
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "boolean_params" do
|
50
|
+
it "raises an error when the param is not boolean" do
|
51
|
+
options = {:arg1 => 'string'}
|
52
|
+
args = lambda {
|
53
|
+
Whm::Args.new(options) do |c|
|
54
|
+
c.booleans :arg1
|
55
|
+
end
|
56
|
+
}
|
57
|
+
expect { args.call }.to raise_error(WhmArgumentError, /Boolean parameter must be.*: arg1/)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "raises an error with boolean params" do
|
61
|
+
options = {:arg1 => true}
|
62
|
+
args = Whm::Args.new(options) { |c|
|
63
|
+
c.booleans :arg1
|
64
|
+
}
|
65
|
+
|
66
|
+
args.boolean_params.should have(1).value
|
67
|
+
args.boolean_params.should include(:arg1)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "sets optional_params" do
|
71
|
+
options = {:arg1 => true, :arg2 => false}
|
72
|
+
args = Whm::Args.new(options) { |c|
|
73
|
+
c.booleans :arg1, :arg2
|
74
|
+
}
|
75
|
+
|
76
|
+
args.optional_params.should have(2).values
|
77
|
+
args.boolean_params.should have(2).values
|
78
|
+
|
79
|
+
args.optional_params.should include(:arg1, :arg2)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "sets required_params" do
|
83
|
+
options = {:arg1 => true, :arg2 => false}
|
84
|
+
args = Whm::Args.new(options) { |c|
|
85
|
+
c.booleans :arg1, :arg2
|
86
|
+
}
|
87
|
+
|
88
|
+
args.required_params.should be_empty
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "optional_params" do
|
93
|
+
it "raises an error with unknown params" do
|
94
|
+
options = {:arg1 => true}
|
95
|
+
args = lambda {
|
96
|
+
Whm::Args.new(options) do |c|
|
97
|
+
c.optionals :arg2
|
98
|
+
end
|
99
|
+
}
|
100
|
+
|
101
|
+
expect { args.call }.to raise_error(WhmArgumentError, /Not a valid parameter: arg1/)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "does not raise an error with known params" do
|
105
|
+
options = {:arg1 => true, :arg2 => 2}
|
106
|
+
args = Whm::Args.new(options) { |c|
|
107
|
+
c.optionals :arg1, :arg2
|
108
|
+
}
|
109
|
+
|
110
|
+
args.optional_params.should have(2).values
|
111
|
+
args.optional_params.should include(:arg1, :arg2)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "does not set required_params" do
|
115
|
+
options = {:arg1 => true, :arg2 => 2}
|
116
|
+
args = Whm::Args.new(options) { |c|
|
117
|
+
c.optionals :arg1, :arg2
|
118
|
+
}
|
119
|
+
|
120
|
+
args.required_params.should be_empty
|
121
|
+
end
|
122
|
+
|
123
|
+
it "does not set boolean_params" do
|
124
|
+
options = {:arg1 => true, :arg2 => 2}
|
125
|
+
args = Whm::Args.new(options) { |c|
|
126
|
+
c.optionals :arg1, :arg2
|
127
|
+
}
|
128
|
+
|
129
|
+
args.boolean_params.should be_empty
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context "one_of" do
|
134
|
+
it "allows one arg" do
|
135
|
+
options = {:arg1 => true}
|
136
|
+
args = lambda {
|
137
|
+
Whm::Args.new(options) do |c|
|
138
|
+
c.one_of :arg1
|
139
|
+
end
|
140
|
+
}
|
141
|
+
|
142
|
+
expect { args.call }.to raise_error(WhmArgumentError, /One of requires two or more items/)
|
143
|
+
end
|
144
|
+
|
145
|
+
it "allows two or more args" do
|
146
|
+
options = {:arg1 => true}
|
147
|
+
|
148
|
+
args = Whm::Args.new(options) do |c|
|
149
|
+
c.one_of :arg1, :arg2
|
150
|
+
end
|
151
|
+
|
152
|
+
args.one_of_params.should have(2).values
|
153
|
+
args.one_of_params.should include(:arg1, :arg2)
|
154
|
+
end
|
155
|
+
|
156
|
+
it "does not allow 0 params" do
|
157
|
+
options = {}
|
158
|
+
args = lambda {
|
159
|
+
Whm::Args.new(options) do |c|
|
160
|
+
c.one_of :arg1, :arg2
|
161
|
+
end
|
162
|
+
}
|
163
|
+
|
164
|
+
expect { args.call }.to raise_error(WhmArgumentError, /The parameters may include only one of 'arg1, arg2'/)
|
165
|
+
end
|
166
|
+
|
167
|
+
it "does not allow both args" do
|
168
|
+
options = {:arg1 => true, :arg2 => 2}
|
169
|
+
args = lambda {
|
170
|
+
Whm::Args.new(options) do |c|
|
171
|
+
c.one_of :arg1, :arg2
|
172
|
+
end
|
173
|
+
}
|
174
|
+
|
175
|
+
expect { args.call }.to raise_error(WhmArgumentError, /The parameters may include only one of 'arg1, arg2'/)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'lumberg/whm'
|
3
|
+
|
4
|
+
module Lumberg
|
5
|
+
describe Whm::Base do
|
6
|
+
before(:each) do
|
7
|
+
@login = { :host => @whm_host, :hash => @whm_hash }
|
8
|
+
@server = Whm::Server.new(@login.dup)
|
9
|
+
@base = Whm::Base.new(:server => @server)
|
10
|
+
end
|
11
|
+
|
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
|
+
it "allows a server instance to be passed in" do
|
18
|
+
@base.server.should be_a(Whm::Server)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "allows a server hash to be passed in" do
|
22
|
+
base = Whm::Base.new(:server => @login)
|
23
|
+
base.server.should be_a(Whm::Server)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,352 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'lumberg/whm'
|
3
|
+
|
4
|
+
module Lumberg
|
5
|
+
describe Whm::Dns do
|
6
|
+
before(:each) do
|
7
|
+
@login = { :host => @whm_host, :hash => @whm_hash }
|
8
|
+
@server = Whm::Server.new(@login.dup)
|
9
|
+
@dns = Whm::Dns.new(:server => @server.dup)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#addzone" do
|
13
|
+
it "requires a domain" do
|
14
|
+
@dns.stub(:perform_request)
|
15
|
+
requires_attr('domain') { @dns.add_zone }
|
16
|
+
end
|
17
|
+
|
18
|
+
it "requires an ip" do
|
19
|
+
requires_attr('ip') { @dns.add_zone(:domain => 'example.com') }
|
20
|
+
end
|
21
|
+
|
22
|
+
it "allows template" do
|
23
|
+
@dns.server.stub(:perform_request)
|
24
|
+
@dns.add_zone(:domain => 'example.com', :ip => '127.0.0.1', :template => 'something')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "allows trueowner" do
|
28
|
+
@dns.server.stub(:perform_request)
|
29
|
+
@dns.add_zone(:domain => 'example.com', :ip => '127.0.0.1', :trueowner => 'something')
|
30
|
+
end
|
31
|
+
|
32
|
+
use_vcr_cassette "whm/dns/adddns"
|
33
|
+
|
34
|
+
it "creates a zone" do
|
35
|
+
result = @dns.add_zone(:domain => 'example.com', :ip => '192.1.2.3')
|
36
|
+
result[:success].should be_true
|
37
|
+
result[:message].should match(/added example\.com .*user root.*/i)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "creates a zone under a user" do
|
41
|
+
result = @dns.add_zone(:domain => 'example.com', :ip => '192.1.2.3', :trueowner => 'something')
|
42
|
+
result[:success].should be_true
|
43
|
+
result[:message].should match(/added example\.com .*user something.*/i)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#addzonerecord" do
|
48
|
+
it "requires a zone" do
|
49
|
+
requires_attr('zone') { @dns.add_zone_record }
|
50
|
+
end
|
51
|
+
|
52
|
+
use_vcr_cassette "whm/dns/addzonerecord"
|
53
|
+
|
54
|
+
it "adds a zone record" do
|
55
|
+
result = @dns.add_zone_record(:zone => 'example.com',
|
56
|
+
:name => 'example.com.',
|
57
|
+
:address => '192.1.2.3',
|
58
|
+
:type => 'A')
|
59
|
+
result[:success].should be_true
|
60
|
+
result[:message].should match(/Bind reloading on .*example.com/i)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "adds a zone record reverse" do
|
64
|
+
result = @dns.add_zone_record(:zone => 'example.com',
|
65
|
+
:name => '1',
|
66
|
+
:ptdrname => 'example.com',
|
67
|
+
:type => 'PTR')
|
68
|
+
result[:success].should be_true
|
69
|
+
result[:message].should match(/Bind reloading on .*example.com/i)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "#listzones" do
|
74
|
+
use_vcr_cassette "whm/dns/listzones"
|
75
|
+
|
76
|
+
it "lists all the zones" do
|
77
|
+
result = @dns.list_zones
|
78
|
+
params = result[:params]
|
79
|
+
params.size.should == 2
|
80
|
+
params[0][:zonefile].should == "thisisathrowawayagain22.com.db"
|
81
|
+
params[0][:domain].should == "thisisathrowawayagain22.com"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "#getzonerecord" do
|
86
|
+
use_vcr_cassette "whm/dns/getzonerecord"
|
87
|
+
|
88
|
+
it "requires a domain" do
|
89
|
+
requires_attr('domain') { @dns.get_zone_record(:Line => 1) }
|
90
|
+
end
|
91
|
+
|
92
|
+
it "requires a Line" do
|
93
|
+
requires_attr('Line') { @dns.get_zone_record(:domain => "example.com") }
|
94
|
+
end
|
95
|
+
|
96
|
+
it "returns the zone" do
|
97
|
+
result = @dns.get_zone_record(:domain => "example.com", :Line => 1)
|
98
|
+
result[:success].should be_true
|
99
|
+
result[:message].should match(/Record obtained/i)
|
100
|
+
result[:params][:record][:Line].should == 1
|
101
|
+
result[:params][:record][:raw].should == "; cPanel 11.25.0-STABLE_44718"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "returns an error when the domain was not found" do
|
105
|
+
result = @dns.get_zone_record(:domain => "notexists.com", :Line => 1)
|
106
|
+
result[:success].should_not be_true
|
107
|
+
result[:message].should match(/Zone does not exist/i)
|
108
|
+
end
|
109
|
+
|
110
|
+
it "returns an error for a line with no data" do
|
111
|
+
result = @dns.get_zone_record(:domain => "example.com", :Line => 20)
|
112
|
+
result[:success].should be_false
|
113
|
+
result[:message].should match(/No record available on selected line/i)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "#dumpzone" do
|
118
|
+
use_vcr_cassette "whm/dns/dumpzone"
|
119
|
+
|
120
|
+
it "requires a domain" do
|
121
|
+
requires_attr('domain') { @dns.dump_zone }
|
122
|
+
end
|
123
|
+
|
124
|
+
it "dumps the zone" do
|
125
|
+
result = @dns.dump_zone(:domain => "example.com")
|
126
|
+
result[:success].should be_true
|
127
|
+
result[:message].should match(/Zone Serialized/i)
|
128
|
+
result[:params][:record][0][:raw].should match(/; cPanel first:11\.25\.0-STABLE_44718 latest:11\.28\.64-STABLE_51024 Cpanel::ZoneFile::VERSION:1\.3 mtime:1299509628/i)
|
129
|
+
result[:params][:record][20][:ttl].should == "14400"
|
130
|
+
end
|
131
|
+
|
132
|
+
it "returns an error when the domain is not found" do
|
133
|
+
result = @dns.dump_zone(:domain => "notexists.com")
|
134
|
+
result[:success].should be_false
|
135
|
+
result[:message].should match(/Zone does not exist/i)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "#resolvedomainname" do
|
140
|
+
use_vcr_cassette "whm/dns/resolvedomainname"
|
141
|
+
|
142
|
+
it "requires a domain" do
|
143
|
+
requires_attr('domain') { @dns.resolve_domain("api.version".to_sym => 1) }
|
144
|
+
end
|
145
|
+
|
146
|
+
it "requires the api version" do
|
147
|
+
requires_attr('api.version') { @dns.resolve_domain(:domain => "example.com") }
|
148
|
+
end
|
149
|
+
|
150
|
+
it "returns the ip address of the domain" do
|
151
|
+
result = @dns.resolve_domain(:domain => "example.com", "api.version".to_sym => 1)
|
152
|
+
result[:params][:ip].should == "192.1.2.3"
|
153
|
+
end
|
154
|
+
|
155
|
+
it "returns an error when the ip address cannot be determined" do
|
156
|
+
result = @dns.resolve_domain(:domain => "notexists.com", "api.version".to_sym => 1)
|
157
|
+
result[:params][:ip].should be_nil
|
158
|
+
result[:message].should match(/Unable to resolve domain name/i)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe "#editzonerecord" do
|
163
|
+
use_vcr_cassette "whm/dns/editzonerecord"
|
164
|
+
|
165
|
+
it "requires a domain" do
|
166
|
+
requires_attr('domain') { @dns.edit_zone_record(:Line => 1) }
|
167
|
+
end
|
168
|
+
|
169
|
+
it "requires a Line" do
|
170
|
+
requires_attr('Line') { @dns.edit_zone_record(:domain => "example.com") }
|
171
|
+
end
|
172
|
+
|
173
|
+
it "updates the zone record" do
|
174
|
+
result = @dns.edit_zone_record(:domain => "example.com", :Line => 1, :ttl => "86400")
|
175
|
+
result[:success].should be_true
|
176
|
+
result[:message].should match(/Bind reloading on .* using rndc zone.*example.com/i)
|
177
|
+
end
|
178
|
+
|
179
|
+
it "returns an error for an unknown domain or invalid Line" do
|
180
|
+
result = @dns.edit_zone_record(:domain => "notexists.com", :Line => 1, :ttl => "86400")
|
181
|
+
result[:success].should be_false
|
182
|
+
result[:message].should match(/Failed to serialize record/i)
|
183
|
+
end
|
184
|
+
|
185
|
+
it "returns an error for an invalid Line" do
|
186
|
+
result = @dns.edit_zone_record(:domain => "example.com", :Line => 200, :ttl => "86400")
|
187
|
+
result[:success].should be_false
|
188
|
+
result[:message].should match(/Failed to serialize record/i)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
describe "#killdns" do
|
193
|
+
use_vcr_cassette "whm/dns/killdns"
|
194
|
+
|
195
|
+
it "requires a domain" do
|
196
|
+
requires_attr('domain') { @dns.kill_dns }
|
197
|
+
end
|
198
|
+
|
199
|
+
it "kills the dns" do
|
200
|
+
result = @dns.kill_dns(:domain => "example.com")
|
201
|
+
result[:success].should be_true
|
202
|
+
result[:message].should match(/Zones Removed/i)
|
203
|
+
end
|
204
|
+
|
205
|
+
it "returns an error when the domain does not exist" do
|
206
|
+
result = @dns.kill_dns(:domain => "notexists.com")
|
207
|
+
result[:success].should be_false
|
208
|
+
result[:message].should match(/Unable to remove zone that does not exist/i)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
describe "#lookupnsip" do
|
213
|
+
use_vcr_cassette "whm/dns/lookupnsip"
|
214
|
+
|
215
|
+
it "requires a nameserver" do
|
216
|
+
requires_attr('nameserver') { @dns.lookup_nameserver_ip }
|
217
|
+
end
|
218
|
+
|
219
|
+
it "returns the nameserver's ip" do
|
220
|
+
result = @dns.lookup_nameserver_ip(:nameserver => "example.com")
|
221
|
+
result[:params][:ip].should == "192.1.2.3"
|
222
|
+
end
|
223
|
+
|
224
|
+
it "returns null if the ip cannot be determined" do
|
225
|
+
result = @dns.lookup_nameserver_ip(:nameserver => "notexists.com")
|
226
|
+
result[:params][:ip].should be_nil
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
describe "#removezonerecord" do
|
231
|
+
use_vcr_cassette "whm/dns/removezonerecord"
|
232
|
+
|
233
|
+
it "requires a zone" do
|
234
|
+
requires_attr('zone') { @dns.remove_zone_record(:Line => 1) }
|
235
|
+
end
|
236
|
+
|
237
|
+
it "requires a Line" do
|
238
|
+
requires_attr('Line') { @dns.remove_zone_record(:zone => "example.com") }
|
239
|
+
end
|
240
|
+
|
241
|
+
it "removes the zone record" do
|
242
|
+
result = @dns.remove_zone_record(:zone => "example.com", :Line => 1)
|
243
|
+
result[:success].should be_true
|
244
|
+
result[:message].should match(/Bind reloading on .*example.com/i)
|
245
|
+
end
|
246
|
+
|
247
|
+
it "returns an error for an unknown zone " do
|
248
|
+
result = @dns.remove_zone_record(:zone => "notexists.com", :Line => 1)
|
249
|
+
result[:success].should be_false
|
250
|
+
result[:message].should match(/Unable to find a record on specified line/i)
|
251
|
+
end
|
252
|
+
|
253
|
+
it "returns an error for an invalid line" do
|
254
|
+
result = @dns.remove_zone_record(:zone => "example.com", :Line => 200)
|
255
|
+
result[:success].should be_false
|
256
|
+
result[:message].should match(/Unable to find a record on specified line/i)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
describe "#resetzone" do
|
261
|
+
use_vcr_cassette "whm/dns/resetzone"
|
262
|
+
|
263
|
+
it "requires a domain" do
|
264
|
+
requires_attr('domain') { @dns.reset_zone(:zone => "example.com") }
|
265
|
+
end
|
266
|
+
|
267
|
+
it "requires a zone" do
|
268
|
+
requires_attr('zone') { @dns.reset_zone(:domain => "example.com") }
|
269
|
+
end
|
270
|
+
|
271
|
+
it "resets the zone" do
|
272
|
+
result = @dns.reset_zone(:domain => "example.com", :zone => "example.com")
|
273
|
+
result[:success].should be_true
|
274
|
+
result[:message].should match(/Bind reloading on .*example.com/i)
|
275
|
+
end
|
276
|
+
|
277
|
+
it "returns an error for an unknown domain" do
|
278
|
+
result = @dns.reset_zone(:domain => "notexists.com", :zone => "notexists.com")
|
279
|
+
result[:success].should be_false
|
280
|
+
result[:message].should match(/Unable to determine the IP address for notexists.com/i)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
describe "#listmxs" do
|
285
|
+
use_vcr_cassette "whm/dns/listmxs"
|
286
|
+
|
287
|
+
it "requires a domain" do
|
288
|
+
requires_attr('domain') { @dns.list_mxs("api.version".to_sym => 1) }
|
289
|
+
end
|
290
|
+
|
291
|
+
it "requires the api.version" do
|
292
|
+
requires_attr('api.version') { @dns.list_mxs(:domain => "example.com") }
|
293
|
+
end
|
294
|
+
|
295
|
+
it "returns a list of mxs" do
|
296
|
+
result = @dns.list_mxs(:domain => "example.com", "api.version".to_sym => 1)
|
297
|
+
result[:params][:record].should be_a_kind_of Array
|
298
|
+
result[:params][:record].size.should == 1
|
299
|
+
result[:params][:record].first[:exchange].should == "example.com"
|
300
|
+
result[:params][:record].first[:name].should == "example.com."
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
describe "#savemxs" do
|
305
|
+
use_vcr_cassette "whm/dns/savemxs"
|
306
|
+
|
307
|
+
it "requires the api.version" do
|
308
|
+
requires_attr('api.version') { @dns.save_mx(:domain => "example.com",
|
309
|
+
:name => "mail.example.com",
|
310
|
+
:exchange => "example.com",
|
311
|
+
:preference => 10) }
|
312
|
+
end
|
313
|
+
|
314
|
+
it "requires a domain" do
|
315
|
+
requires_attr('domain') { @dns.save_mx("api.version".to_sym => 1,
|
316
|
+
:name => "mail.example.com",
|
317
|
+
:exchange => "example.com",
|
318
|
+
:preference => 10) }
|
319
|
+
end
|
320
|
+
|
321
|
+
it "requires a name" do
|
322
|
+
requires_attr('name') { @dns.save_mx("api.version".to_sym => 1,
|
323
|
+
:domain => "example.com",
|
324
|
+
:exchange => "example.com",
|
325
|
+
:preference => 10) }
|
326
|
+
end
|
327
|
+
|
328
|
+
it "requires an exchange" do
|
329
|
+
requires_attr('exchange') { @dns.save_mx("api.version".to_sym => 1,
|
330
|
+
:domain => "example.com",
|
331
|
+
:name => "mail.example.com",
|
332
|
+
:preference => 10) }
|
333
|
+
end
|
334
|
+
|
335
|
+
it "requires a preference" do
|
336
|
+
requires_attr('preference') { @dns.save_mx("api.version".to_sym => 1,
|
337
|
+
:domain => "example.com",
|
338
|
+
:name => "mail.example.com",
|
339
|
+
:exchange => "example.com") }
|
340
|
+
end
|
341
|
+
|
342
|
+
it "saves the mx record" do
|
343
|
+
result = @dns.save_mx("api.version".to_sym => 1,
|
344
|
+
:domain => "example.com",
|
345
|
+
:name => "mail.example.com",
|
346
|
+
:exchange => "example.com",
|
347
|
+
:preference => 10)
|
348
|
+
result[:message].should match(/Bind reloading on .*example.com/i)
|
349
|
+
end
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|