mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
finished all token tests
This commit is contained in:
parent
2e08d22b4e
commit
7b4e45249d
3 changed files with 67 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue