squall 1.1.0 → 1.2.0beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/lib/squall/support/base.rb +12 -37
- data/lib/squall/support/exception.rb +8 -8
- data/lib/squall/support/on_app_errors.rb +23 -0
- data/lib/squall/support/version.rb +1 -1
- data/lib/squall.rb +3 -1
- data/spec/squall/data_store_zone_spec.rb +3 -3
- data/spec/squall/firewall_rule_spec.rb +3 -3
- data/spec/squall/hypervisor_spec.rb +3 -3
- data/spec/squall/hypervisor_zone_spec.rb +3 -3
- data/spec/squall/ip_address_join_spec.rb +3 -3
- data/spec/squall/ip_address_spec.rb +1 -1
- data/spec/squall/network_spec.rb +3 -3
- data/spec/squall/network_zone_spec.rb +7 -7
- data/spec/squall/payment_spec.rb +3 -3
- data/spec/squall/role_spec.rb +3 -3
- data/spec/squall/support/base_spec.rb +2 -34
- data/spec/squall/template_spec.rb +1 -1
- data/spec/squall/transaction_spec.rb +1 -1
- data/spec/squall/user_group_spec.rb +2 -2
- data/spec/squall/user_spec.rb +7 -7
- data/spec/squall/virtual_machine_spec.rb +22 -22
- data/spec/squall/whitelist_spec.rb +4 -4
- data/spec/vcr_cassettes/data_store_zone/create.yml +1 -1
- data/spec/vcr_cassettes/data_store_zone/edit.yml +2 -2
- data/spec/vcr_cassettes/firewall_rule/create.yml +2 -2
- data/spec/vcr_cassettes/firewall_rule/edit.yml +2 -2
- data/spec/vcr_cassettes/hypervisor/add_network_join.yml +1 -1
- data/spec/vcr_cassettes/hypervisor/create.yml +1 -1
- data/spec/vcr_cassettes/hypervisor/edit.yml +1 -1
- data/spec/vcr_cassettes/hypervisor_zones/add_network_join.yml +1 -1
- data/spec/vcr_cassettes/hypervisor_zones/create.yml +1 -1
- data/spec/vcr_cassettes/hypervisor_zones/edit.yml +2 -2
- data/spec/vcr_cassettes/ipaddress/create.yml +1 -1
- data/spec/vcr_cassettes/ipaddress/edit.yml +1 -1
- data/spec/vcr_cassettes/ipaddress_join/assign.yml +2 -2
- data/spec/vcr_cassettes/network/create.yml +5 -5
- data/spec/vcr_cassettes/network/edit.yml +5 -5
- data/spec/vcr_cassettes/network_zones/create.yml +1 -1
- data/spec/vcr_cassettes/network_zones/edit.yml +2 -2
- data/spec/vcr_cassettes/payment/create.yml +2 -2
- data/spec/vcr_cassettes/payment/edit.yml +2 -2
- data/spec/vcr_cassettes/role/create.yml +1 -1
- data/spec/vcr_cassettes/role/edit.yml +1 -1
- data/spec/vcr_cassettes/user/create.yml +1 -1
- data/spec/vcr_cassettes/user/edit.yml +1 -1
- data/spec/vcr_cassettes/user/edit_role.yml +3 -3
- data/spec/vcr_cassettes/user_group/create.yml +1 -1
- data/spec/vcr_cassettes/user_group/edit.yml +2 -2
- data/spec/vcr_cassettes/virtual_machine/build.yml +2 -2
- data/spec/vcr_cassettes/virtual_machine/create.yml +1 -1
- data/spec/vcr_cassettes/virtual_machine/edit.yml +2 -2
- data/spec/vcr_cassettes/virtual_machine/migrate.yml +3 -3
- data/spec/vcr_cassettes/virtual_machine/resize.yml +2 -2
- data/spec/vcr_cassettes/virtual_machine/segregate.yml +3 -3
- data/spec/vcr_cassettes/whitelist/create.yml +2 -2
- data/spec/vcr_cassettes/whitelist/edit.yml +2 -2
- data/squall.gemspec +4 -2
- metadata +41 -26
data/LICENSE
CHANGED
data/README.md
CHANGED
data/lib/squall/support/base.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
Faraday.register_middleware :response, :on_app_errors => Squall::OnAppErrors
|
2
|
+
|
1
3
|
module Squall
|
2
4
|
# All OnApp API classes subclass Base to get access to
|
3
5
|
# HTTParty methods and other convenience methods
|
@@ -11,21 +13,6 @@ module Squall
|
|
11
13
|
# HTTPart request result
|
12
14
|
attr_reader :result
|
13
15
|
|
14
|
-
# HTTParty class methods
|
15
|
-
include HTTParty
|
16
|
-
|
17
|
-
def initialize
|
18
|
-
self.class.base_uri Squall::config[:base_uri]
|
19
|
-
self.class.basic_auth Squall::config[:username], Squall::config[:password]
|
20
|
-
self.class.format :json
|
21
|
-
self.class.headers 'Content-Type' => 'application/json'
|
22
|
-
if Squall::config[:debug]
|
23
|
-
self.class.debug_output
|
24
|
-
else
|
25
|
-
self.class.debug_output(nil)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
16
|
# Returns a Params.new
|
30
17
|
def params
|
31
18
|
@params = Squall::Params.new
|
@@ -44,17 +31,6 @@ module Squall
|
|
44
31
|
options.empty? ? {} : {:query => { key_for_class => options.first}}
|
45
32
|
end
|
46
33
|
|
47
|
-
# Returns an array of Request errors
|
48
|
-
def errors
|
49
|
-
return [] if @success
|
50
|
-
err = {}
|
51
|
-
@result.each do |k,v|
|
52
|
-
err[k] ||= []
|
53
|
-
err[k].push v.respond_to?(:first) ? v.first : v
|
54
|
-
end
|
55
|
-
err
|
56
|
-
end
|
57
|
-
|
58
34
|
# Peforms an HTTP Request
|
59
35
|
#
|
60
36
|
# ==== Options
|
@@ -68,18 +44,17 @@ module Squall
|
|
68
44
|
# request :put, '/something.json', :something => 1 # PUT /something.json?something=1
|
69
45
|
def request(request_method, path, options = {})
|
70
46
|
check_config
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
when 422
|
79
|
-
raise RequestError, @result
|
80
|
-
else
|
81
|
-
raise ServerError, @result
|
47
|
+
conn = Faraday.new(:url => Squall.config[:base_uri]) do |c|
|
48
|
+
c.basic_auth Squall.config[:username], Squall.config[:password]
|
49
|
+
c.params = (options[:query] || {})
|
50
|
+
c.request :url_encoded
|
51
|
+
c.response :on_app_errors
|
52
|
+
c.response :json
|
53
|
+
c.adapter :net_http
|
82
54
|
end
|
55
|
+
response = conn.send(request_method, path)
|
56
|
+
@success = (200..207).include?(response.env[:status])
|
57
|
+
@result = conn.send(request_method, path).body
|
83
58
|
end
|
84
59
|
|
85
60
|
# Raises an error if a request is made without first calling Squall.config
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Squall
|
2
|
+
# Config missing
|
3
|
+
class NoConfig < StandardError;end
|
4
|
+
|
2
5
|
# HTTP 404 not found
|
3
|
-
class
|
4
|
-
|
5
|
-
# HTTP 500 error
|
6
|
-
class RequestError < StandardError;end
|
6
|
+
class NotFoundError < StandardError;end
|
7
7
|
|
8
8
|
# HTTP 422
|
9
|
+
class ClientError < StandardError;end
|
10
|
+
|
11
|
+
# HTTP 500 error
|
9
12
|
class ServerError < StandardError;end
|
10
|
-
|
11
|
-
# Config missing
|
12
|
-
class NoConfig < StandardError;end
|
13
|
-
end
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Squall
|
2
|
+
class OnAppErrors < Faraday::Response::Middleware
|
3
|
+
|
4
|
+
def on_complete(env)
|
5
|
+
# https://help.onapp.com/manual.php?m=2#p29
|
6
|
+
case env[:status]
|
7
|
+
when 403
|
8
|
+
raise Squall::ForbiddenError, response_values(env)
|
9
|
+
when 404
|
10
|
+
raise Squall::NotFoundError, response_values(env)
|
11
|
+
when 422
|
12
|
+
raise Squall::ClientError, response_values(env)
|
13
|
+
when 500
|
14
|
+
raise Squall::ServerError, response_values(env)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def response_values(env)
|
19
|
+
{:status => env[:status], :headers => env[:response_headers], :body => env[:body]}
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
data/lib/squall.rb
CHANGED
@@ -27,7 +27,7 @@ describe Squall::DataStoreZone do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns not found for invalid data store zone id" do
|
30
|
-
expect { @data_store_zone.show(404) }.to raise_error(Squall::
|
30
|
+
expect { @data_store_zone.show(404) }.to raise_error(Squall::NotFoundError)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "returns a data store zone" do
|
@@ -74,7 +74,7 @@ describe Squall::DataStoreZone do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
it "raises an error for an invalid data store zone id" do
|
77
|
-
expect { @data_store_zone.edit(404, @valid) }.to raise_error(Squall::
|
77
|
+
expect { @data_store_zone.edit(404, @valid) }.to raise_error(Squall::NotFoundError)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -90,7 +90,7 @@ describe Squall::DataStoreZone do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
it "returns NotFound for invalid data store zone id" do
|
93
|
-
expect { @data_store_zone.delete(404) }.to raise_error(Squall::
|
93
|
+
expect { @data_store_zone.delete(404) }.to raise_error(Squall::NotFoundError)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -54,7 +54,7 @@ describe Squall::FirewallRule do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "raises an error for an invalid vm id" do
|
57
|
-
expect { @firewall_rule.create(404, @valid) }.to raise_error(Squall::
|
57
|
+
expect { @firewall_rule.create(404, @valid) }.to raise_error(Squall::NotFoundError)
|
58
58
|
end
|
59
59
|
|
60
60
|
it "creates a firewall rule for a virtual machine" do
|
@@ -86,7 +86,7 @@ describe Squall::FirewallRule do
|
|
86
86
|
end
|
87
87
|
|
88
88
|
it "raises an error for an invalid firewall rule id" do
|
89
|
-
expect { @firewall_rule.edit(1, 404, @valid) }.to raise_error(Squall::
|
89
|
+
expect { @firewall_rule.edit(1, 404, @valid) }.to raise_error(Squall::NotFoundError)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -105,7 +105,7 @@ describe Squall::FirewallRule do
|
|
105
105
|
end
|
106
106
|
|
107
107
|
it "returns NotFound for missing virtual machine" do
|
108
|
-
expect { @firewall_rule.delete(1, 404) }.to raise_error(Squall::
|
108
|
+
expect { @firewall_rule.delete(1, 404) }.to raise_error(Squall::NotFoundError)
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
@@ -28,7 +28,7 @@ describe Squall::Hypervisor do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it "returns not found for invalid hvs" do
|
31
|
-
expect { @hv.show(404) }.to raise_error(Squall::
|
31
|
+
expect { @hv.show(404) }.to raise_error(Squall::NotFoundError)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "returns a hv" do
|
@@ -89,7 +89,7 @@ describe Squall::Hypervisor do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it "404s on not found" do
|
92
|
-
expect { @hv.reboot(404) }.to raise_error(Squall::
|
92
|
+
expect { @hv.reboot(404) }.to raise_error(Squall::NotFoundError)
|
93
93
|
@hv.success.should be_false
|
94
94
|
end
|
95
95
|
|
@@ -106,7 +106,7 @@ describe Squall::Hypervisor do
|
|
106
106
|
end
|
107
107
|
|
108
108
|
it "404s on not found" do
|
109
|
-
expect { @hv.delete(404) }.to raise_error(Squall::
|
109
|
+
expect { @hv.delete(404) }.to raise_error(Squall::NotFoundError)
|
110
110
|
@hv.success.should be_false
|
111
111
|
end
|
112
112
|
|
@@ -27,7 +27,7 @@ describe Squall::HypervisorZone do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns not found for invalid hypervisor zone id" do
|
30
|
-
expect { @hypervisor_zone.show(404) }.to raise_error(Squall::
|
30
|
+
expect { @hypervisor_zone.show(404) }.to raise_error(Squall::NotFoundError)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "returns a hypervisor zone" do
|
@@ -74,7 +74,7 @@ describe Squall::HypervisorZone do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
it "raises an error for an invalid hypervisor zone id" do
|
77
|
-
expect { @hypervisor_zone.edit(404, @valid) }.to raise_error(Squall::
|
77
|
+
expect { @hypervisor_zone.edit(404, @valid) }.to raise_error(Squall::NotFoundError)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -90,7 +90,7 @@ describe Squall::HypervisorZone do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
it "returns NotFound for invalid hypervisor zone id" do
|
93
|
-
expect { @hypervisor_zone.delete(404) }.to raise_error(Squall::
|
93
|
+
expect { @hypervisor_zone.delete(404) }.to raise_error(Squall::NotFoundError)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -13,7 +13,7 @@ describe Squall::IpAddressJoin do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "raises NotFound with an invalid virtual machine ID" do
|
16
|
-
expect { @join.list(404) }.to raise_error(Squall::
|
16
|
+
expect { @join.list(404) }.to raise_error(Squall::NotFoundError)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "returns list of ip_addresses" do
|
@@ -38,7 +38,7 @@ describe Squall::IpAddressJoin do
|
|
38
38
|
it "raises NotFound with an invalid virtual machine ID" do
|
39
39
|
expect {
|
40
40
|
@join.assign(404, {:ip_address_id => 1, :network_interface_id => 1})
|
41
|
-
}.to raise_error(Squall::
|
41
|
+
}.to raise_error(Squall::NotFoundError)
|
42
42
|
end
|
43
43
|
|
44
44
|
it "assigns the IP join" do
|
@@ -56,7 +56,7 @@ describe Squall::IpAddressJoin do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it "raises NotFound with an invalid ID" do
|
59
|
-
expect { @join.delete(404, 1) }.to raise_error(Squall::
|
59
|
+
expect { @join.delete(404, 1) }.to raise_error(Squall::NotFoundError)
|
60
60
|
end
|
61
61
|
|
62
62
|
it "deletes the IP join" do
|
data/spec/squall/network_spec.rb
CHANGED
@@ -49,7 +49,7 @@ describe Squall::Network do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it "404s on not found" do
|
52
|
-
expect { @network.edit(404) }.to raise_error(Squall::
|
52
|
+
expect { @network.edit(404) }.to raise_error(Squall::NotFoundError)
|
53
53
|
@network.success.should be_false
|
54
54
|
end
|
55
55
|
end
|
@@ -64,7 +64,7 @@ describe Squall::Network do
|
|
64
64
|
pending "Broken in OnApp" do
|
65
65
|
expect {
|
66
66
|
@network.create(:label => 'networktaken')
|
67
|
-
}.to raise_error(Squall::
|
67
|
+
}.to raise_error(Squall::ServerError)
|
68
68
|
@network.errors['label'].should include("has already been taken")
|
69
69
|
end
|
70
70
|
end
|
@@ -108,7 +108,7 @@ describe Squall::Network do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
it "404s on not found" do
|
111
|
-
expect { @network.delete(404) }.to raise_error(Squall::
|
111
|
+
expect { @network.delete(404) }.to raise_error(Squall::NotFoundError)
|
112
112
|
@network.success.should be_false
|
113
113
|
end
|
114
114
|
|
@@ -27,7 +27,7 @@ describe Squall::NetworkZone do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns not found for invalid network zone id" do
|
30
|
-
expect { @network_zone.show(404) }.to raise_error(Squall::
|
30
|
+
expect { @network_zone.show(404) }.to raise_error(Squall::NotFoundError)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "returns a network zone" do
|
@@ -74,7 +74,7 @@ describe Squall::NetworkZone do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
it "raises an error for an invalid network zone id" do
|
77
|
-
expect { @network_zone.edit(404, @valid) }.to raise_error(Squall::
|
77
|
+
expect { @network_zone.edit(404, @valid) }.to raise_error(Squall::NotFoundError)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -90,7 +90,7 @@ describe Squall::NetworkZone do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
it "returns NotFound for invalid network zone id" do
|
93
|
-
expect { @network_zone.delete(404) }.to raise_error(Squall::
|
93
|
+
expect { @network_zone.delete(404) }.to raise_error(Squall::NotFoundError)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -106,11 +106,11 @@ describe Squall::NetworkZone do
|
|
106
106
|
end
|
107
107
|
|
108
108
|
it "returns NotFound error for invalid id" do
|
109
|
-
expect { @network_zone.attach(404, 1) }.to raise_error(Squall::
|
109
|
+
expect { @network_zone.attach(404, 1) }.to raise_error(Squall::NotFoundError)
|
110
110
|
end
|
111
111
|
|
112
112
|
it "returns NotFound error for invalid network id" do
|
113
|
-
expect { @network_zone.attach(1, 404) }.to raise_error(Squall::
|
113
|
+
expect { @network_zone.attach(1, 404) }.to raise_error(Squall::NotFoundError)
|
114
114
|
end
|
115
115
|
|
116
116
|
it "attaches a network to the network zone" do
|
@@ -131,11 +131,11 @@ describe Squall::NetworkZone do
|
|
131
131
|
end
|
132
132
|
|
133
133
|
it "returns NotFound error for invalid id" do
|
134
|
-
expect { @network_zone.detach(404, 1) }.to raise_error(Squall::
|
134
|
+
expect { @network_zone.detach(404, 1) }.to raise_error(Squall::NotFoundError)
|
135
135
|
end
|
136
136
|
|
137
137
|
it "returns NotFound error for invalid network id" do
|
138
|
-
expect { @network_zone.detach(1, 404) }.to raise_error(Squall::
|
138
|
+
expect { @network_zone.detach(1, 404) }.to raise_error(Squall::NotFoundError)
|
139
139
|
end
|
140
140
|
|
141
141
|
it "detaches a network to the network zone" do
|
data/spec/squall/payment_spec.rb
CHANGED
@@ -45,7 +45,7 @@ describe Squall::Payment do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it "raises an error for an invalid user id" do
|
48
|
-
expect { @payment.create(404, @valid) }.to raise_error(Squall::
|
48
|
+
expect { @payment.create(404, @valid) }.to raise_error(Squall::NotFoundError)
|
49
49
|
end
|
50
50
|
|
51
51
|
it "creates a payment for a user" do
|
@@ -75,7 +75,7 @@ describe Squall::Payment do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
it "raises an error for an invalid payment id" do
|
78
|
-
expect { @payment.edit(1, 404, @valid) }.to raise_error(Squall::
|
78
|
+
expect { @payment.edit(1, 404, @valid) }.to raise_error(Squall::NotFoundError)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -91,7 +91,7 @@ describe Squall::Payment do
|
|
91
91
|
end
|
92
92
|
|
93
93
|
it "returns NotFound for missing user" do
|
94
|
-
expect { @payment.delete(1, 404) }.to raise_error(Squall::
|
94
|
+
expect { @payment.delete(1, 404) }.to raise_error(Squall::NotFoundError)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
data/spec/squall/role_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe Squall::Role do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it "returns 404 for invalid id" do
|
23
|
-
expect { @role.show(404) }.to raise_error(Squall::
|
23
|
+
expect { @role.show(404) }.to raise_error(Squall::NotFoundError)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "returns a role" do
|
@@ -36,7 +36,7 @@ describe Squall::Role do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it "returns 404 for invalid id" do
|
39
|
-
expect { @role.edit(404) }.to raise_error(Squall::
|
39
|
+
expect { @role.edit(404) }.to raise_error(Squall::NotFoundError)
|
40
40
|
end
|
41
41
|
|
42
42
|
it "allows all optional params" do
|
@@ -63,7 +63,7 @@ describe Squall::Role do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it "returns not found for invalid user" do
|
66
|
-
expect { @role.delete(5) }.to raise_error(Squall::
|
66
|
+
expect { @role.delete(5) }.to raise_error(Squall::NotFoundError)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "returns a role" do
|
@@ -12,24 +12,6 @@ describe Squall::Base do
|
|
12
12
|
@base = Squall::Base.new
|
13
13
|
end
|
14
14
|
|
15
|
-
describe "#initialize" do
|
16
|
-
it "sets the base_uri" do
|
17
|
-
@base.class.base_uri.should_not be_nil
|
18
|
-
end
|
19
|
-
|
20
|
-
it "sets credentials" do
|
21
|
-
@base.class.default_options[:basic_auth].should include(:username, :password)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "uses JSON" do
|
25
|
-
@base.class.default_options[:format].should == :json
|
26
|
-
end
|
27
|
-
|
28
|
-
it "sets JSON headers" do
|
29
|
-
@base.class.default_options[:headers].should include('Content-Type' => 'application/json')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
15
|
describe "#request" do
|
34
16
|
it "200-207 returns success" do
|
35
17
|
(200..207).each do |i|
|
@@ -42,7 +24,7 @@ describe Squall::Base do
|
|
42
24
|
|
43
25
|
it "raises NotFound for 404s" do
|
44
26
|
mock_request(:get, '/404', :status => [404, "NotFound"])
|
45
|
-
expect { @base.request(:get, '/404') }.to raise_error(Squall::
|
27
|
+
expect { @base.request(:get, '/404') }.to raise_error(Squall::NotFoundError)
|
46
28
|
@base.success.should be_false
|
47
29
|
end
|
48
30
|
|
@@ -54,7 +36,7 @@ describe Squall::Base do
|
|
54
36
|
|
55
37
|
it "raises RequestError on errors" do
|
56
38
|
mock_request(:get, '/422', :status => [422, "Unprocessable"])
|
57
|
-
expect { @base.request(:get, '/422') }.to raise_error(Squall::
|
39
|
+
expect { @base.request(:get, '/422') }.to raise_error(Squall::ClientError)
|
58
40
|
@base.success.should be_false
|
59
41
|
end
|
60
42
|
|
@@ -64,20 +46,6 @@ describe Squall::Base do
|
|
64
46
|
end
|
65
47
|
end
|
66
48
|
|
67
|
-
describe "#errors" do
|
68
|
-
it "is empty on success" do
|
69
|
-
mock_request(:get, '/200_errors', :status => [200, "OK"], :body => "{\"something\":[\"errors\"]}")
|
70
|
-
@base.request(:get, '/200_errors')
|
71
|
-
@base.errors.should be_empty
|
72
|
-
end
|
73
|
-
|
74
|
-
it "returns an error hash" do
|
75
|
-
mock_request(:get, '/500_errors', :status => [500, "Internal Server Error"], :body => "{\"something\":[\"errors\"]}")
|
76
|
-
expect { @base.request(:get, '/500_errors') }.to raise_error(Squall::ServerError)
|
77
|
-
@base.errors.should_not be_empty
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
49
|
describe "#params" do
|
82
50
|
it "returns Params.new" do
|
83
51
|
@base.params.should be_a(Squall::Params)
|
@@ -30,7 +30,7 @@ describe Squall::Template do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "404s on not found" do
|
33
|
-
expect { @template.make_public(404) }.to raise_error(Squall::
|
33
|
+
expect { @template.make_public(404) }.to raise_error(Squall::NotFoundError)
|
34
34
|
@template.success.should be_false
|
35
35
|
end
|
36
36
|
|
@@ -27,7 +27,7 @@ describe Squall::Transaction do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns not found for invalid" do
|
30
|
-
expect { @transaction.show(5) }.to raise_error(Squall::
|
30
|
+
expect { @transaction.show(5) }.to raise_error(Squall::NotFoundError)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "returns a transaction" do
|
@@ -51,7 +51,7 @@ describe Squall::UserGroup do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it "raises an error for an invalid user group id" do
|
54
|
-
expect { @user_group.edit(404, @valid) }.to raise_error(Squall::
|
54
|
+
expect { @user_group.edit(404, @valid) }.to raise_error(Squall::NotFoundError)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -67,7 +67,7 @@ describe Squall::UserGroup do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it "returns NotFound for missing user" do
|
70
|
-
expect { @user_group.delete(404) }.to raise_error(Squall::
|
70
|
+
expect { @user_group.delete(404) }.to raise_error(Squall::NotFoundError)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
data/spec/squall/user_spec.rb
CHANGED
@@ -102,7 +102,7 @@ describe Squall::User do
|
|
102
102
|
end
|
103
103
|
|
104
104
|
it "returns not found for invalid users" do
|
105
|
-
expect { @user.show(404) }.to raise_error(Squall::
|
105
|
+
expect { @user.show(404) }.to raise_error(Squall::NotFoundError)
|
106
106
|
end
|
107
107
|
|
108
108
|
it "returns a user" do
|
@@ -163,7 +163,7 @@ describe Squall::User do
|
|
163
163
|
end
|
164
164
|
|
165
165
|
it "returns NotFound for missing user" do
|
166
|
-
expect { @user.delete(404) }.to raise_error(Squall::
|
166
|
+
expect { @user.delete(404) }.to raise_error(Squall::NotFoundError)
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
@@ -198,7 +198,7 @@ describe Squall::User do
|
|
198
198
|
end
|
199
199
|
|
200
200
|
it "404s on not found" do
|
201
|
-
expect { @user.virtual_machines(404) }.to raise_error(Squall::
|
201
|
+
expect { @user.virtual_machines(404) }.to raise_error(Squall::NotFoundError)
|
202
202
|
end
|
203
203
|
|
204
204
|
it "returns the virtual_machines" do
|
@@ -214,7 +214,7 @@ describe Squall::User do
|
|
214
214
|
end
|
215
215
|
|
216
216
|
it "404s on not found" do
|
217
|
-
expect { @user.hypervisors(404) }.to raise_error(Squall::
|
217
|
+
expect { @user.hypervisors(404) }.to raise_error(Squall::NotFoundError)
|
218
218
|
end
|
219
219
|
|
220
220
|
it "returns the virtual_machines" do
|
@@ -231,7 +231,7 @@ describe Squall::User do
|
|
231
231
|
|
232
232
|
it "404s on not found" do
|
233
233
|
pending "Broken on OnApp: returns success despite non-existent user" do
|
234
|
-
expect { @user.data_store_zones(2532564353245) }.to raise_error(Squall::
|
234
|
+
expect { @user.data_store_zones(2532564353245) }.to raise_error(Squall::NotFoundError)
|
235
235
|
end
|
236
236
|
end
|
237
237
|
|
@@ -249,7 +249,7 @@ describe Squall::User do
|
|
249
249
|
|
250
250
|
it "404s on not found" do
|
251
251
|
pending "Broken on OnApp: returns success despite non-existent user" do
|
252
|
-
expect { @user.network_zones(2532564353245) }.to raise_error(Squall::
|
252
|
+
expect { @user.network_zones(2532564353245) }.to raise_error(Squall::NotFoundError)
|
253
253
|
end
|
254
254
|
end
|
255
255
|
|
@@ -266,7 +266,7 @@ describe Squall::User do
|
|
266
266
|
end
|
267
267
|
|
268
268
|
it "404s on not found" do
|
269
|
-
expect { @user.limits(438768534623) }.to raise_error(Squall::
|
269
|
+
expect { @user.limits(438768534623) }.to raise_error(Squall::NotFoundError)
|
270
270
|
end
|
271
271
|
|
272
272
|
it "returns the limits" do
|