1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[rackspace|lb] added error page requests

This commit is contained in:
Brian Hartsock 2011-12-15 16:53:06 -05:00
parent 9c3bf8edcc
commit 87778f5436
6 changed files with 91 additions and 0 deletions

View file

@ -62,6 +62,9 @@ module Fog
request :remove_monitor
request :get_usage
request :get_load_balancer_usage
request :get_error_page
request :set_error_page
request :remove_error_page
module Shared

View file

@ -0,0 +1,15 @@
module Fog
module Rackspace
class LoadBalancers
class Real
def get_error_page(load_balancer_id)
request(
:expects => 200,
:path => "loadbalancers/#{load_balancer_id}/errorpage",
:method => 'GET'
)
end
end
end
end
end

View file

@ -0,0 +1,15 @@
module Fog
module Rackspace
class LoadBalancers
class Real
def remove_error_page(load_balancer_id)
request(
:expects => [200, 202],
:path => "loadbalancers/#{load_balancer_id}/errorpage",
:method => 'DELETE'
)
end
end
end
end
end

View file

@ -0,0 +1,21 @@
module Fog
module Rackspace
class LoadBalancers
class Real
def set_error_page(load_balancer_id, content)
data = {
'errorpage' => {
'content' => content
}
}
request(
:body => MultiJson.encode(data),
:expects => [200, 202],
:path => "loadbalancers/#{load_balancer_id}/errorpage",
:method => 'PUT'
)
end
end
end
end
end

View file

@ -0,0 +1,31 @@
Shindo.tests('Fog::Rackspace::LoadBalancers | error_page', ['rackspace', 'loadbalancers']) do
pending if Fog.mocking?
given_a_load_balancer_service do
given_a_load_balancer do
tests('success') do
@lb.wait_for { ready? }
tests("#get_error_page(#{@lb.id})").formats(ERROR_PAGE_FORMAT) do
@service.get_error_page(@lb.id).body
end
@lb.wait_for { ready? }
tests("#set_error_page(#{@lb.id}, '<html><body>hi!</body></html>')").succeeds do
@service.set_error_page(@lb.id, '<html><body>hi!</body></html>')
end
@lb.wait_for { ready? }
tests("#get_error_page(#{@lb.id})").formats(ERROR_PAGE_FORMAT) do
@service.get_error_page(@lb.id).body
end
@lb.wait_for { ready? }
tests("#remove_error_page()").succeeds do
@service.remove_error_page(@lb.id)
end
end
end
end
end

View file

@ -131,3 +131,9 @@ LOAD_BALANCER_FORMAT = {
'updated' => { 'time' => String },
}.merge(CONNECTION_LOGGING_FORMAT)
}
ERROR_PAGE_FORMAT = {
'errorpage' => {
'content' => String
}
}