lumberg 1.0.6 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
data/spec/whm/dns_spec.rb CHANGED
@@ -10,25 +10,6 @@ module Lumberg
10
10
  end
11
11
 
12
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
13
  use_vcr_cassette "whm/dns/adddns"
33
14
 
34
15
  it "creates a zone" do
@@ -45,14 +26,10 @@ module Lumberg
45
26
  end
46
27
 
47
28
  describe "#addzonerecord" do
48
- it "requires a zone" do
49
- requires_attr('zone') { @dns.add_zone_record }
50
- end
51
-
52
29
  use_vcr_cassette "whm/dns/addzonerecord"
53
30
 
54
31
  it "adds a zone record" do
55
- result = @dns.add_zone_record(:zone => 'example.com',
32
+ result = @dns.add_zone_record(:zone => 'example.com',
56
33
  :name => 'example.com.',
57
34
  :address => '192.1.2.3',
58
35
  :type => 'A')
@@ -85,14 +62,6 @@ module Lumberg
85
62
  describe "#getzonerecord" do
86
63
  use_vcr_cassette "whm/dns/getzonerecord"
87
64
 
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
65
  it "returns the zone" do
97
66
  result = @dns.get_zone_record(:domain => "example.com", :Line => 1)
98
67
  result[:success].should be_true
@@ -117,10 +86,6 @@ module Lumberg
117
86
  describe "#dumpzone" do
118
87
  use_vcr_cassette "whm/dns/dumpzone"
119
88
 
120
- it "requires a domain" do
121
- requires_attr('domain') { @dns.dump_zone }
122
- end
123
-
124
89
  it "dumps the zone" do
125
90
  result = @dns.dump_zone(:domain => "example.com")
126
91
  result[:success].should be_true
@@ -139,14 +104,6 @@ module Lumberg
139
104
  describe "#resolvedomainname" do
140
105
  use_vcr_cassette "whm/dns/resolvedomainname"
141
106
 
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
107
  it "returns the ip address of the domain" do
151
108
  result = @dns.resolve_domain(:domain => "example.com", "api.version".to_sym => 1)
152
109
  result[:params][:ip].should == "192.1.2.3"
@@ -162,14 +119,6 @@ module Lumberg
162
119
  describe "#editzonerecord" do
163
120
  use_vcr_cassette "whm/dns/editzonerecord"
164
121
 
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
122
  it "updates the zone record" do
174
123
  result = @dns.edit_zone_record(:domain => "example.com", :Line => 1, :ttl => "86400")
175
124
  result[:success].should be_true
@@ -192,10 +141,6 @@ module Lumberg
192
141
  describe "#killdns" do
193
142
  use_vcr_cassette "whm/dns/killdns"
194
143
 
195
- it "requires a domain" do
196
- requires_attr('domain') { @dns.kill_dns }
197
- end
198
-
199
144
  it "kills the dns" do
200
145
  result = @dns.kill_dns(:domain => "example.com")
201
146
  result[:success].should be_true
@@ -212,10 +157,6 @@ module Lumberg
212
157
  describe "#lookupnsip" do
213
158
  use_vcr_cassette "whm/dns/lookupnsip"
214
159
 
215
- it "requires a nameserver" do
216
- requires_attr('nameserver') { @dns.lookup_nameserver_ip }
217
- end
218
-
219
160
  it "returns the nameserver's ip" do
220
161
  result = @dns.lookup_nameserver_ip(:nameserver => "example.com")
221
162
  result[:params][:ip].should == "192.1.2.3"
@@ -230,14 +171,6 @@ module Lumberg
230
171
  describe "#removezonerecord" do
231
172
  use_vcr_cassette "whm/dns/removezonerecord"
232
173
 
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
174
  it "removes the zone record" do
242
175
  result = @dns.remove_zone_record(:zone => "example.com", :Line => 1)
243
176
  result[:success].should be_true
@@ -260,14 +193,6 @@ module Lumberg
260
193
  describe "#resetzone" do
261
194
  use_vcr_cassette "whm/dns/resetzone"
262
195
 
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
196
  it "resets the zone" do
272
197
  result = @dns.reset_zone(:domain => "example.com", :zone => "example.com")
273
198
  result[:success].should be_true
@@ -284,14 +209,6 @@ module Lumberg
284
209
  describe "#listmxs" do
285
210
  use_vcr_cassette "whm/dns/listmxs"
286
211
 
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
212
  it "returns a list of mxs" do
296
213
  result = @dns.list_mxs(:domain => "example.com", "api.version".to_sym => 1)
297
214
  result[:params][:record].should be_a_kind_of Array
@@ -304,46 +221,11 @@ module Lumberg
304
221
  describe "#savemxs" do
305
222
  use_vcr_cassette "whm/dns/savemxs"
306
223
 
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
224
  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",
225
+ result = @dns.save_mx("api.version".to_sym => 1,
226
+ :domain => "example.com",
227
+ :name => "mail.example.com",
228
+ :exchange => "example.com",
347
229
  :preference => 10)
348
230
  result[:message].should match(/Bind reloading on .*example.com/i)
349
231
  end
@@ -11,10 +11,6 @@ module Lumberg
11
11
  describe "#setup_reseller" do
12
12
  use_vcr_cassette "whm/reseller/setupreseller"
13
13
 
14
- it "requires username" do
15
- requires_attr('username') { @reseller.create }
16
- end
17
-
18
14
  it "fails when the user doesn't exist" do
19
15
  result = @reseller.create(:username => 'invalid')
20
16
  result[:success].should be_false
@@ -41,15 +37,11 @@ module Lumberg
41
37
  result[:params][:resellers].should have(2).resellers
42
38
  result[:params][:resellers].should include('bob', 'ted')
43
39
  end
44
- end
40
+ end
45
41
 
46
42
  describe "#setresellerips" do
47
43
  use_vcr_cassette "whm/reseller/setresellerips"
48
44
 
49
- it "requires a username" do
50
- requires_attr('username') { @reseller.add_ips }
51
- end
52
-
53
45
  it "adds the ip address to the reseller account" do
54
46
  result = @reseller.add_ips(:username => 'bob', :ips =>'192.1.2.3')
55
47
  result[:message].should match(/Successfully configured IP addresses delegation to reseller/i)
@@ -64,12 +56,8 @@ module Lumberg
64
56
  describe "#setresellerlimits" do
65
57
  use_vcr_cassette "whm/reseller/setresellerlimits"
66
58
 
67
- it "requires a username" do
68
- requires_attr('username') { @reseller.set_limits }
69
- end
70
-
71
59
  it "sets the limits" do
72
- result = @reseller.set_limits(:username => 'bob', :diskspace_limit => 1024, :enable_overselling => true,
60
+ result = @reseller.set_limits(:username => 'bob', :diskspace_limit => 1024, :enable_overselling => true,
73
61
  :enable_overselling_diskspace => true)
74
62
  result[:success].should be_true
75
63
  result[:message].should match(/Successfully set reseller account .*limits/i)
@@ -79,10 +67,6 @@ module Lumberg
79
67
  describe "#terminate" do
80
68
  use_vcr_cassette "whm/reseller/terminatereseller"
81
69
 
82
- it "requires a reseller" do
83
- requires_attr('reseller') { @reseller.terminate }
84
- end
85
-
86
70
  it "terminates the reseller" do
87
71
  result = @reseller.terminate(:reseller => 'terminat')
88
72
  result[:success].should be_true
@@ -108,14 +92,6 @@ module Lumberg
108
92
  describe "#setresellermainip" do
109
93
  use_vcr_cassette "whm/reseller/setresellermainip"
110
94
 
111
- it "requires a username" do
112
- requires_attr('username') { @reseller.set_main_ip(:ip => '192.1.2.3') }
113
- end
114
-
115
- it "requires an ip" do
116
- requires_attr('ip') { @reseller.set_main_ip(:username => 'bob') }
117
- end
118
-
119
95
  it "sets the main ip" do
120
96
  result = @reseller.set_main_ip(:username => 'bob', :ip => '192.1.2.3')
121
97
  result[:success].should be_true
@@ -138,18 +114,6 @@ module Lumberg
138
114
  describe "#setresellerpackagelimit" do
139
115
  use_vcr_cassette "whm/reseller/setresellerpackagelimit"
140
116
 
141
- it "requires a username" do
142
- requires_attr('username') { @reseller.set_package_limit(:no_limit => true, :package => 'gold') }
143
- end
144
-
145
- it "requires no_limit" do
146
- requires_attr('no_limit') { @reseller.set_package_limit(:username => 'bob', :package => 'gold') }
147
- end
148
-
149
- it "requires package" do
150
- requires_attr('package') { @reseller.set_package_limit(:username => 'bob', :no_limit => true) }
151
- end
152
-
153
117
  it "sets the package limit" do
154
118
  result = @reseller.set_package_limit(:username => 'bob', :no_limit => false, :package => 'gold', :allowed => true)
155
119
  result[:success].should be_true
@@ -161,15 +125,11 @@ module Lumberg
161
125
  result[:success].should be_true
162
126
  result[:message].should match(/Successfully set reseller package limit/i)
163
127
  end
164
- end
128
+ end
165
129
 
166
130
  describe "#suspendreseller" do
167
131
  use_vcr_cassette "whm/reseller/suspendreseller"
168
132
 
169
- it "requires a username" do
170
- requires_attr('username') { @reseller.suspend }
171
- end
172
-
173
133
  it "suspends the reseller" do
174
134
  result = @reseller.suspend(:username => 'bob')
175
135
  result[:success].should be_true
@@ -192,10 +152,6 @@ module Lumberg
192
152
  describe "#unsuspendreseller" do
193
153
  use_vcr_cassette "whm/reseller/unsuspendreseller"
194
154
 
195
- it "requires a username" do
196
- requires_attr('username') { @reseller.unsuspend }
197
- end
198
-
199
155
  it "should unsuspend the user" do
200
156
  result = @reseller.unsuspend(:username => 'bob')
201
157
  result[:success].should be_true
@@ -212,18 +168,14 @@ module Lumberg
212
168
  describe "#acctcounts" do
213
169
  use_vcr_cassette "whm/reseller/acctcounts"
214
170
 
215
- it "requires a username" do
216
- requires_attr('username') { @reseller.account_counts }
217
- end
218
-
219
171
  it "returns the account counts" do
220
172
  result = @reseller.account_counts(:username => 'bob')
221
173
  result[:success].should be_true
222
174
  result[:message].should match(/Obtained reseller account counts/i)
223
- result[:params][:account].should == "bob"
175
+ result[:params][:account].should == "bob"
224
176
  result[:params][:suspended].to_i.should == 0
225
177
  result[:params][:active].to_i.should == 0
226
- result[:params][:limit].should == ""
178
+ result[:params][:limit].should == ""
227
179
  end
228
180
 
229
181
  it "returns an error when the user is invalid" do
@@ -236,22 +188,18 @@ module Lumberg
236
188
  describe "#setresellernameservers" do
237
189
  use_vcr_cassette "whm/reseller/setresellernameservers"
238
190
 
239
- it "requires a username" do
240
- requires_attr('username') { @reseller.set_nameservers }
241
- end
242
-
243
191
  it "sets the default nameservers" do
244
192
  result = @reseller.set_nameservers(:username => 'bob')
245
193
  result[:success].should be_true
246
194
  result[:message].should match(/Set resellers nameservers/i)
247
195
  end
248
-
196
+
249
197
  it "sets the specified nameservers" do
250
198
  result = @reseller.set_nameservers(:username => 'bob', :nameservers => 'ns1.example.com')
251
199
  result[:success].should be_true
252
200
  result[:message].should match(/Set resellers nameservers/i)
253
201
  end
254
-
202
+
255
203
  it "returns an error for an invalid username" do
256
204
  result = @reseller.account_counts(:username => 'notexists')
257
205
  result[:success].should be_false
@@ -262,16 +210,12 @@ module Lumberg
262
210
  describe "#resellerstats" do
263
211
  use_vcr_cassette "whm/reseller/resellerstats"
264
212
 
265
- it "requires a reseller" do
266
- requires_attr('reseller') { @reseller.stats }
267
- end
268
-
269
213
  it "returns the stats of the reseller" do
270
214
  result = @reseller.stats(:reseller => 'bob')
271
215
  result[:success].should be_true
272
216
  result[:message].should match(/Fetched Reseller Data OK/i)
273
217
  result[:params][:diskquota].to_i.should == 0
274
- result[:params][:diskoverselling].to_i.should == 1
218
+ result[:params][:diskoverselling].to_i.should == 1
275
219
  result[:params][:bandwidthlimit].to_i.should == 0
276
220
  end
277
221
 
@@ -297,10 +241,6 @@ module Lumberg
297
241
  describe "#saveacllist" do
298
242
  use_vcr_cassette "whm/reseller/saveacllist"
299
243
 
300
- it "requires an acllist name" do
301
- requires_attr('acllist') { @reseller.save_acl_list }
302
- end
303
-
304
244
  it "creates a new reseller ACL list" do
305
245
  result = @reseller.save_acl_list(:acllist => 'testacllist')
306
246
  result[:success].should be_true
@@ -308,9 +248,9 @@ module Lumberg
308
248
  end
309
249
 
310
250
  it "creates a new reseller ACL list with optional settings" do
311
- result = @reseller.save_acl_list(:acllist => 'testacllist',
251
+ result = @reseller.save_acl_list(:acllist => 'testacllist',
312
252
  "acl-ssl".to_sym => true,
313
- "acl-add-pkg".to_sym => true,
253
+ "acl-add-pkg".to_sym => true,
314
254
  "acl-stats".to_sym => true)
315
255
  result[:success].should be_true
316
256
  result[:message].should match(/ACL List testacllist saved/i)
@@ -320,16 +260,12 @@ module Lumberg
320
260
  describe "#setacls" do
321
261
  use_vcr_cassette "whm/reseller/setacls"
322
262
 
323
- it "requires a reseller" do
324
- requires_attr('reseller') { @reseller.set_acls }
325
- end
326
-
327
263
  it "sets the ACL for the reseller" do
328
264
  result = @reseller.set_acls(:reseller => 'bob', :acllist => 'testacllist')
329
265
  result[:success].should be_true
330
266
  result[:message].should match(/Reseller Acls Saved/i)
331
267
  end
332
-
268
+
333
269
  it "returns an error for an invalid reseller" do
334
270
  result = @reseller.set_acls(:reseller => 'notexists')
335
271
  result[:success].should be_false
@@ -340,10 +276,6 @@ module Lumberg
340
276
  describe "#unsetupreseller" do
341
277
  use_vcr_cassette "whm/reseller/unsetupreseller"
342
278
 
343
- it "requires a username" do
344
- requires_attr('username') { @reseller.unsetup }
345
- end
346
-
347
279
  it "removes the reseller status from the user" do
348
280
  result = @reseller.unsetup(:username => 'bob')
349
281
  result[:success].should be_true
@@ -188,37 +188,28 @@ module Lumberg
188
188
  @whm.account.should be_an(Whm::Account)
189
189
  end
190
190
 
191
- it "returns the same thing twice" do
192
- @whm.account.should be_a(Whm::Account)
193
- @whm.account.should respond_to(:list)
194
-
195
- @whm.account.should be_a(Whm::Account)
196
- @whm.account.should respond_to(:list)
191
+ it "sets the server" do
192
+ @whm.account.server.should == @whm
197
193
  end
198
-
199
194
  end
200
195
 
201
196
  describe "#dns" do
202
197
  it "has an dns accessor" do
203
198
  @whm.dns.should be_an(Whm::Dns)
204
199
  end
200
+
201
+ it "sets the server" do
202
+ @whm.dns.server.should == @whm
203
+ end
205
204
  end
206
205
 
207
206
  describe "#reseller" do
208
207
  it "has an reseller accessor" do
209
208
  @whm.reseller.should be_an(Whm::Reseller)
210
209
  end
211
- end
212
210
 
213
- describe "#method_missing" do
214
- it "caches @vars" do
215
- Whm.should_receive(:const_get).once.and_return(Whm::Account)
216
- @whm.account
217
- @whm.account
218
- end
219
-
220
- it "raises to super" do
221
- expect { @whm.asdf }.to raise_error(NoMethodError)
211
+ it "sets the server" do
212
+ @whm.reseller.server.should == @whm
222
213
  end
223
214
  end
224
215
 
@@ -236,14 +227,6 @@ module Lumberg
236
227
  describe "#add_ip" do
237
228
  use_vcr_cassette "whm/server/addip"
238
229
 
239
- it "requires an ip address" do
240
- requires_attr('ip') { @whm.add_ip(:netmask => '255.255.255.250') }
241
- end
242
-
243
- it "requires a netmask" do
244
- requires_attr('netmask') { @whm.add_ip(:ip => '123.123.123.123') }
245
- end
246
-
247
230
  it "adds the ip address" do
248
231
  result = @whm.add_ip(:ip => '208.77.188.166', :netmask => '255.255.255.0')
249
232
  result[:success].should be_true
@@ -253,10 +236,6 @@ module Lumberg
253
236
  describe "#delete_ip" do
254
237
  use_vcr_cassette "whm/server/delip"
255
238
 
256
- it "requires an ip address" do
257
- requires_attr('ip') { @whm.delete_ip }
258
- end
259
-
260
239
  it "deletes the ip address" do
261
240
  result = @whm.delete_ip(:ip => '208.77.188.166')
262
241
  result[:success].should be_true
@@ -266,10 +245,6 @@ module Lumberg
266
245
  describe "#set_hostname" do
267
246
  use_vcr_cassette "whm/server/sethostname"
268
247
 
269
- it "requires a hostname" do
270
- requires_attr('hostname') { @whm.set_hostname }
271
- end
272
-
273
248
  it "changes the server's hostname" do
274
249
  result = @whm.set_hostname(:hostname => "myhost.com")
275
250
  result[:success].should be_true
@@ -279,10 +254,6 @@ module Lumberg
279
254
  describe "#set_resolvers" do
280
255
  use_vcr_cassette "whm/server/setresolvers"
281
256
 
282
- it "requires a nameserver1" do
283
- requires_attr('nameserver1') { @whm.set_resolvers }
284
- end
285
-
286
257
  it "configures the nameservers" do
287
258
  result = @whm.set_resolvers(:nameserver1 => "123.123.123.123", :nameserver2 => "123.123.123.124")
288
259
  result[:success].should be_true