diff --git a/lib/fog/rackspace/requests/monitoring/create_check.rb b/lib/fog/rackspace/requests/monitoring/create_check.rb index 124eb7a72..58725d427 100644 --- a/lib/fog/rackspace/requests/monitoring/create_check.rb +++ b/lib/fog/rackspace/requests/monitoring/create_check.rb @@ -13,6 +13,34 @@ module Fog ) end end + + class Mock + def create_check(entity_id, options = {}) + + if options[:type] == "" + raise Fog::Rackspace::Monitoring::BadRequest + end + + response = Excon::Response.new + response.status = 201 + response.body = "" + response.headers = { + "Date" => Time.now.utc.to_s, + "Location" => "https://monitoring.api.rackspacecloud.com/v1.0/55555/" + entity_id + "/checks/mock_id", + "X-Object-ID" => "mock_id", + "X-RateLimit-Limit" => "50000", + "X-RateLimit-Remaining" => "49627", + "X-RateLimit-Window" => "24 hours", + "X-RateLimit-Type" => "global", + "X-Response-Id" => ".rh-lHJL.h-ord1-maas-prod-api1.r-AGRIH406.c-4085336.ts-1377785008661.v-e602877", + "X-LB" => "ord1-maas-prod-api1", + "Content-Length" => "0", + "Content-Type" => "text/plain", + } + response.remote_ip = "1.1.1.1" + response + end + end end end end diff --git a/lib/fog/rackspace/requests/monitoring/delete_check.rb b/lib/fog/rackspace/requests/monitoring/delete_check.rb index 2d0db6c7b..ffe4d97d0 100644 --- a/lib/fog/rackspace/requests/monitoring/delete_check.rb +++ b/lib/fog/rackspace/requests/monitoring/delete_check.rb @@ -11,6 +11,32 @@ module Fog ) end end + + class Mock + def delete_check(entity_id, check_id) + + if entity_id == -1 || check_id == -1 + raise Fog::Rackspace::Monitoring::NotFound + end + + response = Excon::Response.new + response.status = 204 + response.body = "" + response.headers = { + "Date" => Time.now.utc.to_s, + "X-RateLimit-Limit" => "50000", + "X-RateLimit-Remaining" => "49627", + "X-RateLimit-Window" => "24 hours", + "X-RateLimit-Type" => "global", + "X-Response-Id" => ".rh-lHJL.h-ord1-maas-prod-api1.r-AGRIH406.c-4085336.ts-1377785008661.v-e602877", + "X-LB" => "ord1-maas-prod-api1", + "Content-Length" => "0", + "Content-Type" => "text/plain", + } + response.remote_ip = "1.1.1.1" + response + end + end end end end diff --git a/lib/fog/rackspace/requests/monitoring/get_check.rb b/lib/fog/rackspace/requests/monitoring/get_check.rb index b34e93f33..020788bc3 100644 --- a/lib/fog/rackspace/requests/monitoring/get_check.rb +++ b/lib/fog/rackspace/requests/monitoring/get_check.rb @@ -10,7 +10,48 @@ module Fog :path => "entities/#{entity_id}/checks/#{check_id}" ) end + end + class Mock + def get_check(entity_id, check_id) + + if entity_id == -1 || check_id == -1 + raise Fog::Rackspace::Monitoring::NotFound + end + + response = Excon::Response.new + response.status = 200 + response.body = { + "id" => "mock_id", + "label" => nil, + "type" => "remote.ping", + "details" => {"count"=>5}, + "monitoring_zones_poll" => ["mzord", "mzdfw", "mziad"], + "timeout" => 10, + "period" => 30, + "target_alias" => nil, + "target_hostname" => "1.1.1.1", + "target_resolver" => "IPv4", + "disabled" => false, + "metadata" => nil, + "created_at" => Time.now.to_i - 1, + "updated_at" => Time.now.to_i + }, + response.headers = { + "Date" => Time.now.utc.to_s, + "Content-Type" => "application/json; charset=UTF-8", + "X-RateLimit-Limit" => "50000", + "X-RateLimit-Remaining" => "44676", + "X-RateLimit-Window" => "24 hours", + "X-RateLimit-Type" => "global", + "X-Response-Id" => ".rh-QScV.h-ord1-maas-prod-api0.r-uuWnOhLS.c-206541.ts-1377805994157.v-9c40430", + "X-LB" => "ord1-maas-prod-api0", + "Vary" => "Accept-Encoding", + "Transfer-Encoding" => "chunked" + } + + response + end end end end diff --git a/lib/fog/rackspace/requests/monitoring/update_check.rb b/lib/fog/rackspace/requests/monitoring/update_check.rb index 8f0867d93..f2a2fd20b 100644 --- a/lib/fog/rackspace/requests/monitoring/update_check.rb +++ b/lib/fog/rackspace/requests/monitoring/update_check.rb @@ -12,6 +12,34 @@ module Fog ) end end + + class Mock + def update_check(entity_id, id, options) + + if options[:testing] == "Bar" + raise Fog::Rackspace::Monitoring::NotFound + end + + response = Excon::Response.new + response.status = 204 + response.body = "" + response.headers = { + "Date" => Time.now.utc.to_s, + "Location" => "https://monitoring.api.rackspacecloud.com/v1.0/55555/entities/" + entity_id + "/checks/mock_id", + "X-Object-ID" => "mock_id", + "X-RateLimit-Limit" => "50000", + "X-RateLimit-Remaining" => "49627", + "X-RateLimit-Window" => "24 hours", + "X-RateLimit-Type" => "global", + "X-Response-Id" => ".rh-lHJL.h-ord1-maas-prod-api1.r-AGRIH406.c-4085336.ts-1377785008661.v-e602877", + "X-LB" => "ord1-maas-prod-api1", + "Content-Length" => "0", + "Content-Type" => "text/plain", + } + response.remote_ip = "1.1.1.1" + response + end + end end end end diff --git a/tests/rackspace/requests/monitoring/check_tests.rb b/tests/rackspace/requests/monitoring/check_tests.rb index 1f6c469ad..a200c8bb8 100644 --- a/tests/rackspace/requests/monitoring/check_tests.rb +++ b/tests/rackspace/requests/monitoring/check_tests.rb @@ -1,5 +1,4 @@ Shindo.tests('Fog::Rackspace::Monitoring | check_tests', ['rackspace', 'rackspace_monitoring']) do - pending if Fog.mocking? account = Fog::Rackspace::Monitoring.new entity_id = account.create_entity(:label => "Foo").data[:headers]["X-Object-ID"]