2012-03-04 08:24:28 -05:00
|
|
|
module Fog
|
|
|
|
module Identity
|
|
|
|
class OpenStack
|
|
|
|
class Real
|
|
|
|
def add_user_to_tenant(tenant_id, user_id, role_id)
|
|
|
|
request(
|
|
|
|
:expects => 200,
|
|
|
|
:method => 'PUT',
|
|
|
|
:path => "/tenants/#{tenant_id}/users/#{user_id}/roles/OS-KSADM/#{role_id}"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end # class Real
|
|
|
|
|
|
|
|
class Mock
|
|
|
|
def add_user_to_tenant(tenant_id, user_id, role_id)
|
2012-12-06 01:42:25 -05:00
|
|
|
role = self.data[:roles][role_id]
|
|
|
|
self.data[:user_tenant_membership][tenant_id] ||= {}
|
|
|
|
self.data[:user_tenant_membership][tenant_id][user_id] ||= []
|
|
|
|
self.data[:user_tenant_membership][tenant_id][user_id].push(role['id']).uniq!
|
|
|
|
|
2012-03-04 08:24:28 -05:00
|
|
|
response = Excon::Response.new
|
|
|
|
response.status = 200
|
|
|
|
response.body = {
|
|
|
|
'role' => {
|
2012-12-06 01:42:25 -05:00
|
|
|
'id' => role['id'],
|
|
|
|
'name' => role['name']
|
2012-03-04 08:24:28 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
response
|
|
|
|
end # def add_user_to_tenant
|
|
|
|
end # class Mock
|
|
|
|
end # class OpenStack
|
|
|
|
end # module Identity
|
2012-03-04 08:24:28 -05:00
|
|
|
end
|