solusvm 0.10.1 → 1.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +75 -25
- data/bin/solusvm +3 -153
- data/lib/solusvm/base.rb +17 -10
- data/lib/solusvm/cli/base_cli.rb +47 -0
- data/lib/solusvm/cli/client_cli.rb +49 -0
- data/lib/solusvm/cli/general_cli.rb +28 -0
- data/lib/solusvm/cli/node_cli.rb +43 -0
- data/lib/solusvm/cli/reseller_cli.rb +73 -0
- data/lib/solusvm/cli/server_cli.rb +168 -0
- data/lib/solusvm/cli.rb +22 -0
- data/lib/solusvm/client.rb +26 -12
- data/lib/solusvm/general.rb +25 -17
- data/lib/solusvm/node.rb +60 -0
- data/lib/solusvm/reseller.rb +72 -0
- data/lib/solusvm/server.rb +116 -2
- data/lib/solusvm/version.rb +1 -1
- data/lib/solusvm.rb +8 -8
- data/solusvm.gemspec +3 -0
- data/test/cli/test_client_cli.rb +80 -0
- data/test/cli/test_general_cli.rb +35 -0
- data/test/cli/test_node_cli.rb +64 -0
- data/test/cli/test_reseller_cli.rb +139 -0
- data/test/cli/test_server_cli.rb +267 -0
- data/test/fixtures/client_delete_success.txt +2 -0
- data/test/fixtures/client_list_success.txt +14 -0
- data/test/fixtures/client_list_success_empty.txt +2 -0
- data/test/fixtures/general_isos_success.txt +3 -0
- data/test/fixtures/general_node_virtualservers_success.txt +15 -0
- data/test/fixtures/general_node_virtualservers_success_empty.txt +2 -0
- data/test/fixtures/general_node_xenresources_success.txt +4 -0
- data/test/fixtures/general_nodes_ids_success.txt +3 -0
- data/test/fixtures/general_plans_success.txt +3 -0
- data/test/fixtures/reseller_change_resources_success.txt +16 -0
- data/test/fixtures/reseller_create_success.txt +23 -0
- data/test/fixtures/reseller_delete_success.txt +2 -0
- data/test/fixtures/reseller_info_success.txt +23 -0
- data/test/fixtures/reseller_list_success.txt +3 -0
- data/test/fixtures/server_bootorder_success.txt +2 -0
- data/test/fixtures/server_change_consolepass_success.txt +3 -0
- data/test/fixtures/server_change_owner_success.txt +2 -0
- data/test/fixtures/server_change_vncpass_success.txt +3 -0
- data/test/fixtures/server_console_success.txt +7 -0
- data/test/fixtures/server_hostname_success.txt +3 -0
- data/test/fixtures/server_mountiso_success.txt +2 -0
- data/test/fixtures/server_network_disable_success.txt +2 -0
- data/test/fixtures/server_network_enable_success.txt +2 -0
- data/test/fixtures/server_pae_success.txt +2 -0
- data/test/fixtures/server_rootpassword_success.txt +3 -0
- data/test/fixtures/server_status_success.txt +2 -0
- data/test/fixtures/server_tun_disable_success.txt +2 -0
- data/test/fixtures/server_tun_enable_success.txt +2 -0
- data/test/fixtures/server_unmountiso_success.txt +2 -0
- data/test/fixtures/server_vnc_success.txt +6 -0
- data/test/helper.rb +6 -0
- data/test/test_cli.rb +17 -0
- data/test/test_client.rb +50 -6
- data/test/test_general.rb +24 -48
- data/test/test_node.rb +107 -0
- data/test/test_reseller.rb +75 -0
- data/test/test_server.rb +95 -1
- metadata +132 -17
@@ -0,0 +1,16 @@
|
|
1
|
+
<status>success</status>
|
2
|
+
<statusmsg>Successfully modified reseller resources</statusmsg>
|
3
|
+
<maxvps>10</maxvps>
|
4
|
+
<maxdisk>21474836480</maxdisk>
|
5
|
+
<maxmem>10737418240</maxmem>
|
6
|
+
<maxusers>20</maxusers>
|
7
|
+
<maxipv4>4</maxipv4>
|
8
|
+
<maxipv6>6</maxipv6>
|
9
|
+
<maxburst>10738466816</maxburst>
|
10
|
+
<maxbw>107374182400</maxbw>
|
11
|
+
<nodegroupids>14,11,9</nodegroupids>
|
12
|
+
<mediagroupids>14,11,9</mediagroupids>
|
13
|
+
<xenpv>1</xenpv>
|
14
|
+
<xenhvm>1</xenhvm>
|
15
|
+
<kvm>1</kvm>
|
16
|
+
<openvz>1</openvz>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<status>success</status>
|
2
|
+
<statusmsg>Successfully added reseller</statusmsg>
|
3
|
+
<username>reseller123</username>
|
4
|
+
<password>123456</password>
|
5
|
+
<email>reseller3@email.com</email>
|
6
|
+
<firstname>Phill</firstname>
|
7
|
+
<lastname>Smith</lastname>
|
8
|
+
<company>FastServers</company>
|
9
|
+
<usernameprefix>vpsuser</usernameprefix>
|
10
|
+
<maxvps>10</maxvps>
|
11
|
+
<maxdisk>21474836480</maxdisk>
|
12
|
+
<maxmem>10737418240</maxmem>
|
13
|
+
<maxusers>20</maxusers>
|
14
|
+
<maxipv4>4</maxipv4>
|
15
|
+
<maxipv6>6</maxipv6>
|
16
|
+
<maxburst>10738466816</maxburst>
|
17
|
+
<maxbw>107374182400</maxbw>
|
18
|
+
<nodegroupids>14,11,9</nodegroupids>
|
19
|
+
<mediagroupids>14,11,9</mediagroupids>
|
20
|
+
<xenpv>1</xenpv>
|
21
|
+
<xenhvm>1</xenhvm>
|
22
|
+
<kvm>1</kvm>
|
23
|
+
<openvz>1</openvz>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<status>success</status>
|
2
|
+
<statusmsg>Successfully added reseller</statusmsg>
|
3
|
+
<username>reseller123</username>
|
4
|
+
<password>123456</password>
|
5
|
+
<email>reseller3@email.com</email>
|
6
|
+
<firstname>Phill</firstname>
|
7
|
+
<lastname>Smith</lastname>
|
8
|
+
<company>FastServers</company>
|
9
|
+
<usernameprefix>vpsuser</usernameprefix>
|
10
|
+
<maxvps>10</maxvps>
|
11
|
+
<maxdisk>21474836480</maxdisk>
|
12
|
+
<maxmem>10737418240</maxmem>
|
13
|
+
<maxusers>20</maxusers>
|
14
|
+
<maxipv4>4</maxipv4>
|
15
|
+
<maxipv6>6</maxipv6>
|
16
|
+
<maxburst>10738466816</maxburst>
|
17
|
+
<maxbw>107374182400</maxbw>
|
18
|
+
<nodegroupids>14,11,9</nodegroupids>
|
19
|
+
<mediagroupids>14,11,9</mediagroupids>
|
20
|
+
<xenpv>1</xenpv>
|
21
|
+
<xenhvm>1</xenhvm>
|
22
|
+
<kvm>1</kvm>
|
23
|
+
<openvz>1</openvz>
|
data/test/helper.rb
CHANGED
@@ -8,6 +8,7 @@ end
|
|
8
8
|
|
9
9
|
require 'solusvm'
|
10
10
|
require 'fake_web'
|
11
|
+
require 'mocha'
|
11
12
|
|
12
13
|
class Test::Unit::TestCase
|
13
14
|
def load_response(name)
|
@@ -26,4 +27,9 @@ class Test::Unit::TestCase
|
|
26
27
|
Solusvm.config(api_login[:id], api_login[:key], :url => 'http://www.example.com/api')
|
27
28
|
end
|
28
29
|
|
30
|
+
def cli_expand_base_arguments(options)
|
31
|
+
arguments = ["--api-login", "thelogin", "--api-key", "thekey", "--api-url", "theurl"]
|
32
|
+
options + arguments
|
33
|
+
end
|
34
|
+
|
29
35
|
end
|
data/test/test_cli.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'solusvm/cli'
|
3
|
+
|
4
|
+
class TestCli < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
# Prevents mocha from stubbing non existent methods so that we now if the CLI is failing because
|
8
|
+
# something was moved around.
|
9
|
+
Mocha::Configuration.prevent(:stubbing_non_existent_method)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_should_print_version
|
13
|
+
$stdout.expects(:puts).with(Solusvm::VERSION)
|
14
|
+
Solusvm::Cli.start(cli_expand_base_arguments(["version"]))
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/test/test_client.rb
CHANGED
@@ -12,9 +12,9 @@ class TestClient < Test::Unit::TestCase
|
|
12
12
|
def test_create
|
13
13
|
options = {:username => 'vps123', :password=> '123456', :email=> 'email@address.com', :firstname => 'phill', :lastname => 'smith'}
|
14
14
|
FakeWeb.register_uri(:get, "#{base_uri}&action=client-create&#{options.to_query}", :body => load_response('client_create_success'))
|
15
|
-
assert @client.create(options)
|
16
15
|
|
17
|
-
params = @client.
|
16
|
+
params = @client.create(options)
|
17
|
+
assert params
|
18
18
|
assert_equal options[:username], params['username']
|
19
19
|
assert_equal options[:firstname], params['firstname']
|
20
20
|
assert_equal options[:lastname], params['lastname']
|
@@ -37,18 +37,62 @@ class TestClient < Test::Unit::TestCase
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_change_password
|
40
|
-
FakeWeb.register_uri(:get, "#{base_uri}&action=client-updatepassword&username=vps123&password=123456", :body => load_response('client_change_password_success'))
|
41
|
-
FakeWeb.register_uri(:get, "#{base_uri}&action=client-updatepassword&username=vps13&password=thecake", :body => load_response('client_change_password_error'))
|
40
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=client-updatepassword&username=vps123&password=123456", :body => load_response('client_change_password_success'))
|
42
41
|
assert @client.change_password("vps123","123456")
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_change_password_fail
|
45
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=client-updatepassword&username=vps13&password=thecake", :body => load_response('client_change_password_error'))
|
43
46
|
assert !@client.change_password("vps13","thecake")
|
44
47
|
end
|
45
48
|
|
46
49
|
def test_authenticate
|
47
50
|
FakeWeb.register_uri(:get, "#{base_uri}&action=client-authenticate&username=u&password=p", :body => load_response('client_authenticate_success'))
|
48
|
-
FakeWeb.register_uri(:get, "#{base_uri}&action=client-authenticate&username=u&password=notp", :body => load_response('client_authenticate_error'))
|
49
51
|
assert @client.authenticate('u', 'p')
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_authenticate_fail
|
55
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=client-authenticate&username=u&password=notp", :body => load_response('client_authenticate_error'))
|
50
56
|
assert ! @client.authenticate('u', 'notp')
|
51
57
|
assert_equal 'invalid username or password', @client.statusmsg
|
52
|
-
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_delete
|
61
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=client-delete&username=vps123", :body => load_response('client_delete_success'))
|
62
|
+
assert @client.delete("vps123")
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_delete_fail
|
66
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=client-delete&username=vps123", :body => load_response('error'))
|
67
|
+
assert !@client.delete("vps123")
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_list
|
71
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=client-list", :body => load_response('client_list_success'))
|
72
|
+
|
73
|
+
clients = @client.list
|
74
|
+
assert_equal 1, clients.size
|
75
|
+
|
76
|
+
client = clients.first
|
77
|
+
assert_equal "1", client["id"]
|
78
|
+
assert_equal "vps123", client["username"]
|
79
|
+
assert_equal "vps123@email.com", client["email"]
|
80
|
+
assert_equal "phill", client["firstname"]
|
81
|
+
assert_equal "smith", client["lastname"]
|
82
|
+
assert_equal "VPS Co", client["company"]
|
83
|
+
assert_equal "Client", client["level"]
|
84
|
+
assert_equal "Active", client["status"]
|
85
|
+
assert_equal "2009-01-01", client["created"]
|
86
|
+
assert_equal "2010-04-23", client["lastlogin"]
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_list_empty
|
90
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=client-list", :body => load_response('client_list_success_empty'))
|
91
|
+
assert @client.list.empty?
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_list_fail
|
95
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=client-list", :body => load_response('error'))
|
96
|
+
assert_nil @client.list
|
53
97
|
end
|
54
98
|
end
|
data/test/test_general.rb
CHANGED
@@ -8,72 +8,48 @@ class TestGeneral < Test::Unit::TestCase
|
|
8
8
|
@general = Solusvm::General.new
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
FakeWeb.register_uri(:get, "#{base_uri}&action=
|
13
|
-
|
14
|
-
expected_nodes = %w(node1 node2 node3 node4)
|
15
|
-
assert_equal expected_nodes, actual_nodes
|
11
|
+
def test_templates
|
12
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=listtemplates&type=xen", :body => load_response('general_templates_success'))
|
13
|
+
assert_equal %w(template1 template2 template3), @general.templates('xen')
|
16
14
|
end
|
17
15
|
|
18
|
-
def
|
19
|
-
FakeWeb.register_uri(:get, "#{base_uri}&action=
|
16
|
+
def test_templates_error
|
17
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=listtemplates&type=whatever", :body => load_response('error'))
|
20
18
|
begin
|
21
|
-
@general.
|
19
|
+
@general.templates('whatever')
|
22
20
|
flunk "Shouldn't get here"
|
23
21
|
rescue Solusvm::SolusvmError => e
|
24
22
|
assert e.message.match /Invalid Virtual Server type/
|
25
23
|
end
|
26
24
|
end
|
27
25
|
|
28
|
-
def
|
29
|
-
FakeWeb.register_uri(:get, "#{base_uri}&action=
|
30
|
-
|
31
|
-
expected_templates = %w(template1 template2 template3)
|
32
|
-
assert_equal expected_templates, actual_templates
|
26
|
+
def test_plans
|
27
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=listplans&type=xen", :body => load_response('general_plans_success'))
|
28
|
+
assert_equal %w(plan1 plan2 plan3 plan4), @general.plans('xen')
|
33
29
|
end
|
34
30
|
|
35
|
-
def
|
36
|
-
FakeWeb.register_uri(:get, "#{base_uri}&action=
|
31
|
+
def test_plans_error
|
32
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=listplans&type=whatever", :body => load_response('error'))
|
37
33
|
begin
|
38
|
-
@general.
|
34
|
+
@general.plans('whatever')
|
39
35
|
flunk "Shouldn't get here"
|
40
36
|
rescue Solusvm::SolusvmError => e
|
41
37
|
assert e.message.match /Invalid Virtual Server type/
|
42
38
|
end
|
43
39
|
end
|
44
40
|
|
45
|
-
def
|
46
|
-
FakeWeb.register_uri(:get, "#{base_uri}&action=
|
47
|
-
|
48
|
-
|
49
|
-
assert_equal '1000', node_statistics['freedisk']
|
50
|
-
assert_equal '22', node_statistics['sshport']
|
51
|
-
assert_equal 'city', node_statistics['city']
|
52
|
-
assert_equal 'name', node_statistics['name']
|
53
|
-
assert_equal '0', node_statistics['freeips']
|
54
|
-
assert_equal 'country', node_statistics['country']
|
55
|
-
assert_equal 'x86_64', node_statistics['arch']
|
56
|
-
assert_equal '1', node_statistics['id']
|
57
|
-
assert_equal '10', node_statistics['freememory']
|
58
|
-
assert_equal '2', node_statistics['virtualservers']
|
59
|
-
assert_equal '127.0.0.1', node_statistics['ip']
|
60
|
-
assert_equal 'hostname.com', node_statistics['hostname']
|
61
|
-
assert_equal 'success', node_statistics['status']
|
41
|
+
def test_isos
|
42
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=listiso&type=xen", :body => load_response('general_isos_success'))
|
43
|
+
assert_equal %w(iso1 iso2 iso3), @general.isos('xen')
|
62
44
|
end
|
63
45
|
|
64
|
-
def
|
65
|
-
FakeWeb.register_uri(:get, "#{base_uri}&action=
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
def test_list_all_ips_not_available
|
74
|
-
FakeWeb.register_uri(:get, "#{base_uri}&action=node-iplist&nodeid=1", :body => load_response('general_node_list_all_ips_not_available'))
|
75
|
-
avaialble_ips = @general.node_available_ips(1)
|
76
|
-
|
77
|
-
assert avaialble_ips.empty?
|
46
|
+
def test_isos_error
|
47
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=listiso&type=whatever", :body => load_response('error'))
|
48
|
+
begin
|
49
|
+
@general.isos('whatever')
|
50
|
+
flunk "Shouldn't get here"
|
51
|
+
rescue Solusvm::SolusvmError => e
|
52
|
+
assert e.message.match /Invalid Virtual Server type/
|
53
|
+
end
|
78
54
|
end
|
79
|
-
end
|
55
|
+
end
|
data/test/test_node.rb
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestNode < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
FakeWeb.allow_net_connect = false
|
6
|
+
FakeWeb.clean_registry
|
7
|
+
setup_solusvm
|
8
|
+
@nodes = Solusvm::Node.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_list
|
12
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=listnodes&type=xen", :body => load_response('general_nodes_success'))
|
13
|
+
assert_equal %w(node1 node2 node3 node4), @nodes.list('xen')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_nodes_error
|
17
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=listnodes&type=whatever", :body => load_response('error'))
|
18
|
+
begin
|
19
|
+
@nodes.list('whatever')
|
20
|
+
flunk "Shouldn't get here"
|
21
|
+
rescue Solusvm::SolusvmError => e
|
22
|
+
assert e.message.match /Invalid Virtual Server type/
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_statistics
|
27
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=node-statistics&nodeid=1", :body => load_response('general_node_statistics_success'))
|
28
|
+
node_statistics = @nodes.statistics(1)
|
29
|
+
|
30
|
+
assert_equal '1000', node_statistics['freedisk']
|
31
|
+
assert_equal '22', node_statistics['sshport']
|
32
|
+
assert_equal 'city', node_statistics['city']
|
33
|
+
assert_equal 'name', node_statistics['name']
|
34
|
+
assert_equal '0', node_statistics['freeips']
|
35
|
+
assert_equal 'country', node_statistics['country']
|
36
|
+
assert_equal 'x86_64', node_statistics['arch']
|
37
|
+
assert_equal '1', node_statistics['id']
|
38
|
+
assert_equal '10', node_statistics['freememory']
|
39
|
+
assert_equal '2', node_statistics['virtualservers']
|
40
|
+
assert_equal '127.0.0.1', node_statistics['ip']
|
41
|
+
assert_equal 'hostname.com', node_statistics['hostname']
|
42
|
+
assert_equal 'success', node_statistics['status']
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_list_all_ips_available
|
46
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=node-iplist&nodeid=1", :body => load_response('general_node_list_all_ips_available'))
|
47
|
+
assert_equal %w(123.123.123.123 124.124.124.124 125.125.125.125).sort, @nodes.available_ips(1).sort
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_list_all_ips_not_available
|
51
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=node-iplist&nodeid=1", :body => load_response('general_node_list_all_ips_not_available'))
|
52
|
+
assert @nodes.available_ips(1).empty?
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_ids
|
56
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=node-idlist&type=xen", :body => load_response('general_nodes_ids_success'))
|
57
|
+
assert_equal %w(nodeid1 nodeid2 nodeid3 nodeid4), @nodes.ids('xen')
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_nodes_ids_error
|
61
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=node-idlist&type=whatever", :body => load_response('error'))
|
62
|
+
begin
|
63
|
+
@nodes.ids('whatever')
|
64
|
+
flunk "Shouldn't get here"
|
65
|
+
rescue Solusvm::SolusvmError => e
|
66
|
+
assert e.message.match /Invalid Virtual Server type/
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_virtualservers
|
71
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=node-virtualservers&nodeid=1", :body => load_response('general_node_virtualservers_success'))
|
72
|
+
|
73
|
+
servers = @nodes.virtualservers(1)
|
74
|
+
assert_equal 1, servers.size
|
75
|
+
|
76
|
+
server = servers.first
|
77
|
+
assert_equal "theid", server["vserverid"]
|
78
|
+
assert_equal "thexid", server["ctid-xid"]
|
79
|
+
assert_equal "theclientid", server["clientid"]
|
80
|
+
assert_equal "theip", server["ipaddress"]
|
81
|
+
assert_equal "thehostname", server["hostname"]
|
82
|
+
assert_equal "thetemplate", server["template"]
|
83
|
+
assert_equal "thediskspace", server["hdd"]
|
84
|
+
assert_equal "thememory", server["memory"]
|
85
|
+
assert_equal "theswap", server["swap-burst"]
|
86
|
+
assert_equal "thetype", server["type"]
|
87
|
+
assert_equal "themac", server["mac"]
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_virtualservers_empty
|
91
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=node-virtualservers&nodeid=1", :body => load_response('general_node_virtualservers_success_empty'))
|
92
|
+
assert @nodes.virtualservers(1).empty?
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_virtualservers_fail
|
96
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=node-virtualservers&nodeid=1", :body => load_response('error'))
|
97
|
+
assert_nil @nodes.virtualservers(1)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_xenresources
|
101
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=node-xenresources&nodeid=1", :body => load_response('general_node_xenresources_success'))
|
102
|
+
node_resources = @nodes.xenresources(1)
|
103
|
+
|
104
|
+
assert_equal 'thefreememory', node_resources['freememory']
|
105
|
+
assert_equal 'thefreehdd', node_resources['freehdd']
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestReseller < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
setup_solusvm
|
7
|
+
FakeWeb.allow_net_connect = false
|
8
|
+
FakeWeb.clean_registry
|
9
|
+
@reseller = Solusvm::Reseller.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_create
|
13
|
+
options = {:username => 'reseller123', :password=> '123456', :email=> 'reseller3@email.com', :firstname => 'Phill', :lastname => 'Smith'}
|
14
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=reseller-create&#{options.to_query}", :body => load_response('reseller_create_success'))
|
15
|
+
|
16
|
+
params = @reseller.create(options)
|
17
|
+
|
18
|
+
assert params
|
19
|
+
assert_equal options[:username], params['username']
|
20
|
+
assert_equal options[:firstname], params['firstname']
|
21
|
+
assert_equal options[:lastname], params['lastname']
|
22
|
+
assert_equal options[:password], params['password']
|
23
|
+
assert_equal options[:email], params['email']
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_create_fail
|
27
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=reseller-create", :body => load_response('error'))
|
28
|
+
assert ! @reseller.create
|
29
|
+
assert_equal 'error message', @reseller.statusmsg
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_change_resources
|
33
|
+
options = {:maxvps => 10}
|
34
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=reseller-modifyresources&username=vps123&#{options.to_query}", :body => load_response('reseller_change_resources_success'))
|
35
|
+
|
36
|
+
params = @reseller.change_resources("vps123", options)
|
37
|
+
|
38
|
+
assert params
|
39
|
+
assert "10", params['maxvps']
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_change_resources_fail
|
43
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=reseller-modifyresources&username=vps13", :body => load_response('error'))
|
44
|
+
assert !@reseller.change_resources("vps13")
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_info
|
48
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=reseller-info&username=vps123", :body => load_response('reseller_info_success'))
|
49
|
+
|
50
|
+
params = @reseller.info("vps123")
|
51
|
+
|
52
|
+
assert params
|
53
|
+
assert_equal "reseller123", params['username']
|
54
|
+
assert_equal "Phill", params['firstname']
|
55
|
+
assert_equal "Smith", params['lastname']
|
56
|
+
assert_equal "123456", params['password']
|
57
|
+
assert_equal "reseller3@email.com", params['email']
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_info_fail
|
61
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=reseller-info&username=vps13", :body => load_response('error'))
|
62
|
+
assert !@reseller.info("vps13")
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_list
|
66
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=reseller-list", :body => load_response('reseller_list_success'))
|
67
|
+
assert_equal %w(username1 username2 username3), @reseller.list
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_delete
|
71
|
+
FakeWeb.register_uri(:get, "#{base_uri}&action=reseller-delete&username=vps123", :body => load_response('reseller_delete_success'))
|
72
|
+
assert @reseller.delete("vps123")
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|