2012-02-17 04:29:44 -05:00
|
|
|
module Fog
|
|
|
|
module Identity
|
2012-02-22 01:46:56 -05:00
|
|
|
class OpenStack
|
2012-02-17 04:29:44 -05:00
|
|
|
class Real
|
|
|
|
|
|
|
|
def get_user_by_id(user_id)
|
|
|
|
request(
|
|
|
|
:expects => [200, 203],
|
|
|
|
:method => 'GET',
|
|
|
|
:path => "users/#{user_id}"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
class Mock
|
2012-03-19 01:52:58 -04:00
|
|
|
def get_user_by_id(user_id)
|
|
|
|
response = Excon::Response.new
|
|
|
|
response.status = 200
|
2012-02-17 04:29:44 -05:00
|
|
|
|
2012-03-19 01:52:58 -04:00
|
|
|
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
|
2012-02-17 04:29:44 -05:00
|
|
|
|
2012-03-19 01:52:58 -04:00
|
|
|
response.body = {
|
|
|
|
'user' => existing_user || create_user('mock', 'mock', 'mock@email.com').body['user']
|
|
|
|
}
|
|
|
|
response
|
|
|
|
end
|
2012-02-17 04:29:44 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|