whm_xml 0.3.2

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.
@@ -0,0 +1,40 @@
1
+ <modifyacct>
2
+ <result>
3
+ <messages>Changing shell for user.
4
+ Shell changed.
5
+ </messages>
6
+ <newcfg>
7
+ <cpuser>
8
+ <BWLIMIT>5242880000</BWLIMIT>
9
+ <CONTACTEMAIL>owner@domain.com</CONTACTEMAIL>
10
+ <CONTACTEMAIL2></CONTACTEMAIL2>
11
+ <DEADDOMAINS>oldsub.domain.com</DEADDOMAINS>
12
+ <DEMO>0</DEMO>
13
+ <DOMAIN>domain.com</DOMAIN>
14
+ <DOMAINS>sub.domain.com</DOMAINS>
15
+ <DOMAINS>addondomain.com</DOMAINS>
16
+ <FEATURELIST>reseller_gold</FEATURELIST>
17
+ <HASCGI>0</HASCGI>
18
+ <IP>192.168.1.1</IP>
19
+ <LANG>english</LANG>
20
+ <MAXADDON>5</MAXADDON>
21
+ <MAXFTP>0</MAXFTP>
22
+ <MAXLST>1</MAXLST>
23
+ <MAXPARK>4</MAXPARK>
24
+ <MAXPOP>3</MAXPOP>
25
+ <MAXSQL>6</MAXSQL>
26
+ <MAXSUB>3</MAXSUB>
27
+ <OWNER>root</OWNER>
28
+ <PLAN>reseller_gold</PLAN>
29
+ <RS>x3</RS>
30
+ <STARTDATE>1175808157</STARTDATE>
31
+ <USER>user</USER>
32
+ </cpuser>
33
+ <domain>domain.com</domain>
34
+ <setshell>/bin/bash</setshell>
35
+ <user>user</user>
36
+ </newcfg>
37
+ <status>1</status>
38
+ <statusmsg>Account Modified</statusmsg>
39
+ </result>
40
+ </modifyacct>
@@ -0,0 +1,33 @@
1
+ <passwd>
2
+ <passwd>
3
+ <rawout>Changing password for user
4
+ Password for user has been changed
5
+ Updating ftp passwords for user
6
+ Ftp password files updated.
7
+ Ftp vhost passwords synced
8
+ Unable to find pgpass file.
9
+ </rawout>
10
+ <services>
11
+ <app>system</app>
12
+ </services>
13
+ <services>
14
+ <app>ftp</app>
15
+ </services>
16
+ <services>
17
+ <app>mail</app>
18
+ </services>
19
+ <services>
20
+ <app>mySQL</app>
21
+ </services>
22
+ <services>
23
+ <app>postgresql</app>
24
+ </services>
25
+ <services>
26
+ <app>FrontPage</app>
27
+ </services>
28
+ <status>1</status>
29
+ <statusmsg>Password changed for user user</statusmsg>
30
+ </passwd>
31
+ </passwd>
32
+
33
+ <!-- Web Host Manager (c) cPanel, Inc. 2008 http://cpanel.net/ Unauthorized copying is prohibited. -->
@@ -0,0 +1,21 @@
1
+ <removeacct>
2
+ <result>
3
+ <rawout>Running pre removal script (/scripts/prekillacct)......DoneCollecting Domain Name and IP...User: user
4
+ Domain: example.com
5
+ ...DoneKilling all processes owned by user......DoneCleaning passwd,shadow,group......DoneRemoving User from Group..........DoneRemoving Web Logs......DoneRemoving Crontab......DoneRemoving Virtual Hosts...Removed Extra Entries from httpd.conf
6
+ example.com not found in httpd.conf.
7
+ ...DoneRemoving PostgreSQL databases and users......DoneRemoving System User......DoneRemoving Group......DoneRemoving DNS Entries...example.com =&gt; deleted from r15.
8
+ ...DoneRemoving Email Setup...Removing /etc/valiases/example.com
9
+ ...DoneRemoving mailman lists......DoneRemoving MySQL databases and users......DoneRemoving remotedomains,secondarymx,localdomains entries......DoneRemoving Counter Data......DoneAdding ip back to the ip address pool...System has 0 free ips.
10
+ ...DoneRemoving user's cPanel Databases &amp; Updating......DoneReloading Services......DoneRemoving mail and service configs...
11
+ ...DoneSending Contacts......DoneUpdating internal databases...Updating ftp passwords for user
12
+ Purging ftp user user
13
+ Ftp password files updated.
14
+ Ftp vhost passwords synced
15
+ ...DoneRunning post removal scripts (/scripts/legacypostkillacct, /scripts/postkillacct)......DoneAccount Removal Complete!!!...user account removed...Done</rawout>
16
+ <status>1</status>
17
+ <statusmsg>user account removed</statusmsg>
18
+ </result>
19
+ </removeacct>
20
+
21
+ <!-- Web Host Manager (c) cPanel, Inc. 2008 http://cpanel.net/ Unauthorized copying is prohibited. -->
@@ -0,0 +1,26 @@
1
+ <suspendacct>
2
+ <result>
3
+ <status>1</status>
4
+ <statusmsg>&lt;script&gt;if (self['clear_ui_status']) { clear_ui_status(); }&lt;/script&gt;
5
+ Changing Shell to /bin/false...Changing shell for user.
6
+ Warning: &quot;/bin/false&quot; is not listed in /etc/shells
7
+ Shell changed.
8
+ Done
9
+ Locking Password...Locking password for user user.
10
+ passwd: Success
11
+ Done
12
+ Suspending mysql users
13
+ Notification =&gt; system@example.com via EMAIL [level =&gt; 3]
14
+ Using Quota v3 Support
15
+ Suspended document root /home/user/public_html
16
+ Using Quota v3 Support
17
+ Suspending FTP accounts...
18
+ Updating ftp passwords for user
19
+ Ftp password files updated.
20
+ Ftp vhost passwords synced
21
+ user's account has been suspended
22
+ </statusmsg>
23
+ </result>
24
+ </suspendacct>
25
+
26
+ <!-- Web Host Manager (c) cPanel, Inc. 2008 http://cpanel.net/ Unauthorized copying is prohibited. -->
@@ -0,0 +1,20 @@
1
+ <unsuspendacct>
2
+ <result>
3
+ <status>1</status>
4
+ <statusmsg>&lt;script&gt;if (self['clear_ui_status']) { clear_ui_status(); }&lt;/script&gt;
5
+ Changing shell for user.
6
+ Shell changed.
7
+ Unlocking password for user user.
8
+ passwd: Success.
9
+ Unsuspending FTP accounts...
10
+ Updating ftp passwords for user
11
+ Ftp password files updated.
12
+ Ftp vhost passwords synced
13
+ user's account is now active
14
+ Unsuspending mysql users
15
+ Notification =&gt; system@example.com via EMAIL [level =&gt; 3]
16
+ </statusmsg>
17
+ </result>
18
+ </unsuspendacct>
19
+
20
+ <!-- Web Host Manager (c) cPanel, Inc. 2008 http://cpanel.net/ Unauthorized copying is prohibited. -->
@@ -0,0 +1,5 @@
1
+ <version>
2
+ <version>11.24.2</version>
3
+ </version>
4
+
5
+ <!-- Web Host Manager (c) cPanel, Inc. 2008 http://cpanel.net/ Unauthorized copying is prohibited. -->
@@ -0,0 +1,83 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+ require 'lib/whm'
3
+ require 'pp'
4
+
5
+
6
+ describe "Whm Packages" do
7
+ before do
8
+ @server = Whm::Server.new(
9
+ :username => "username",
10
+ :password => "password",
11
+ :host => "dedicated.server.com"
12
+ )
13
+ end
14
+
15
+ it "should find all packages" do
16
+ data = open(File.dirname(__FILE__) + '/fixtures/listpkgs.xml').read
17
+ @server.expects(:get_xml).returns(XmlSimple.xml_in(data, { 'ForceArray' => false }))
18
+
19
+ @server.packages.length.should == 3
20
+ end
21
+
22
+ end
23
+
24
+ describe "A Whm Package" do
25
+
26
+ before do
27
+ @server = Whm::Server.new(
28
+ :username => "username",
29
+ :password => "password",
30
+ :host => "dedicated.server.com"
31
+ )
32
+ data = open(File.dirname(__FILE__) + '/fixtures/accountsummary.xml').read
33
+ @server.expects(:get_xml).with(:url => "accountsummary", :params => {:user=>"magic"}).returns(XmlSimple.xml_in(data,{ 'ForceArray' => false }))
34
+ @account = @server.account("magic")
35
+ end
36
+
37
+
38
+ it "should load account attributes" do
39
+ @account.attributes['user'].should == "magic"
40
+ @account.attributes['domain'].should == "magic.example.com"
41
+ end
42
+
43
+ it "should have a name" do
44
+ @account.name.should == "magic"
45
+ @account.user.should == "magic"
46
+ end
47
+
48
+ it "should change the password" do
49
+ @server.expects(:change_account_password).returns("new_password")
50
+ @account.password=("new_password").should == "new_password"
51
+ end
52
+
53
+ it "should suspend an account" do
54
+ @server.expects(:suspend_account).returns("ok")
55
+ @account.suspend!.should == "ok"
56
+ end
57
+
58
+ it "should unsuspend an account" do
59
+ @server.expects(:unsuspend_account).returns("ok")
60
+ @account.unsuspend!.should == "ok"
61
+ end
62
+
63
+ it "should terminate an account" do
64
+ @server.expects(:terminate_account).returns("ok")
65
+ @account.terminate!.should == "ok"
66
+ end
67
+
68
+ it "should change the package on an account" do
69
+ @server.expects(:change_package).returns("ok")
70
+
71
+ @account.package=("new_package").should == "new_package"
72
+ end
73
+
74
+ it "should read an attribute" do
75
+ @account.domain.should == 'magic.example.com'
76
+ end
77
+
78
+ it "should write an attribute" do
79
+ @account.username = 'newname'
80
+ @account.username.should == 'newname'
81
+ end
82
+
83
+ end
@@ -0,0 +1,195 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require 'lib/whm'
3
+
4
+ describe Whm::Server do
5
+ before do
6
+ @server = Whm::Server.new(
7
+ :username => "username",
8
+ :password => "password",
9
+ :host => "dedicated.server.com"
10
+ )
11
+ end
12
+
13
+ it "should build a server object" do
14
+ @server.should_not be_nil
15
+
16
+ @server.host.should eql("dedicated.server.com")
17
+ @server.username.should eql("username")
18
+ @server.password.should eql("password")
19
+ end
20
+
21
+ it "should have default options" do
22
+ @server.debug.should eql(false)
23
+ @server.ssl.should eql(true)
24
+ @server.port.should eql(2087)
25
+ end
26
+
27
+ it "should handle successful commands from cPanel" do
28
+ end
29
+
30
+ it "should handle unsuccessful commands from cPanel" do
31
+ end
32
+
33
+ it "should list accounts" do
34
+ data = open(File.expand_path('spec/fixtures/listaccts.xml')).read
35
+
36
+ @server.expects(:list_accounts).returns(XmlSimple.xml_in(data))
37
+ @server.list_accounts.eql?(XmlSimple.xml_in(data))
38
+ end
39
+
40
+ it "should list packages" do
41
+ data = open('spec/fixtures/listpkgs.xml').read
42
+
43
+ @server.expects(:list_packages).returns(XmlSimple.xml_in(data))
44
+ @server.list_packages.eql?(XmlSimple.xml_in(data))
45
+ end
46
+
47
+ it "should display the actual server hostname" do
48
+ data = open('spec/fixtures/gethostname.xml').read
49
+
50
+ @server.expects(:hostname).returns(XmlSimple.xml_in(data)["hostname"])
51
+ @server.hostname.eql?("ns100.example.com")
52
+ end
53
+
54
+ it "should display the actual server version" do
55
+ data = open('spec/fixtures/version.xml').read
56
+
57
+ @server.expects(:version).returns(XmlSimple.xml_in(data)["version"])
58
+ @server.version.eql?("11.24.2")
59
+ end
60
+
61
+ it "should generate ssl certificates" do
62
+ data = open('spec/fixtures/generatessl.xml').read
63
+
64
+ params = {
65
+ :city => "Houston",
66
+ :co => "Domain LLC",
67
+ :cod => "Web",
68
+ :country => "US",
69
+ :email => "test@domain.com",
70
+ :host => "domain.com",
71
+ :pass => "password",
72
+ :state => "TX",
73
+ :xemail => "test@domain.com"
74
+ }
75
+
76
+ @server.expects(:generate_ssl_certificate).with(params).returns(XmlSimple.xml_in(data))
77
+ @server.generate_ssl_certificate(params).eql?(XmlSimple.xml_in(data))
78
+ end
79
+
80
+ it "should display account summaries" do
81
+ data = open('spec/fixtures/accountsummary.xml').read
82
+
83
+ params = {
84
+ :user => "magic"
85
+ }
86
+
87
+ @server.expects(:account_summary).with(params).returns(XmlSimple.xml_in(data))
88
+ @server.account_summary(params).eql?(XmlSimple.xml_in(data))
89
+ end
90
+
91
+ it "should change packages" do
92
+ data = open('spec/fixtures/accountsummary.xml').read
93
+
94
+ params = {
95
+ :user => "user",
96
+ :pkg => "new_plan"
97
+ }
98
+
99
+ @server.expects(:change_package).with(params).returns(XmlSimple.xml_in(data))
100
+ @server.change_package(params).eql?(XmlSimple.xml_in(data))
101
+ end
102
+
103
+ it "should create accounts" do
104
+ data = open('spec/fixtures/createacct.xml').read
105
+
106
+ params = {
107
+ :user => "user",
108
+ :domain => "domain.com"
109
+ }
110
+
111
+ @server.expects(:create_account).with(params).returns(XmlSimple.xml_in(data))
112
+ @server.create_account(params).eql?(XmlSimple.xml_in(data))
113
+ end
114
+
115
+ it "should suspend accounts" do
116
+ data = open('spec/fixtures/suspendacct.xml').read
117
+
118
+ params = {
119
+ :user => "user",
120
+ :reason => "N/A"
121
+ }
122
+
123
+ @server.expects(:suspend_account).with(params).returns(XmlSimple.xml_in(data))
124
+ @server.suspend_account(params).eql?(XmlSimple.xml_in(data))
125
+ end
126
+
127
+ it "should unsuspend accounts" do
128
+ data = open('spec/fixtures/unsuspendacct.xml').read
129
+
130
+ params = {
131
+ :user => "user"
132
+ }
133
+
134
+ @server.expects(:unsuspend_account).with(params).returns(XmlSimple.xml_in(data))
135
+ @server.unsuspend_account(params).eql?(XmlSimple.xml_in(data))
136
+ end
137
+
138
+ it "should terminate accounts" do
139
+ data = open('spec/fixtures/removeacct.xml').read
140
+
141
+ params = {
142
+ :user => "user"
143
+ }
144
+
145
+ @server.expects(:terminate_account).with(params).returns(XmlSimple.xml_in(data))
146
+ @server.terminate_account(params).eql?(XmlSimple.xml_in(data))
147
+ end
148
+
149
+ it "should limit an account's bandwidth usage limit" do
150
+ data = open('spec/fixtures/limitbw.xml').read
151
+
152
+ params = {
153
+ :user => "username",
154
+ :bwlimit => "1"
155
+ }
156
+
157
+ @server.expects(:limit_bandwidth_usage).with(params).returns(XmlSimple.xml_in(data))
158
+ @server.limit_bandwidth_usage(params).eql?(XmlSimple.xml_in(data))
159
+ end
160
+
161
+ it "should change account passwords" do
162
+ data = open('spec/fixtures/passwd.xml').read
163
+
164
+ params = {
165
+ :user => "username",
166
+ :pass => "password"
167
+ }
168
+
169
+ @server.expects(:change_account_password).with(params).returns(XmlSimple.xml_in(data))
170
+ @server.change_account_password(params).eql?(XmlSimple.xml_in(data))
171
+ end
172
+
173
+ it "should modify accounts" do
174
+ data = open('spec/fixtures/modifyacct.xml').read
175
+
176
+ params = {
177
+ :user => "user",
178
+ :domain => "domain.com",
179
+ :HASCGI => 0,
180
+ :CPTHEME => "x3",
181
+ :LANG => "english",
182
+ :MAXPOP => 3,
183
+ :MAXFTP => 0,
184
+ :MAXLST => 1,
185
+ :MAXSUB => 3,
186
+ :MAXPARK => 4,
187
+ :MAXADDON => 5,
188
+ :MAXSQL => 6,
189
+ :shell => 1
190
+ }
191
+
192
+ @server.expects(:modify_account).with(params).returns(XmlSimple.xml_in(data))
193
+ @server.modify_account(params).eql?(XmlSimple.xml_in(data))
194
+ end
195
+ end
@@ -0,0 +1,26 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ dir = File.dirname(__FILE__)
10
+
11
+ $:.unshift(File.join(dir, '/lib/'))
12
+
13
+ # Enable mocha mocking/stubbing
14
+ Spec::Runner.configure do |config|
15
+ config.mock_with :mocha
16
+ end
17
+
18
+ def stdout_for(&block)
19
+ # Inspired by http://www.ruby-forum.com/topic/58647
20
+ old_stdout = $stdout
21
+ $stdout = StringIO.new
22
+ yield
23
+ output = $stdout.string
24
+ $stdout = old_stdout
25
+ output
26
+ end