Skip to content

Commit

Permalink
[rackspace|lb] added error page requests
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhartsock committed Dec 15, 2011
1 parent 9c3bf8e commit 87778f5
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/fog/rackspace/load_balancers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class BadRequest < Fog::Rackspace::Errors::BadRequest; end
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

Expand Down
15 changes: 15 additions & 0 deletions lib/fog/rackspace/requests/load_balancers/get_error_page.rb
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions lib/fog/rackspace/requests/load_balancers/remove_error_page.rb
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions lib/fog/rackspace/requests/load_balancers/set_error_page.rb
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions tests/rackspace/requests/load_balancers/error_page_tests.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions tests/rackspace/requests/load_balancers/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,9 @@
'updated' => { 'time' => String },
}.merge(CONNECTION_LOGGING_FORMAT)
}

ERROR_PAGE_FORMAT = {
'errorpage' => {
'content' => String
}
}

0 comments on commit 87778f5

Please sign in to comment.