lumberg 1.0.6 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/lumberg.rb +0 -1
- data/lib/lumberg/version.rb +1 -1
- data/lib/lumberg/whm/account.rb +24 -101
- data/lib/lumberg/whm/base.rb +3 -7
- data/lib/lumberg/whm/dns.rb +21 -73
- data/lib/lumberg/whm/reseller.rb +20 -113
- data/lib/lumberg/whm/server.rb +12 -63
- data/spec/whm/account_spec.rb +40 -198
- data/spec/whm/base_spec.rb +0 -4
- data/spec/whm/dns_spec.rb +5 -123
- data/spec/whm/reseller_spec.rb +11 -79
- data/spec/whm/server_spec.rb +8 -37
- metadata +4 -82
- data/lib/lumberg/whm/args.rb +0 -113
- data/spec/whm/args_spec.rb +0 -179
data/lib/lumberg/whm/reseller.rb
CHANGED
@@ -5,13 +5,9 @@ module Lumberg
|
|
5
5
|
#
|
6
6
|
# *Note:* The user must already exist to be made a reseller. This function will not create an account. If the account does not yet exist, you can use the createacct function to set it up before conferring reseller privileges.
|
7
7
|
#
|
8
|
-
# ==== Required
|
8
|
+
# ==== Required
|
9
9
|
# * <tt>:username</tt> - PENDING
|
10
10
|
def create(options = {})
|
11
|
-
Args.new(options) do |c|
|
12
|
-
c.requires :username
|
13
|
-
c.booleans :makeowner
|
14
|
-
end
|
15
11
|
options[:user] = options.delete(:username)
|
16
12
|
server.perform_request('setupreseller', options)
|
17
13
|
end
|
@@ -27,54 +23,35 @@ module Lumberg
|
|
27
23
|
|
28
24
|
# Adds IP addresses to a reseller account
|
29
25
|
#
|
30
|
-
# ==== Required
|
26
|
+
# ==== Required
|
31
27
|
# * <tt>:username</tt> - PENDING
|
32
28
|
#
|
33
|
-
# ==== Optional
|
29
|
+
# ==== Optional
|
34
30
|
# * <tt>:ips</tt> - PENDING
|
35
31
|
def add_ips(options = {})
|
36
|
-
Args.new(options) do |c|
|
37
|
-
c.requires :username
|
38
|
-
c.optionals :ips
|
39
|
-
c.booleans :delegate
|
40
|
-
end
|
41
|
-
|
42
32
|
options[:user] = options.delete(:username)
|
43
33
|
server.perform_request('setresellerips', options)
|
44
34
|
end
|
45
35
|
|
46
36
|
# Specifies the amount of bandwidth and disk space a reseller is able to use
|
47
37
|
#
|
48
|
-
# ==== Required
|
38
|
+
# ==== Required
|
49
39
|
# * <tt>:username</tt> - PENDING
|
50
40
|
#
|
51
|
-
# ==== Optional
|
41
|
+
# ==== Optional
|
52
42
|
# * <tt>:account_limit</tt> - PENDING
|
53
43
|
# * <tt>:bandwidth_limit</tt> - PENDING
|
54
44
|
# * <tt>:diskspace_limit</tt> - PENDING
|
55
45
|
def set_limits(options = {})
|
56
|
-
Args.new(options) do |c|
|
57
|
-
c.requires :username
|
58
|
-
c.optionals :account_limit, :bandwidth_limit, :diskspace_limit
|
59
|
-
c.booleans :enable_account_limit, :enable_resource_limits, :enable_overselling,
|
60
|
-
:enable_overselling_bandwidth, :enable_overselling_diskspace, :enable_package_limits,
|
61
|
-
:enable_package_limit_numbers
|
62
|
-
end
|
63
|
-
|
64
46
|
options[:user] = options.delete(:username)
|
65
47
|
server.perform_request('setresellerlimits', options)
|
66
48
|
end
|
67
49
|
|
68
50
|
# Terminates a reseller's main account, as well as all accounts owned by the reseller
|
69
51
|
#
|
70
|
-
# ==== Required
|
52
|
+
# ==== Required
|
71
53
|
# * <tt>:reseller</tt> - PENDING
|
72
54
|
def terminate(options = {})
|
73
|
-
Args.new(options) do |c|
|
74
|
-
c.requires :reseller
|
75
|
-
c.booleans :terminatereseller
|
76
|
-
end
|
77
|
-
|
78
55
|
# WTF, seriously?
|
79
56
|
wtf = "I understand this will irrevocably remove all the "
|
80
57
|
wtf << "accounts owned by the reseller #{options[:reseller]}"
|
@@ -85,111 +62,79 @@ module Lumberg
|
|
85
62
|
|
86
63
|
# Assigns a main, shared IP address to a reseller
|
87
64
|
#
|
88
|
-
# ==== Required
|
65
|
+
# ==== Required
|
89
66
|
# * <tt>:username</tt> - PENDING
|
90
67
|
# * <tt>:ip</tt> - PENDING
|
91
68
|
def set_main_ip(options = {})
|
92
|
-
Args.new(options) do |c|
|
93
|
-
c.requires :username, :ip
|
94
|
-
end
|
95
|
-
|
96
69
|
options[:user] = options.delete(:username)
|
97
70
|
server.perform_request('setresellermainip', options)
|
98
71
|
end
|
99
72
|
|
100
73
|
# Sets which packages resellers are able to use. It also allows you to define the number of times a package can be used by a reseller
|
101
74
|
#
|
102
|
-
# ==== Required
|
75
|
+
# ==== Required
|
103
76
|
# * <tt>:username</tt> - PENDING
|
104
77
|
# * <tt>:no_limit</tt> - PENDING
|
105
78
|
# * <tt>:package</tt> - PENDING
|
106
79
|
#
|
107
|
-
# ==== Optional
|
80
|
+
# ==== Optional
|
108
81
|
# * <tt>:allowed</tt> - PENDING
|
109
82
|
# * <tt>:number</tt> - PENDING
|
110
83
|
def set_package_limit(options = {})
|
111
|
-
Args.new(options) do |c|
|
112
|
-
c.requires :username, :no_limit, :package
|
113
|
-
c.booleans :no_limit, :allowed
|
114
|
-
c.optionals :allowed, :number
|
115
|
-
end
|
116
|
-
|
117
84
|
options[:user] = options.delete(:username)
|
118
85
|
server.perform_request('setresellerpackagelimit', options)
|
119
86
|
end
|
120
87
|
|
121
88
|
# Suspends a reseller's account. The suspension will prevent the reseller from accessing his or her account
|
122
89
|
#
|
123
|
-
# ==== Required
|
90
|
+
# ==== Required
|
124
91
|
# * <tt>:username</tt> - PENDING
|
125
92
|
#
|
126
|
-
# ==== Optional
|
93
|
+
# ==== Optional
|
127
94
|
# * <tt>:reason</tt> - PENDING
|
128
95
|
def suspend(options = {})
|
129
|
-
Args.new(options) do |c|
|
130
|
-
c.requires :username
|
131
|
-
c.optionals :reason
|
132
|
-
end
|
133
|
-
|
134
96
|
options[:user] = options.delete(:username)
|
135
97
|
server.perform_request('suspendreseller', options)
|
136
98
|
end
|
137
99
|
|
138
100
|
# Unsuspends a reseller's account
|
139
101
|
#
|
140
|
-
# ==== Required
|
102
|
+
# ==== Required
|
141
103
|
# * <tt>:username</tt> - PENDING
|
142
104
|
def unsuspend(options = {})
|
143
|
-
Args.new(options) do |c|
|
144
|
-
c.requires :username
|
145
|
-
end
|
146
|
-
|
147
105
|
options[:user] = options.delete(:username)
|
148
106
|
server.perform_request('unsuspendreseller', options)
|
149
107
|
end
|
150
108
|
|
151
109
|
# Lists the total number of accounts owned by a reseller, as well as how many suspended accounts the reseller owns, and what the reseller's account creation limit is, if any.
|
152
110
|
# If no reseller is specified, counts will be provided for the reseller who is currently logged in.
|
153
|
-
#
|
111
|
+
#
|
154
112
|
# *Note:* Counts for other users will only be provided if the user issuing the function call has root-level permissions or owns the provided account.
|
155
113
|
#
|
156
|
-
# ==== Required
|
114
|
+
# ==== Required
|
157
115
|
# * <tt>:username</tt> - PENDING
|
158
116
|
def account_counts(options = {})
|
159
|
-
Args.new(options) do |c|
|
160
|
-
c.requires :username
|
161
|
-
end
|
162
|
-
|
163
117
|
options[:user] = options.delete(:username)
|
164
118
|
server.perform_request('acctcounts', options.merge(:key => 'reseller'))
|
165
119
|
end
|
166
120
|
|
167
121
|
# Defines a reseller's nameservers. Additionally, you may use it to reset a reseller's nameservers to the default settings
|
168
122
|
#
|
169
|
-
# ==== Required
|
123
|
+
# ==== Required
|
170
124
|
# * <tt>:username</tt> - PENDING
|
171
125
|
#
|
172
|
-
# ==== Optional
|
126
|
+
# ==== Optional
|
173
127
|
# * <tt>:nameservers</tt> - PENDING
|
174
128
|
def set_nameservers(options = {})
|
175
|
-
Args.new(options) do |c|
|
176
|
-
c.requires :username
|
177
|
-
c.optionals :nameservers
|
178
|
-
end
|
179
|
-
|
180
129
|
options[:user] = options.delete(:username)
|
181
130
|
server.perform_request('setresellernameservers', options)
|
182
131
|
end
|
183
132
|
|
184
133
|
# Shows account statistics for a specific reseller's accounts
|
185
134
|
#
|
186
|
-
# ==== Required
|
135
|
+
# ==== Required
|
187
136
|
# * <tt>:reseller</tt> - PENDING
|
188
137
|
def stats(options = {})
|
189
|
-
Args.new(options) do |c|
|
190
|
-
c.requires :reseller
|
191
|
-
end
|
192
|
-
|
193
138
|
server.perform_request('resellerstats', options)
|
194
139
|
end
|
195
140
|
|
@@ -200,55 +145,21 @@ module Lumberg
|
|
200
145
|
|
201
146
|
# Creates a new reseller ACL list
|
202
147
|
#
|
203
|
-
# ==== Required
|
148
|
+
# ==== Required
|
204
149
|
# * <tt>:acllist</tt> - PENDING
|
205
150
|
def save_acl_list(options = {})
|
206
|
-
optional_args = [
|
207
|
-
"acl-add-pkg", "acl-add-pkg-ip", "acl-add-pkg-shell", "acl-all", "acl-allow-addoncreate",
|
208
|
-
"acl-allow-parkedcreate", "acl-allow-unlimited-disk-pkgs", "acl-allow-unlimited-pkgs",
|
209
|
-
"acl-clustering", "acl-create-acct", "acl-create-dns", "acl-demo-setup", "acl-disallow-shell",
|
210
|
-
"acl-edit-account", "acl-edit-dns", "acl-edit-mx", "acl-edit-pkg", "acl-frontpage",
|
211
|
-
"acl-kill-acct", "acl-kill-dns", "acl-limit-bandwidth", "acl-list-accts", "acl-mailcheck",
|
212
|
-
"acl-mod-subdomains", "acl-news", "acl-onlyselfandglobalpkgs", "acl-park-dns", "acl-passwd",
|
213
|
-
"acl-quota", "acl-rearrange-accts", "acl-res-cart", "acl-status", "acl-resftp", "acl-restart",
|
214
|
-
"acl-show-bandwidth", "acl-ssl", "acl-ssl-gencrt", "acl-stats", "acl-suspend-acct", "acl-upgrade-account"
|
215
|
-
].collect { |option| option.to_sym }
|
216
|
-
|
217
|
-
Args.new(options) do |c|
|
218
|
-
c.requires :acllist
|
219
|
-
c.booleans *optional_args
|
220
|
-
c.optionals *optional_args
|
221
|
-
end
|
222
|
-
|
223
151
|
server.perform_request('saveacllist', options.merge(:key => 'results'))
|
224
152
|
end
|
225
153
|
|
226
154
|
# Sets the ACL for a reseller, or modifies specific ACL items for a reseller
|
227
155
|
#
|
228
|
-
# ==== Required
|
156
|
+
# ==== Required
|
229
157
|
# * <tt>:reseller</tt> - PENDING
|
230
158
|
#
|
231
|
-
# ==== Optional
|
159
|
+
# ==== Optional
|
232
160
|
# * <tt>:acllist</tt> - PENDING
|
233
161
|
# * <tt>:*optional_args</tt> - PENDING
|
234
162
|
def set_acls(options = {})
|
235
|
-
optional_args = [
|
236
|
-
"acl-add-pkg", "acl-add-pkg-ip", "acl-add-pkg-shell", "acl-all", "acl-allow-addoncreate",
|
237
|
-
"acl-allow-parkedcreate", "acl-allow-unlimited-disk-pkgs", "acl-allow-unlimited-pkgs",
|
238
|
-
"acl-clustering", "acl-create-acct", "acl-create-dns", "acl-demo-setup", "acl-disallow-shell",
|
239
|
-
"acl-edit-account", "acl-edit-dns", "acl-edit-mx", "acl-edit-pkg", "acl-frontpage",
|
240
|
-
"acl-kill-acct", "acl-kill-dns", "acl-limit-bandwidth", "acl-list-accts", "acl-mailcheck",
|
241
|
-
"acl-mod-subdomains", "acl-news", "acl-onlyselfandglobalpkgs", "acl-park-dns", "acl-passwd",
|
242
|
-
"acl-quota", "acl-rearrange-accts", "acl-res-cart", "acl-status", "acl-resftp", "acl-restart",
|
243
|
-
"acl-show-bandwidth", "acl-ssl", "acl-ssl-gencrt", "acl-stats", "acl-suspend-acct", "acl-upgrade-account"
|
244
|
-
].collect { |option| option.to_sym }
|
245
|
-
|
246
|
-
Args.new(options) do |c|
|
247
|
-
c.requires :reseller
|
248
|
-
c.booleans *optional_args
|
249
|
-
c.optionals :acllist, *optional_args
|
250
|
-
end
|
251
|
-
|
252
163
|
server.perform_request('setacls', options)
|
253
164
|
end
|
254
165
|
|
@@ -256,10 +167,6 @@ module Lumberg
|
|
256
167
|
#
|
257
168
|
# *Note:* This function will not delete the account; it will only remove its reseller status
|
258
169
|
def unsetup(options = {})
|
259
|
-
Args.new(options) do |c|
|
260
|
-
c.requires :username
|
261
|
-
end
|
262
|
-
|
263
170
|
options[:user] = options.delete(:username)
|
264
171
|
server.perform_request('unsetupreseller', options)
|
265
172
|
end
|
data/lib/lumberg/whm/server.rb
CHANGED
@@ -49,11 +49,6 @@ module Lumberg
|
|
49
49
|
# * <tt>:ssl</tt> - PENDING
|
50
50
|
# * <tt>:basic_auth</tt>
|
51
51
|
def initialize(options)
|
52
|
-
Args.new(options) do |c|
|
53
|
-
c.requires :host, :hash
|
54
|
-
c.optionals :user, :ssl, :basic_auth
|
55
|
-
end
|
56
|
-
|
57
52
|
@ssl_verify ||= false
|
58
53
|
@ssl = options.delete(:ssl)
|
59
54
|
@host = options.delete(:host)
|
@@ -90,10 +85,6 @@ module Lumberg
|
|
90
85
|
end
|
91
86
|
|
92
87
|
def system_load_average(options = {})
|
93
|
-
Args.new(options) do |c|
|
94
|
-
c.requires "api.version".to_sym
|
95
|
-
end
|
96
|
-
|
97
88
|
perform_request('systemloadavg', options.merge(:key => 'data'))
|
98
89
|
end
|
99
90
|
|
@@ -106,63 +97,30 @@ module Lumberg
|
|
106
97
|
end
|
107
98
|
|
108
99
|
def add_ip(options = {})
|
109
|
-
Args.new(options) do |c|
|
110
|
-
c.requires :ip, :netmask
|
111
|
-
end
|
112
|
-
|
113
100
|
perform_request('addip', options.merge(:key => 'addip'))
|
114
101
|
end
|
115
102
|
|
116
103
|
def delete_ip(options = {})
|
117
|
-
Args.new(options) do |c|
|
118
|
-
c.requires :ip
|
119
|
-
c.optionals :ethernetdev
|
120
|
-
c.booleans :skipifshutdown
|
121
|
-
end
|
122
|
-
|
123
104
|
perform_request('delip', options.merge(:key => 'delip'))
|
124
105
|
end
|
125
106
|
|
126
107
|
def set_hostname(options = {})
|
127
|
-
Args.new(options) do |c|
|
128
|
-
c.requires :hostname
|
129
|
-
end
|
130
|
-
|
131
108
|
perform_request('sethostname', options.merge(:key => 'sethostname'))
|
132
109
|
end
|
133
110
|
|
134
111
|
def set_resolvers(options = {})
|
135
|
-
Args.new(options) do |c|
|
136
|
-
c.requires :nameserver1
|
137
|
-
c.optionals :nameserver2, :nameserver3
|
138
|
-
end
|
139
|
-
|
140
112
|
perform_request('setresolvers', options.merge(:key => 'setresolvers'))
|
141
113
|
end
|
142
114
|
|
143
115
|
def show_bandwidth(options = {})
|
144
|
-
Args.new(options) do |c|
|
145
|
-
c.optionals :month, :year, :showres, :search, :searchtype
|
146
|
-
end
|
147
|
-
|
148
116
|
perform_request('showbw', options.merge(:key => 'bandwidth'))
|
149
117
|
end
|
150
118
|
|
151
119
|
def set_nv_var(options = {})
|
152
|
-
Args.new(options) do |c|
|
153
|
-
c.requires :key
|
154
|
-
c.optionals :value
|
155
|
-
end
|
156
|
-
|
157
120
|
perform_request('nvset', options.merge(:key => 'nvset'))
|
158
121
|
end
|
159
122
|
|
160
123
|
def get_nv_var(options = {})
|
161
|
-
Args.new(options) do |c|
|
162
|
-
c.requires :key
|
163
|
-
c.optionals :value
|
164
|
-
end
|
165
|
-
|
166
124
|
perform_request('nvget', options.merge(:key => 'nvget'))
|
167
125
|
end
|
168
126
|
|
@@ -170,6 +128,18 @@ module Lumberg
|
|
170
128
|
perform_request('reboot', {:key => "reboot"})
|
171
129
|
end
|
172
130
|
|
131
|
+
def account
|
132
|
+
@account ||= Account.new(:server => self)
|
133
|
+
end
|
134
|
+
|
135
|
+
def dns
|
136
|
+
@dns ||= Dns.new(:server => self)
|
137
|
+
end
|
138
|
+
|
139
|
+
def reseller
|
140
|
+
@reseller ||= Reseller.new(:server => self)
|
141
|
+
end
|
142
|
+
|
173
143
|
private
|
174
144
|
|
175
145
|
def do_request(uri, function, params)
|
@@ -228,27 +198,6 @@ module Lumberg
|
|
228
198
|
raise Lumberg::WhmArgumentError.new("Missing WHM hash") unless hash.is_a?(String)
|
229
199
|
hash.gsub(/\n|\s/, '')
|
230
200
|
end
|
231
|
-
|
232
|
-
# Creates WHM::Whatever.new(:server => @server)
|
233
|
-
# automagically
|
234
|
-
def auto_accessors
|
235
|
-
[:account, :dns, :reseller]
|
236
|
-
end
|
237
|
-
|
238
|
-
def method_missing(meth, *args, &block)
|
239
|
-
if auto_accessors.include?(meth.to_sym)
|
240
|
-
ivar = instance_variable_get("@#{meth}")
|
241
|
-
if ivar.nil?
|
242
|
-
constant = Whm.const_get(meth.to_s.capitalize)
|
243
|
-
return instance_variable_set("@#{meth}", constant.new(:server => self))
|
244
|
-
else
|
245
|
-
return ivar
|
246
|
-
end
|
247
|
-
else
|
248
|
-
super
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
201
|
end
|
253
202
|
end
|
254
203
|
end
|
data/spec/whm/account_spec.rb
CHANGED
@@ -12,29 +12,15 @@ 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
|
|
@@ -48,10 +34,6 @@ module Lumberg
|
|
48
34
|
describe "#remove" do
|
49
35
|
use_vcr_cassette "whm/account/removeacct"
|
50
36
|
|
51
|
-
it "requires a username" do
|
52
|
-
requires_attr('username') { @account.remove }
|
53
|
-
end
|
54
|
-
|
55
37
|
it "removes a user and keeps DNS by default" do
|
56
38
|
result = @account.remove(:username => 'removeme')
|
57
39
|
result[:success].should be_true
|
@@ -80,14 +62,6 @@ module Lumberg
|
|
80
62
|
describe "#change_password" do
|
81
63
|
use_vcr_cassette "whm/account/passwd"
|
82
64
|
|
83
|
-
it "requires a username" do
|
84
|
-
requires_attr('username') { @account.change_password }
|
85
|
-
end
|
86
|
-
|
87
|
-
it "requires a password" do
|
88
|
-
requires_attr('password') { @account.change_password(:username => 'changeme') }
|
89
|
-
end
|
90
|
-
|
91
65
|
it "changes the password" do
|
92
66
|
result = @account.change_password(:username => 'changeme', :password => 'superpass')
|
93
67
|
result[:success].should be_true
|
@@ -104,14 +78,6 @@ module Lumberg
|
|
104
78
|
describe "#limit bandwidth" do
|
105
79
|
use_vcr_cassette "whm/account/limitbw"
|
106
80
|
|
107
|
-
it "requires a user" do
|
108
|
-
requires_attr('username') { @account.limit_bandwidth(:bwlimit => 99999) }
|
109
|
-
end
|
110
|
-
|
111
|
-
it "requires a bandwidth" do
|
112
|
-
requires_attr('bwlimit') { @account.limit_bandwidth(:username => 'changeme') }
|
113
|
-
end
|
114
|
-
|
115
81
|
it "sets the bandwidth limit" do
|
116
82
|
result = @account.limit_bandwidth(:username => 'changeme', :bwlimit => 99999)
|
117
83
|
result[:success].should be_true
|
@@ -121,11 +87,11 @@ module Lumberg
|
|
121
87
|
end
|
122
88
|
|
123
89
|
it "isn't successful when the user doesn't exist" do
|
124
|
-
expect {
|
125
|
-
@account.limit_bandwidth(:username => 'notexists', :bwlimit => 99999)
|
90
|
+
expect {
|
91
|
+
@account.limit_bandwidth(:username => 'notexists', :bwlimit => 99999)
|
126
92
|
}.to raise_error(WhmInvalidUser, /User notexists does not exist/i)
|
127
93
|
end
|
128
|
-
end
|
94
|
+
end
|
129
95
|
|
130
96
|
describe "#list" do
|
131
97
|
use_vcr_cassette "whm/account/listaccts"
|
@@ -165,7 +131,7 @@ module Lumberg
|
|
165
131
|
result[:success].should be_true
|
166
132
|
result[:params][:acct].should have(1).account
|
167
133
|
end
|
168
|
-
end
|
134
|
+
end
|
169
135
|
|
170
136
|
describe "#modify" do
|
171
137
|
use_vcr_cassette "whm/account/modifyacct"
|
@@ -184,7 +150,7 @@ module Lumberg
|
|
184
150
|
|
185
151
|
it "returns the bandwidth limit" do
|
186
152
|
result = @account.modify(:username => 'changeme')
|
187
|
-
result[:params][:newcfg][:cpuser][:BWLIMIT].should == "unlimited"
|
153
|
+
result[:params][:newcfg][:cpuser][:BWLIMIT].should == "unlimited"
|
188
154
|
end
|
189
155
|
|
190
156
|
it "returns the primary contact email" do
|
@@ -206,7 +172,7 @@ module Lumberg
|
|
206
172
|
result = @account.modify(:username => 'changeme')
|
207
173
|
result[:params][:newcfg][:cpuser][:HASCGI].should be_true
|
208
174
|
end
|
209
|
-
end
|
175
|
+
end
|
210
176
|
|
211
177
|
describe "#editquota" do
|
212
178
|
use_vcr_cassette "whm/account/editquota"
|
@@ -232,9 +198,6 @@ module Lumberg
|
|
232
198
|
|
233
199
|
describe "#summary" do
|
234
200
|
use_vcr_cassette "whm/account/accountsummary"
|
235
|
-
it "requires a user" do
|
236
|
-
requires_attr('username') { @account.create }
|
237
|
-
end
|
238
201
|
|
239
202
|
it "returns an error for invalid users" do
|
240
203
|
result = @account.summary(:username => 'notexists')
|
@@ -247,15 +210,11 @@ module Lumberg
|
|
247
210
|
result[:success].should be_true
|
248
211
|
result[:message].should match(/ok/i)
|
249
212
|
end
|
250
|
-
end
|
213
|
+
end
|
251
214
|
|
252
215
|
describe "#suspend" do
|
253
216
|
use_vcr_cassette "whm/account/suspend"
|
254
217
|
|
255
|
-
it "requires a username" do
|
256
|
-
requires_attr('username') { @account.suspend }
|
257
|
-
end
|
258
|
-
|
259
218
|
it "returns an error for invalid users" do
|
260
219
|
result = @account.suspend(:username => 'notexists')
|
261
220
|
result[:success].should_not be_true
|
@@ -272,13 +231,10 @@ module Lumberg
|
|
272
231
|
@account.server.should_receive(:perform_request).with('suspendacct', hash_including(:user => 'suspendme', :reason => 'abusive user'))
|
273
232
|
@account.suspend(:username => 'suspendme', :reason => 'abusive user')
|
274
233
|
end
|
275
|
-
end
|
234
|
+
end
|
276
235
|
|
277
236
|
describe "#unsuspend" do
|
278
237
|
use_vcr_cassette "whm/account/unsuspend"
|
279
|
-
it "require a username" do
|
280
|
-
requires_attr('username') { @account.unsuspend }
|
281
|
-
end
|
282
238
|
|
283
239
|
it "returns an error for invalid users" do
|
284
240
|
result = @account.unsuspend(:username => 'notexists')
|
@@ -291,10 +247,11 @@ module Lumberg
|
|
291
247
|
result[:success].should be_true
|
292
248
|
result[:message].should match(/unsuspending .* account/i)
|
293
249
|
end
|
294
|
-
end
|
250
|
+
end
|
295
251
|
|
296
252
|
describe "#list_suspended" do
|
297
253
|
use_vcr_cassette 'whm/account/listsuspended'
|
254
|
+
|
298
255
|
it "returns non-empty result" do
|
299
256
|
# empty isn't a real param. VCR Hacks
|
300
257
|
result = @account.list_suspended(:empty => true)
|
@@ -308,7 +265,7 @@ module Lumberg
|
|
308
265
|
result[:success].should be_true
|
309
266
|
result[:params][:accts].should be_empty
|
310
267
|
end
|
311
|
-
end
|
268
|
+
end
|
312
269
|
|
313
270
|
describe "#change package" do
|
314
271
|
use_vcr_cassette "whm/account/changepackage"
|
@@ -319,14 +276,6 @@ module Lumberg
|
|
319
276
|
result[:message].should match(/user notexists does not exist/i)
|
320
277
|
end
|
321
278
|
|
322
|
-
it "requires a username" do
|
323
|
-
requires_attr('username') { @account.change_package(:pkg => '') }
|
324
|
-
end
|
325
|
-
|
326
|
-
it "requires a pkg" do
|
327
|
-
requires_attr('pkg') { @account.change_package(:username => 'changeme') }
|
328
|
-
end
|
329
|
-
|
330
279
|
it "fails if the package was not found" do
|
331
280
|
result = @account.change_package(:username => 'changeme', :pkg => 'fakepackage')
|
332
281
|
result[:success].should_not be_true
|
@@ -338,13 +287,10 @@ module Lumberg
|
|
338
287
|
result[:success].should be_true
|
339
288
|
result[:message].should match(/Account Upgrade\/Downgrade Complete for changeme/i)
|
340
289
|
end
|
341
|
-
end
|
290
|
+
end
|
342
291
|
|
343
292
|
describe "#privs" do
|
344
293
|
use_vcr_cassette 'whm/account/myprivs'
|
345
|
-
it "requires a user" do
|
346
|
-
requires_attr('username') { @account.privs }
|
347
|
-
end
|
348
294
|
|
349
295
|
it "has a result" do
|
350
296
|
result = @account.privs(:username => 'privs')
|
@@ -352,12 +298,12 @@ module Lumberg
|
|
352
298
|
|
353
299
|
params = result[:params]
|
354
300
|
expected = {
|
355
|
-
:kill_dns => false, :edit_dns => false, :edit_mx => false, :add_pkg => false,
|
356
|
-
:suspend_acct => false, :add_pkg_shell => false, :viewglobalpackages => false,
|
357
|
-
:resftp => false, :list_accts => false, :all => true, :passwd => false, :quota => false,
|
358
|
-
:park_dns => false, :rearrange_accts => false, :allow_addoncreate => false, :demo => false,
|
359
|
-
:news => false, :edit_account => false, :allow_unlimited_disk_pkgs => false, :allow_parkedcreate => false,
|
360
|
-
: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,
|
361
307
|
:add_pkg_ip => false, :disallow_shell => false, :res_cart => false, :ssl_buy => false, :kill_acct => false,
|
362
308
|
:allow_unlimited_bw_pkgs => false, :create_dns => false, :mailcheck => false, :clustering => false, :ssl => false,
|
363
309
|
:edit_pkg => false, :locale_edit => false, :show_bandwidth => false, :upgrade_account => false, :thirdparty => false,
|
@@ -365,7 +311,7 @@ module Lumberg
|
|
365
311
|
|
366
312
|
params.should include(expected)
|
367
313
|
end
|
368
|
-
end
|
314
|
+
end
|
369
315
|
|
370
316
|
describe "#domainuserdata" do
|
371
317
|
use_vcr_cassette "whm/account/domainuserdata"
|
@@ -376,10 +322,6 @@ module Lumberg
|
|
376
322
|
result[:message].should match(/Unable to determine account owner for domain\./i)
|
377
323
|
end
|
378
324
|
|
379
|
-
it "requires a domain" do
|
380
|
-
requires_attr('domain') { @account.domain_user_data }
|
381
|
-
end
|
382
|
-
|
383
325
|
it "returns the correct data" do
|
384
326
|
result = @account.domain_user_data(:domain => 'example.com')
|
385
327
|
result[:success].should be_true
|
@@ -397,19 +339,11 @@ module Lumberg
|
|
397
339
|
result[:params][:servername].should == "example.com"
|
398
340
|
result[:params][:user].should == "changeme"
|
399
341
|
end
|
400
|
-
end
|
342
|
+
end
|
401
343
|
|
402
344
|
describe "#setsiteip" do
|
403
345
|
use_vcr_cassette "whm/account/setsiteip"
|
404
346
|
|
405
|
-
it "requires an ip" do
|
406
|
-
requires_attr('ip') { @account.set_site_ip }
|
407
|
-
end
|
408
|
-
|
409
|
-
it "requires a username or a domain" do
|
410
|
-
expect { @account.set_site_ip(:ip => '1.1.1.1') }.to raise_error(WhmArgumentError, /may include only one of 'username, domain'/i)
|
411
|
-
end
|
412
|
-
|
413
347
|
it "accepts a username for the account to use" do
|
414
348
|
result = @account.set_site_ip(:ip => '192.1.2.3', :username => 'changeme')
|
415
349
|
result[:success].should be_true
|
@@ -425,131 +359,39 @@ module Lumberg
|
|
425
359
|
result[:success].should be_true
|
426
360
|
result[:message].should match(/OK/i)
|
427
361
|
end
|
428
|
-
end
|
362
|
+
end
|
429
363
|
|
430
364
|
describe "#restore" do
|
431
365
|
# 11.27/11.28+ only
|
432
366
|
use_vcr_cassette "whm/account/restoreaccount"
|
433
|
-
it "requires api.version" do
|
434
|
-
requires_attr('api.version') {
|
435
|
-
@account.restore_account(:username => 'changeme',
|
436
|
-
:type => 'monthly',
|
437
|
-
:all => false,
|
438
|
-
:ip => false,
|
439
|
-
:mail => false,
|
440
|
-
:mysql => false,
|
441
|
-
:subs => false)
|
442
|
-
}
|
443
|
-
end
|
444
|
-
|
445
|
-
it "requires a username" do
|
446
|
-
requires_attr('username') {
|
447
|
-
@account.restore_account("api.version".to_sym => 1,
|
448
|
-
:type => 'monthly',
|
449
|
-
:all => false,
|
450
|
-
:ip => false,
|
451
|
-
:mail => false,
|
452
|
-
:mysql => false,
|
453
|
-
:subs => false)
|
454
|
-
}
|
455
|
-
end
|
456
|
-
|
457
|
-
it "requires type" do
|
458
|
-
requires_attr('type') {
|
459
|
-
@account.restore_account("api.version".to_sym => 1,
|
460
|
-
:username => 'changeme',
|
461
|
-
:all => false,
|
462
|
-
:ip => false,
|
463
|
-
:mail => false,
|
464
|
-
:mysql => false,
|
465
|
-
:subs => false)
|
466
|
-
}
|
467
|
-
end
|
468
|
-
|
469
|
-
it "requires all" do
|
470
|
-
requires_attr('all') {
|
471
|
-
@account.restore_account("api.version".to_sym => 1,
|
472
|
-
:username => 'changeme',
|
473
|
-
:type => 'monthly',
|
474
|
-
:ip => false,
|
475
|
-
:mail => false,
|
476
|
-
:mysql => false,
|
477
|
-
:subs => false)
|
478
|
-
}
|
479
|
-
end
|
480
|
-
|
481
|
-
it "requires ip" do
|
482
|
-
requires_attr('ip') {
|
483
|
-
@account.restore_account("api.version".to_sym => 1,
|
484
|
-
:username => 'changeme',
|
485
|
-
:type => 'monthly',
|
486
|
-
:all => false,
|
487
|
-
:mail => false,
|
488
|
-
:mysql => false,
|
489
|
-
:subs => false)
|
490
|
-
}
|
491
|
-
end
|
492
|
-
|
493
|
-
it "requires mail" do
|
494
|
-
requires_attr('mail') { @account.restore_account("api.version".to_sym => 1,
|
495
|
-
:username => 'changeme',
|
496
|
-
:type => 'monthly',
|
497
|
-
:all => false,
|
498
|
-
:ip => false,
|
499
|
-
:mysql => false,
|
500
|
-
:subs => false)
|
501
|
-
}
|
502
|
-
end
|
503
|
-
|
504
|
-
it "requires mysql" do
|
505
|
-
requires_attr('mysql') { @account.restore_account("api.version".to_sym => 1,
|
506
|
-
:username => 'changeme',
|
507
|
-
:type => 'monthly',
|
508
|
-
:all => false,
|
509
|
-
:ip => false,
|
510
|
-
:mail => false,
|
511
|
-
:subs => false)
|
512
|
-
}
|
513
|
-
end
|
514
|
-
|
515
|
-
it "require subs" do
|
516
|
-
requires_attr('subs') { @account.restore_account("api.version".to_sym => 1,
|
517
|
-
:username => 'changeme',
|
518
|
-
:type => 'monthly',
|
519
|
-
:all => false,
|
520
|
-
:ip => false,
|
521
|
-
:mail => false,
|
522
|
-
:mysql => false)
|
523
|
-
}
|
524
|
-
end
|
525
367
|
|
526
368
|
it "returns an error if it can't find the backup" do
|
527
|
-
result = @account.restore_account("api.version".to_sym => 1,
|
528
|
-
:username => 'notexists',
|
529
|
-
:type => 'daily',
|
530
|
-
:all => false,
|
531
|
-
:ip => false,
|
532
|
-
:mail => false,
|
533
|
-
: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,
|
534
376
|
:subs => false)
|
535
377
|
result[:params][:result].to_i.should == 0
|
536
378
|
result[:params][:reason].should match(/Unable to find archive/i)
|
537
379
|
end
|
538
380
|
|
539
381
|
it "restores the account" do
|
540
|
-
result = @account.restore_account("api.version".to_sym => 1,
|
541
|
-
:username => 'changeme',
|
542
|
-
:type => 'daily',
|
543
|
-
:all => false,
|
544
|
-
:ip => false,
|
545
|
-
:mail => false,
|
546
|
-
: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,
|
547
389
|
:subs => false)
|
548
390
|
result[:params][:result].to_i.should == 1
|
549
391
|
result[:params][:reason].should == "OK"
|
550
392
|
result[:params][:output][:raw].should match(/Account Restore Complete/i)
|
551
393
|
end
|
552
|
-
end
|
394
|
+
end
|
553
395
|
|
554
396
|
describe "#verify_user" do
|
555
397
|
use_vcr_cassette "whm/account/accountsummary"
|
@@ -558,7 +400,7 @@ module Lumberg
|
|
558
400
|
|
559
401
|
it "does not call the block if the user doesn't exist" do
|
560
402
|
@something.should_not_receive(:gold)
|
561
|
-
expect {
|
403
|
+
expect {
|
562
404
|
@account.send(:verify_user, 'notexists') do
|
563
405
|
@something.gold
|
564
406
|
end
|