mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[openstack|identity] Update User Role Membership Mocks
Signed-off-by: Nelvin Driz <nelvindriz@live.com>
This commit is contained in:
parent
d7da8ef3d7
commit
c054fcb841
5 changed files with 17 additions and 5 deletions
|
@ -73,6 +73,7 @@ module Fog
|
|||
@roles ||= {}
|
||||
@tenants ||= {}
|
||||
@ec2_credentials ||= Hash.new { |hash, key| hash[key] = {} }
|
||||
@user_tenant_membership ||= {}
|
||||
|
||||
@data ||= Hash.new do |hash, key|
|
||||
hash[key] = {
|
||||
|
@ -80,6 +81,7 @@ module Fog
|
|||
:roles => @roles,
|
||||
:tenants => @tenants,
|
||||
:ec2_credentials => @ec2_credentials,
|
||||
:user_tenant_membership => @user_tenant_membership
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,12 +13,17 @@ module Fog
|
|||
|
||||
class Mock
|
||||
def add_user_to_tenant(tenant_id, user_id, role_id)
|
||||
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!
|
||||
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
response.body = {
|
||||
'role' => {
|
||||
'id' => '503df61a99d6461fb247cdb6a3f3a4dd',
|
||||
'name' => 'admin'
|
||||
'id' => role['id'],
|
||||
'name' => role['name']
|
||||
}
|
||||
}
|
||||
response
|
||||
|
|
|
@ -21,7 +21,7 @@ module Fog
|
|||
class Mock
|
||||
def create_role(name)
|
||||
data = {
|
||||
'id' => Fog::Mock.random_base64(64),
|
||||
'id' => Fog::Mock.random_hex(32),
|
||||
'name' => name
|
||||
}
|
||||
self.data[:roles][data['id']] = data
|
||||
|
|
|
@ -13,8 +13,14 @@ module Fog
|
|||
|
||||
class Mock
|
||||
def list_roles_for_user_on_tenant(tenant_id, user_id)
|
||||
self.data[:user_tenant_membership][tenant_id] ||= {}
|
||||
self.data[:user_tenant_membership][tenant_id][user_id] ||= []
|
||||
roles = self.data[:user_tenant_membership][tenant_id][user_id].map do |role_id|
|
||||
self.data[:roles][role_id]
|
||||
end
|
||||
|
||||
Excon::Response.new(
|
||||
:body => { 'roles' => self.data[:roles].values },
|
||||
:body => { 'roles' => roles },
|
||||
:status => 200
|
||||
)
|
||||
end # def list_roles_for_user_on_tenant
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
Shindo.tests('Fog::Identity[:openstack] | role requests', ['openstack']) do
|
||||
|
||||
@role_format = {
|
||||
'id' => String,
|
||||
'name' => String
|
||||
|
|
Loading…
Add table
Reference in a new issue