1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/openstack/requests/identity/get_user_by_id.rb
Nelvin Driz 92523f763a [openstack] Update mocks for login and identity request #get_user_by_id
Signed-off-by: Nelvin Driz <nelvindriz@live.com>
2012-04-30 10:35:01 +08:00

34 lines
784 B
Ruby

module Fog
module Identity
class OpenStack
class Real
def get_user_by_id(user_id)
request(
:expects => [200, 203],
:method => 'GET',
:path => "users/#{user_id}"
)
end
end
class Mock
def get_user_by_id(user_id)
response = Excon::Response.new
response.status = 200
existing_user = self.data[:users].find do |u|
u[0] == user_id || u[1]['name'] == 'mock'
end
existing_user = existing_user[1] if existing_user
response.body = {
'user' => existing_user || create_user('mock', 'mock', 'mock@email.com').body['user']
}
response
end
end
end
end
end