Browse Source

Fixed function grant_user_domain_role

- method is from top level class (not domain itself)
- fixed specs
Christoph Albers 2 years ago
parent
commit
d2b5bf7c37
2 changed files with 12 additions and 9 deletions
  1. 4
    2
      libraries/openstack_user.rb
  2. 8
    7
      spec/user_spec.rb

+ 4
- 2
libraries/openstack_user.rb View File

@@ -69,14 +69,16 @@ module OpenstackclientCookbook
69 69
       user = connection.users.find { |u| u.name == user_name }
70 70
       domain = connection.domains.find { |p| p.name == domain_name }
71 71
       role = connection.roles.find { |r| r.name == role_name }
72
-      domain.grant_domain_user_role user.id, role.id if role && domain && user
72
+      connection.grant_domain_user_role(
73
+        domain.id, user.id, role.id) if role && domain && user
73 74
     end
74 75
 
75 76
     action :revoke_domain do
76 77
       user = connection.users.find { |u| u.name == user_name }
77 78
       domain = connection.domains.find { |p| p.name == domain_name }
78 79
       role = connection.roles.find { |r| r.name == role_name }
79
-      domain.revoke_domain_user_role user.id, role.id if role && domain && user
80
+      connection.revoke_domain_user_role(
81
+        domain.id, user.id, role.id) if role && domain && user
80 82
     end
81 83
   end
82 84
 end

+ 8
- 7
spec/user_spec.rb View File

@@ -55,8 +55,7 @@ describe 'openstackclient_test::user' do
55 55
 
56 56
   let(:found_domain) do
57 57
     double :find,
58
-           grant_domain_user_role: true,
59
-           revoke_domain_user_role: true
58
+           id: 5
60 59
   end
61 60
 
62 61
   let(:domains_populated) do
@@ -151,7 +150,9 @@ describe 'openstackclient_test::user' do
151 150
              users: users_populated,
152 151
              domains: domains_populated,
153 152
              roles: roles_populated,
154
-             projects: projects_populated
153
+             projects: projects_populated,
154
+             grant_domain_user_role: true,
155
+             revoke_domain_user_role: true
155 156
     end
156 157
 
157 158
     before do
@@ -238,14 +239,14 @@ describe 'openstackclient_test::user' do
238 239
     end
239 240
 
240 241
     it do
241
-      expect(found_domain).to receive(:grant_domain_user_role)
242
-        .with(4, 3)
242
+      expect(connection_dub).to receive(:grant_domain_user_role)
243
+        .with(5, 4, 3)
243 244
       chef_run
244 245
     end
245 246
 
246 247
     it do
247
-      expect(found_domain).to receive(:revoke_domain_user_role)
248
-        .with(4, 3)
248
+      expect(connection_dub).to receive(:revoke_domain_user_role)
249
+        .with(5, 4, 3)
249 250
       chef_run
250 251
     end
251 252
   end

Loading…
Cancel
Save