diff --git a/lib/fog/rackspace/requests/monitoring/get_agent_token.rb b/lib/fog/rackspace/requests/monitoring/get_agent_token.rb index eba4f6e47..47f8dbf52 100644 --- a/lib/fog/rackspace/requests/monitoring/get_agent_token.rb +++ b/lib/fog/rackspace/requests/monitoring/get_agent_token.rb @@ -10,8 +10,39 @@ module Fog :path => "agent_tokens/#{id}" ) end - end + + class Mock + def get_agent_token(id) + + if id == -1 + raise TypeError + end + + response = Excon::Response.new + response.status = 200 + response.body = { + "id" => "7e261310b36834a9969e389c8e90adc08629c00d4c74aaea5e42599cc07ba80d.55555", + "token" => "7e261310b36834a9969e389c8e90adc08629c00d4c74aaea5e42599cc07ba80d.55555", + "label" => "mock_token" + } + response.headers = { + "Date" => Time.now.utc.to_s, + "Content-Type" => "application/json; charset=UTF-8", + "X-RateLimit-Limit" => "50000", + "X-RateLimit-Remaining" => "47903", + "X-RateLimit-Window" => "24 hours", + "X-RateLimit-Type" => "global", + "X-Response-Id" => ".rh-lHJL.h-ord1-maas-prod-api1.r-5YqHhQwV.c-6259794.ts-1377798031450.v-e602877", + "X-LB" => "ord1-maas-prod-api0", + "Vary" => "Accept-Encoding", + "Transfer-Encoding" => "chunked" + } + response.remote_ip = "1.1.1.1" + response + end + end + end end end diff --git a/lib/fog/rackspace/requests/monitoring/list_agent_tokens.rb b/lib/fog/rackspace/requests/monitoring/list_agent_tokens.rb index d74045168..4226e1080 100644 --- a/lib/fog/rackspace/requests/monitoring/list_agent_tokens.rb +++ b/lib/fog/rackspace/requests/monitoring/list_agent_tokens.rb @@ -11,7 +11,42 @@ module Fog :query => options ) end + end + class Mock + def list_agent_tokens(options={}) + response = Excon::Response.new + response.status = 200 + response.body = { + "values"=> [ + { + "id" => "7e261310b36834a9969e389c8e90adc08629c00d4c74aaea5e42599cc07ba80d.55555", + "token" => "7e261310b36834a9969e389c8e90adc08629c00d4c74aaea5e42599cc07ba80d.55555", + "label" => "mock_token" + } + ], + "metadata" => { + "count" => 1, + "limit" => 100, + "marker" => nil, + "next_marker" => nil, + "next_href" => nil + } + } + response.headers = { + "Date" => Time.now.utc.to_s, + "Content-Type" => "application/json; charset=UTF-8", + "X-RateLimit-Limit" => "50000", + "X-RateLimit-Remaining" => "49627", + "X-RateLimit-Window" => "24 hours", + "X-RateLimit-Type" => "global", + "X-Response-Id" =>" j23jlk234jl2j34j", + "X-LB" => "dfw1-maas-prod-api0", + "Vary" => "Accept-Encoding", + "Transfer-Encoding" => "chunked" + } + response + end end end end diff --git a/tests/rackspace/requests/monitoring/agent_tests.rb b/tests/rackspace/requests/monitoring/agent_tests.rb index cd9123f06..51ddf96f3 100644 --- a/tests/rackspace/requests/monitoring/agent_tests.rb +++ b/tests/rackspace/requests/monitoring/agent_tests.rb @@ -10,11 +10,9 @@ Shindo.tests('Fog::Rackspace::Monitoring | agent_tests', ['rackspace','rackspace response end tests('#list agent tokens').formats(LIST_HEADERS_FORMAT) do - pending if Fog.mocking? account.list_agent_tokens().data[:headers] end tests('#get agent token').formats(LIST_HEADERS_FORMAT) do - pending if Fog.mocking? account.get_agent_token(agent_token).data[:headers] end tests('#delete agent token').formats(DELETE_HEADERS_FORMAT) do @@ -26,7 +24,6 @@ Shindo.tests('Fog::Rackspace::Monitoring | agent_tests', ['rackspace','rackspace account.create_agent_token(-1) end tests('#fail to get agent token(-1)').raises(TypeError) do - pending if Fog.mocking? account.create_agent_token(-1) end tests('#fail to delete agent token(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do