keycloak-admin 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +4 -2
  3. data/CHANGELOG.md +8 -0
  4. data/Gemfile.lock +17 -20
  5. data/README.md +9 -5
  6. data/keycloak-admin.gemspec +4 -3
  7. data/lib/keycloak-admin/client/attack_detection_client.rb +3 -3
  8. data/lib/keycloak-admin/client/client.rb +10 -6
  9. data/lib/keycloak-admin/client/client_authz_permission_client.rb +7 -7
  10. data/lib/keycloak-admin/client/client_authz_policy_client.rb +5 -5
  11. data/lib/keycloak-admin/client/client_authz_resource_client.rb +6 -6
  12. data/lib/keycloak-admin/client/client_authz_scope_client.rb +5 -5
  13. data/lib/keycloak-admin/client/client_client.rb +6 -6
  14. data/lib/keycloak-admin/client/client_role_client.rb +1 -1
  15. data/lib/keycloak-admin/client/client_role_mappings_client.rb +2 -2
  16. data/lib/keycloak-admin/client/client_scope_client.rb +5 -5
  17. data/lib/keycloak-admin/client/client_scope_protocol_mapper_client.rb +5 -5
  18. data/lib/keycloak-admin/client/configurable_token_client.rb +2 -2
  19. data/lib/keycloak-admin/client/group_client.rb +13 -13
  20. data/lib/keycloak-admin/client/identity_provider_client.rb +4 -4
  21. data/lib/keycloak-admin/client/organization_client.rb +18 -18
  22. data/lib/keycloak-admin/client/realm_client.rb +4 -4
  23. data/lib/keycloak-admin/client/role_client.rb +6 -6
  24. data/lib/keycloak-admin/client/role_mapper_client.rb +7 -7
  25. data/lib/keycloak-admin/client/token_client.rb +1 -3
  26. data/lib/keycloak-admin/client/user_client.rb +24 -24
  27. data/lib/keycloak-admin/configuration.rb +1 -1
  28. data/lib/keycloak-admin/version.rb +1 -1
  29. data/lib/keycloak-admin.rb +3 -1
  30. data/spec/client/attack_detection_client_spec.rb +3 -3
  31. data/spec/client/client_authz_permission_client_spec.rb +5 -5
  32. data/spec/client/client_authz_policy_client_spec.rb +5 -5
  33. data/spec/client/client_authz_resource_client_spec.rb +7 -7
  34. data/spec/client/client_authz_scope_client_spec.rb +5 -5
  35. data/spec/client/client_client_spec.rb +14 -14
  36. data/spec/client/client_role_mappings_client_spec.rb +10 -10
  37. data/spec/client/client_scope_client_spec.rb +7 -7
  38. data/spec/client/client_scope_protocol_mapper_client_spec.rb +7 -7
  39. data/spec/client/client_spec.rb +27 -7
  40. data/spec/client/group_client_spec.rb +47 -47
  41. data/spec/client/identity_provider_client_spec.rb +5 -5
  42. data/spec/client/organization_client_spec.rb +31 -31
  43. data/spec/client/realm_client_spec.rb +20 -20
  44. data/spec/client/role_client_spec.rb +10 -10
  45. data/spec/client/role_mapper_client_spec.rb +10 -10
  46. data/spec/client/token_client_spec.rb +5 -5
  47. data/spec/client/user_client_spec.rb +29 -29
  48. data/spec/configuration_spec.rb +2 -2
  49. data/spec/gemspec_spec.rb +25 -0
  50. data/spec/integration/client_authorization_spec.rb +4 -4
  51. data/spec/representation/client_authz_policy_representation_spec.rb +1 -1
  52. data/spec/spec_helper.rb +0 -8
  53. metadata +22 -7
@@ -29,7 +29,7 @@ RSpec.describe KeycloakAdmin::GroupClient do
29
29
  @group_client = KeycloakAdmin.realm(realm_name).groups
30
30
 
31
31
  stub_token_client
32
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return '{"id":"test_group_id","name":"test_group_name"}'
32
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return '{"id":"test_group_id","name":"test_group_name"}'
33
33
  end
34
34
 
35
35
  it "get a group" do
@@ -39,11 +39,11 @@ RSpec.describe KeycloakAdmin::GroupClient do
39
39
  end
40
40
 
41
41
  it "passes rest client options" do
42
- rest_client_options = {timeout: 10}
43
- allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
42
+ faraday_options = {timeout: 10}
43
+ allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
44
44
 
45
- expect(RestClient::Resource).to receive(:new).with(
46
- "http://auth.service.io/auth/admin/realms/valid-realm/groups/test_group_id", rest_client_options).and_call_original
45
+ expect(KeycloakAdmin::Resource).to receive(:new).with(
46
+ "http://auth.service.io/auth/admin/realms/valid-realm/groups/test_group_id", faraday_options).and_call_original
47
47
 
48
48
  group = @group_client.get("test_group_id")
49
49
  expect(group.id).to eq "test_group_id"
@@ -58,7 +58,7 @@ RSpec.describe KeycloakAdmin::GroupClient do
58
58
  @group_client = KeycloakAdmin.realm(realm_name).groups
59
59
 
60
60
  stub_token_client
61
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return '[{"id":"test_group_id","name":"test_group_name"}]'
61
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return '[{"id":"test_group_id","name":"test_group_name"}]'
62
62
  end
63
63
 
64
64
  it "lists groups" do
@@ -68,11 +68,11 @@ RSpec.describe KeycloakAdmin::GroupClient do
68
68
  end
69
69
 
70
70
  it "passes rest client options" do
71
- rest_client_options = {timeout: 10}
72
- allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
71
+ faraday_options = {timeout: 10}
72
+ allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
73
73
 
74
- expect(RestClient::Resource).to receive(:new).with(
75
- "http://auth.service.io/auth/admin/realms/valid-realm/groups", rest_client_options).and_call_original
74
+ expect(KeycloakAdmin::Resource).to receive(:new).with(
75
+ "http://auth.service.io/auth/admin/realms/valid-realm/groups", faraday_options).and_call_original
76
76
 
77
77
  groups = @group_client.list
78
78
  expect(groups.length).to eq 1
@@ -88,7 +88,7 @@ RSpec.describe KeycloakAdmin::GroupClient do
88
88
  @group_client = KeycloakAdmin.realm(realm_name).groups
89
89
 
90
90
  stub_token_client
91
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return '[{"id":"test_group_id","name":"test_group_name"}]'
91
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return '[{"id":"test_group_id","name":"test_group_name"}]'
92
92
  end
93
93
 
94
94
  it "lists children groups" do
@@ -98,11 +98,11 @@ RSpec.describe KeycloakAdmin::GroupClient do
98
98
  end
99
99
 
100
100
  it "passes rest client options" do
101
- rest_client_options = {timeout: 10}
102
- allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
101
+ faraday_options = {timeout: 10}
102
+ allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
103
103
 
104
- expect(RestClient::Resource).to receive(:new).with(
105
- "http://auth.service.io/auth/admin/realms/valid-realm/groups/parent_group_id/children", rest_client_options).and_call_original
104
+ expect(KeycloakAdmin::Resource).to receive(:new).with(
105
+ "http://auth.service.io/auth/admin/realms/valid-realm/groups/parent_group_id/children", faraday_options).and_call_original
106
106
 
107
107
  groups = @group_client.children("parent_group_id")
108
108
  expect(groups.length).to eq 1
@@ -130,7 +130,7 @@ RSpec.describe KeycloakAdmin::GroupClient do
130
130
  { location: 'http://auth.service.io/auth/admin/realms/valid-realm/groups/be061c48-6edd-4783-a726-1a57d4bfa22b' }
131
131
  )
132
132
 
133
- expect_any_instance_of(RestClient::Resource).to receive(:post).with(group.to_json, anything).and_return response
133
+ expect_any_instance_of(KeycloakAdmin::Resource).to receive(:post).with(group.to_json, anything).and_return response
134
134
  end
135
135
 
136
136
  it "saves a group" do
@@ -138,11 +138,11 @@ RSpec.describe KeycloakAdmin::GroupClient do
138
138
  end
139
139
 
140
140
  it "passes rest client options" do
141
- rest_client_options = {timeout: 10}
142
- allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
141
+ faraday_options = {timeout: 10}
142
+ allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
143
143
 
144
- expect(RestClient::Resource).to receive(:new).with(
145
- "http://auth.service.io/auth/admin/realms/valid-realm/groups", rest_client_options).and_call_original
144
+ expect(KeycloakAdmin::Resource).to receive(:new).with(
145
+ "http://auth.service.io/auth/admin/realms/valid-realm/groups", faraday_options).and_call_original
146
146
 
147
147
  @group_client.save(group)
148
148
  end
@@ -160,7 +160,7 @@ RSpec.describe KeycloakAdmin::GroupClient do
160
160
  { location: 'http://auth.service.io/auth/admin/realms/valid-realm/groups/be061c48-6edd-4783-a726-1a57d4bfa22b' }
161
161
  )
162
162
 
163
- expect_any_instance_of(RestClient::Resource).to receive(:put).with(group.to_json, anything).and_return response
163
+ expect_any_instance_of(KeycloakAdmin::Resource).to receive(:put).with(group.to_json, anything).and_return response
164
164
  end
165
165
 
166
166
  it "saves a group" do
@@ -168,11 +168,11 @@ RSpec.describe KeycloakAdmin::GroupClient do
168
168
  end
169
169
 
170
170
  it "passes rest client options" do
171
- rest_client_options = {timeout: 10}
172
- allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
171
+ faraday_options = {timeout: 10}
172
+ allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
173
173
 
174
- expect(RestClient::Resource).to receive(:new).with(
175
- "http://auth.service.io/auth/admin/realms/valid-realm/groups/test_group_id", rest_client_options).and_call_original
174
+ expect(KeycloakAdmin::Resource).to receive(:new).with(
175
+ "http://auth.service.io/auth/admin/realms/valid-realm/groups/test_group_id", faraday_options).and_call_original
176
176
 
177
177
  @group_client.save(group)
178
178
  end
@@ -186,22 +186,22 @@ RSpec.describe KeycloakAdmin::GroupClient do
186
186
  @group_client = KeycloakAdmin.realm(realm_name).groups
187
187
 
188
188
  stub_token_client
189
- @response = double
190
- allow(@response).to receive(:headers).and_return(
191
- { location: 'http://auth.service.io/auth/admin/realms/valid-realm/groups/be061c48-6edd-4783-a726-1a57d4bfa22b' }
189
+ @response = double(
190
+ headers: { location: 'http://auth.service.io/auth/admin/realms/valid-realm/groups/be061c48-6edd-4783-a726-1a57d4bfa22b' },
191
+ status: 201,
192
+ reason_phrase: 'Created'
192
193
  )
193
- allow_any_instance_of(RestClient::Resource).to receive(:post).and_return @response
194
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:post).and_return @response
194
195
  end
195
196
 
196
197
  it "creates a group" do
197
- stub_net_http_res(Net::HTTPCreated, 201, 'Created')
198
-
199
198
  group_id = @group_client.create!("test_group_name")
200
199
  expect(group_id).to eq 'be061c48-6edd-4783-a726-1a57d4bfa22b'
201
200
  end
202
201
 
203
202
  it "detects unexpected response to create a group" do
204
- stub_net_http_res(Net::HTTPOK, 200, 'OK')
203
+ allow(@response).to receive(:status).and_return 200
204
+ allow(@response).to receive(:reason_phrase).and_return 'OK'
205
205
 
206
206
  expect{ @group_client.create!("test_group_name") }.to raise_error(
207
207
  'Create method returned status OK (Code: 200); expected status: Created (201)'
@@ -216,15 +216,15 @@ RSpec.describe KeycloakAdmin::GroupClient do
216
216
  @group_client = KeycloakAdmin.realm(realm_name).groups
217
217
 
218
218
  stub_token_client
219
- @response = double headers: {
220
- location: 'http://auth.service.io/auth/admin/realms/valid-realm/groups/7686af34-204c-4515-8122-78d19febbf6e'
221
- }
222
- allow_any_instance_of(RestClient::Resource).to receive(:post).and_return @response
219
+ @response = double(
220
+ headers: { location: 'http://auth.service.io/auth/admin/realms/valid-realm/groups/7686af34-204c-4515-8122-78d19febbf6e' },
221
+ status: 201,
222
+ reason_phrase: 'Created'
223
+ )
224
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:post).and_return @response
223
225
  end
224
226
 
225
227
  it "creates a subgroup" do
226
- stub_net_http_res(Net::HTTPCreated, 201, 'Created')
227
-
228
228
  group_id = @group_client.create_subgroup!('be061c48-6edd-4783-a726-1a57d4bfa22b', 'subgroup-name')
229
229
  expect(group_id).to eq '7686af34-204c-4515-8122-78d19febbf6e'
230
230
  end
@@ -237,7 +237,7 @@ RSpec.describe KeycloakAdmin::GroupClient do
237
237
  @group_client = KeycloakAdmin.realm(realm_name).groups
238
238
 
239
239
  stub_token_client
240
- allow_any_instance_of(RestClient::Resource).to receive(:delete).and_return ''
240
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:delete).and_return ''
241
241
  end
242
242
 
243
243
  it "deletes a group" do
@@ -246,11 +246,11 @@ RSpec.describe KeycloakAdmin::GroupClient do
246
246
  end
247
247
 
248
248
  it "raises a delete error" do
249
- rest_client_options = {timeout: 10}
250
- allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
249
+ faraday_options = {timeout: 10}
250
+ allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
251
251
 
252
- expect(RestClient::Resource).to receive(:new).with(
253
- "http://auth.service.io/auth/admin/realms/valid-realm/groups/test_group_id", rest_client_options).and_raise("error")
252
+ expect(KeycloakAdmin::Resource).to receive(:new).with(
253
+ "http://auth.service.io/auth/admin/realms/valid-realm/groups/test_group_id", faraday_options).and_raise("error")
254
254
 
255
255
  expect { @group_client.delete("test_group_id") }.to raise_error("error")
256
256
  end
@@ -261,7 +261,7 @@ RSpec.describe KeycloakAdmin::GroupClient do
261
261
  before(:each) do
262
262
  @group_client = KeycloakAdmin.realm(realm_name).groups
263
263
  stub_token_client
264
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return '[{"id":"role-id","name":"role-name"}]'
264
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return '[{"id":"role-id","name":"role-name"}]'
265
265
  end
266
266
 
267
267
  it 'gets all realm-level roles for a group' do
@@ -279,7 +279,7 @@ RSpec.describe KeycloakAdmin::GroupClient do
279
279
  @group_client = KeycloakAdmin.realm(realm_name).groups
280
280
 
281
281
  stub_token_client
282
- allow_any_instance_of(RestClient::Resource).to receive(:post).and_return ''
282
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:post).and_return ''
283
283
  end
284
284
 
285
285
  it 'adds a realm-level role to a group' do
@@ -302,7 +302,7 @@ RSpec.describe KeycloakAdmin::GroupClient do
302
302
  @group_client = KeycloakAdmin.realm(realm_name).groups
303
303
 
304
304
  stub_token_client
305
- allow(RestClient::Request).to receive(:execute).and_return ''
305
+ allow(KeycloakAdmin::Resource).to receive(:execute).and_return ''
306
306
  end
307
307
 
308
308
  it 'deletes a realm-level role from a group' do
@@ -315,7 +315,7 @@ RSpec.describe KeycloakAdmin::GroupClient do
315
315
 
316
316
  result = @group_client.remove_realm_level_role_name!('test-group-id', 'test-role-name')
317
317
  expect(result).to be(true)
318
- expect(RestClient::Request).to have_received(:execute).with(
318
+ expect(KeycloakAdmin::Resource).to have_received(:execute).with(
319
319
  hash_including(
320
320
  url: "http://auth.service.io/auth/admin/realms/valid-realm/groups/test-group-id/role-mappings/realm",
321
321
  method: :delete,
@@ -68,7 +68,7 @@ RSpec.describe KeycloakAdmin::IdentityProviderClient do
68
68
  @identity_provider_client = KeycloakAdmin.realm(realm_name).identity_providers
69
69
 
70
70
  stub_token_client
71
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return json_response
71
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_response
72
72
  end
73
73
 
74
74
  it "lists identity providers" do
@@ -78,11 +78,11 @@ RSpec.describe KeycloakAdmin::IdentityProviderClient do
78
78
  end
79
79
 
80
80
  it "passes rest client options" do
81
- rest_client_options = {timeout: 10}
82
- allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
81
+ faraday_options = {timeout: 10}
82
+ allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
83
83
 
84
- expect(RestClient::Resource).to receive(:new).with(
85
- "http://auth.service.io/auth/admin/realms/valid-realm/identity-provider/instances", rest_client_options).and_call_original
84
+ expect(KeycloakAdmin::Resource).to receive(:new).with(
85
+ "http://auth.service.io/auth/admin/realms/valid-realm/identity-provider/instances", faraday_options).and_call_original
86
86
 
87
87
  identity_providers = @identity_provider_client.list
88
88
  expect(identity_providers.length).to eq 1
@@ -42,7 +42,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
42
42
  }
43
43
  ]
44
44
  payload
45
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return json_payload
45
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
46
46
  end
47
47
 
48
48
  it "lists organizations" do
@@ -53,11 +53,11 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
53
53
  end
54
54
 
55
55
  it "passes rest client options" do
56
- rest_client_options = {timeout: 10}
57
- allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
56
+ faraday_options = {timeout: 10}
57
+ allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
58
58
 
59
- expect(RestClient::Resource).to receive(:new).with(
60
- "http://auth.service.io/auth/admin/realms/valid-realm/organizations?briefRepresentation=true", rest_client_options).and_call_original
59
+ expect(KeycloakAdmin::Resource).to receive(:new).with(
60
+ "http://auth.service.io/auth/admin/realms/valid-realm/organizations?briefRepresentation=true", faraday_options).and_call_original
61
61
 
62
62
  organizations = @organization_client.list
63
63
  expect(organizations.length).to eq 1
@@ -74,7 +74,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
74
74
  @organization_client = KeycloakAdmin.realm(realm_name).organizations
75
75
  stub_token_client
76
76
  json_payload = "2"
77
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return json_payload
77
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
78
78
  end
79
79
 
80
80
  it "count organizations" do
@@ -163,7 +163,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
163
163
  }
164
164
  ]
165
165
  payload
166
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return json_payload
166
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
167
167
  end
168
168
 
169
169
  it "list organizations of members organizations" do
@@ -180,7 +180,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
180
180
  before(:each) do
181
181
  @organization_client = KeycloakAdmin.realm(realm_name).organizations
182
182
  stub_token_client
183
- allow_any_instance_of(RestClient::Resource).to receive(:delete).and_return ""
183
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:delete).and_return ""
184
184
  end
185
185
 
186
186
  it "deletes an organization" do
@@ -189,11 +189,11 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
189
189
  end
190
190
 
191
191
  it "raises a delete error" do
192
- rest_client_options = {timeout: 10}
193
- allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
192
+ faraday_options = {timeout: 10}
193
+ allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
194
194
 
195
- expect(RestClient::Resource).to receive(:new).with(
196
- "http://auth.service.io/auth/admin/realms/valid-realm/organizations/2904e1a1-e5f4-4143-8725-003e54cc8b58", rest_client_options).and_raise("error")
195
+ expect(KeycloakAdmin::Resource).to receive(:new).with(
196
+ "http://auth.service.io/auth/admin/realms/valid-realm/organizations/2904e1a1-e5f4-4143-8725-003e54cc8b58", faraday_options).and_raise("error")
197
197
 
198
198
  expect { @organization_client.delete("2904e1a1-e5f4-4143-8725-003e54cc8b58") }.to raise_error("error")
199
199
  end
@@ -230,7 +230,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
230
230
  }
231
231
  ]
232
232
  payload
233
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return json_payload
233
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
234
234
  end
235
235
 
236
236
  it "get identity providers" do
@@ -248,7 +248,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
248
248
  before(:each) do
249
249
  @organization_client = KeycloakAdmin.realm(realm_name).organizations
250
250
  stub_token_client
251
- allow_any_instance_of(RestClient::Resource).to receive(:post).and_return ""
251
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:post).and_return ""
252
252
  end
253
253
 
254
254
  it "adds one identity provider" do
@@ -285,7 +285,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
285
285
  }
286
286
  payload
287
287
  stub_token_client
288
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return json_payload
288
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
289
289
  end
290
290
 
291
291
  it "get identity provider" do
@@ -320,7 +320,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
320
320
  ]
321
321
  }
322
322
  payload
323
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return json_payload
323
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
324
324
  end
325
325
 
326
326
  it "get organization" do
@@ -332,11 +332,11 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
332
332
  end
333
333
 
334
334
  it "passes rest client options" do
335
- rest_client_options = {timeout: 10}
336
- allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
335
+ faraday_options = {timeout: 10}
336
+ allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
337
337
 
338
- expect(RestClient::Resource).to receive(:new).with(
339
- "http://auth.service.io/auth/admin/realms/valid-realm/organizations/8f6e474e-e688-4bec-99ba-5dc862594f4b", rest_client_options).and_call_original
338
+ expect(KeycloakAdmin::Resource).to receive(:new).with(
339
+ "http://auth.service.io/auth/admin/realms/valid-realm/organizations/8f6e474e-e688-4bec-99ba-5dc862594f4b", faraday_options).and_call_original
340
340
 
341
341
  organization = @organization_client.get("8f6e474e-e688-4bec-99ba-5dc862594f4b")
342
342
  expect(organization).to be
@@ -351,7 +351,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
351
351
  before(:each) do
352
352
  @organization_client = KeycloakAdmin.realm(realm_name).organizations
353
353
  stub_token_client
354
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return "2"
354
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return "2"
355
355
  end
356
356
 
357
357
  it "get count of members" do
@@ -399,7 +399,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
399
399
  ]
400
400
  payload
401
401
  stub_token_client
402
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return json_payload
402
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
403
403
  end
404
404
 
405
405
  it "get members" do
@@ -420,7 +420,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
420
420
  before(:each) do
421
421
  @organization_client = KeycloakAdmin.realm(realm_name).organizations
422
422
  stub_token_client
423
- allow_any_instance_of(RestClient::Resource).to receive(:post).and_return ""
423
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:post).and_return ""
424
424
  end
425
425
 
426
426
  it "invites an existing user" do
@@ -434,7 +434,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
434
434
  before(:each) do
435
435
  @organization_client = KeycloakAdmin.realm(realm_name).organizations
436
436
  stub_token_client
437
- allow_any_instance_of(RestClient::Resource).to receive(:post).and_return ""
437
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:post).and_return ""
438
438
  end
439
439
 
440
440
  it "invites an existing user" do
@@ -448,7 +448,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
448
448
  before(:each) do
449
449
  @organization_client = KeycloakAdmin.realm(realm_name).organizations
450
450
  stub_token_client
451
- allow_any_instance_of(RestClient::Resource).to receive(:delete).and_return ""
451
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:delete).and_return ""
452
452
  end
453
453
 
454
454
  it "deletes a member" do
@@ -478,7 +478,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
478
478
  }
479
479
  payload
480
480
  stub_token_client
481
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return json_payload
481
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
482
482
  end
483
483
 
484
484
  it "gets a member" do
@@ -496,7 +496,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
496
496
  before(:each) do
497
497
  @organization_client = KeycloakAdmin.realm(realm_name).organizations
498
498
  stub_token_client
499
- allow_any_instance_of(RestClient::Resource).to receive(:post).and_return ""
499
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:post).and_return ""
500
500
  end
501
501
 
502
502
  it "creates a member from an existing user" do
@@ -511,7 +511,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
511
511
  before(:each) do
512
512
  @organization_client = KeycloakAdmin.realm(realm_name).organizations
513
513
  stub_token_client
514
- allow_any_instance_of(RestClient::Resource).to receive(:post).and_return ""
514
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:post).and_return ""
515
515
  end
516
516
 
517
517
  it "creates a member from an existing user" do
@@ -553,8 +553,8 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
553
553
  before(:each) do
554
554
  @organization_client = KeycloakAdmin.realm(realm_name).organizations
555
555
  stub_token_client
556
- allow_any_instance_of(RestClient::Resource).to receive(:put).and_return ""
557
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return json_payload
556
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:put).and_return ""
557
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
558
558
  end
559
559
 
560
560
  it "updates an organization" do
@@ -571,7 +571,7 @@ RSpec.describe KeycloakAdmin::OrganizationClient do
571
571
  before(:each) do
572
572
  @organization_client = KeycloakAdmin.realm(realm_name).organizations
573
573
  stub_token_client
574
- allow_any_instance_of(RestClient::Resource).to receive(:post).and_return ""
574
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:post).and_return ""
575
575
  end
576
576
 
577
577
  it "creates an organization" do
@@ -50,7 +50,7 @@ RSpec.describe KeycloakAdmin::RealmClient do
50
50
  @realm_client = KeycloakAdmin.realm('master')
51
51
 
52
52
  stub_token_client
53
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return '[{"id":"test_realm","realm":"test_realm"}]'
53
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return '[{"id":"test_realm","realm":"test_realm"}]'
54
54
  end
55
55
 
56
56
  it "lists realms" do
@@ -60,11 +60,11 @@ RSpec.describe KeycloakAdmin::RealmClient do
60
60
  end
61
61
 
62
62
  it "passes rest client options" do
63
- rest_client_options = {timeout: 10}
64
- allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
63
+ faraday_options = {timeout: 10}
64
+ allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
65
65
 
66
- expect(RestClient::Resource).to receive(:new).with(
67
- "http://auth.service.io/auth/admin/realms", rest_client_options).and_call_original
66
+ expect(KeycloakAdmin::Resource).to receive(:new).with(
67
+ "http://auth.service.io/auth/admin/realms", faraday_options).and_call_original
68
68
 
69
69
  realms = @realm_client.list
70
70
  expect(realms.length).to eq 1
@@ -79,7 +79,7 @@ RSpec.describe KeycloakAdmin::RealmClient do
79
79
  @realm_client = KeycloakAdmin.realm(realm_name)
80
80
 
81
81
  stub_token_client
82
- allow_any_instance_of(RestClient::Resource).to receive(:delete)
82
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:delete)
83
83
  end
84
84
 
85
85
  it "delete realm" do
@@ -87,11 +87,11 @@ RSpec.describe KeycloakAdmin::RealmClient do
87
87
  end
88
88
 
89
89
  it "passes rest client options" do
90
- rest_client_options = {timeout: 10}
91
- allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
90
+ faraday_options = {timeout: 10}
91
+ allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
92
92
 
93
- expect(RestClient::Resource).to receive(:new).with(
94
- "http://auth.service.io/auth/admin/realms/valid-realm", rest_client_options).and_call_original
93
+ expect(KeycloakAdmin::Resource).to receive(:new).with(
94
+ "http://auth.service.io/auth/admin/realms/valid-realm", faraday_options).and_call_original
95
95
 
96
96
  expect(@realm_client.delete).to be_truthy
97
97
  end
@@ -109,7 +109,7 @@ RSpec.describe KeycloakAdmin::RealmClient do
109
109
 
110
110
  stub_token_client
111
111
 
112
- expect_any_instance_of(RestClient::Resource).to receive(:post).with(realm.to_json, anything)
112
+ expect_any_instance_of(KeycloakAdmin::Resource).to receive(:post).with(realm.to_json, anything)
113
113
  end
114
114
 
115
115
  it "saves a realm" do
@@ -117,11 +117,11 @@ RSpec.describe KeycloakAdmin::RealmClient do
117
117
  end
118
118
 
119
119
  it "passes rest client options" do
120
- rest_client_options = {timeout: 10}
121
- allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
120
+ faraday_options = {timeout: 10}
121
+ allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
122
122
 
123
- expect(RestClient::Resource).to receive(:new).with(
124
- "http://auth.service.io/auth/admin/realms", rest_client_options).and_call_original
123
+ expect(KeycloakAdmin::Resource).to receive(:new).with(
124
+ "http://auth.service.io/auth/admin/realms", faraday_options).and_call_original
125
125
 
126
126
  @realm_client.save(realm)
127
127
  end
@@ -135,7 +135,7 @@ RSpec.describe KeycloakAdmin::RealmClient do
135
135
  @realm_client = KeycloakAdmin.realm(realm_name)
136
136
 
137
137
  stub_token_client
138
- expect_any_instance_of(RestClient::Resource).to receive(:put).with(realm_json.to_json, anything)
138
+ expect_any_instance_of(KeycloakAdmin::Resource).to receive(:put).with(realm_json.to_json, anything)
139
139
  end
140
140
 
141
141
  it "updates a realm" do
@@ -143,11 +143,11 @@ RSpec.describe KeycloakAdmin::RealmClient do
143
143
  end
144
144
 
145
145
  it "passes rest client options" do
146
- rest_client_options = {timeout: 10}
147
- allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
146
+ faraday_options = {timeout: 10}
147
+ allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
148
148
 
149
- expect(RestClient::Resource).to receive(:new).with(
150
- "http://auth.service.io/auth/admin/realms/valid-realm", rest_client_options).and_call_original
149
+ expect(KeycloakAdmin::Resource).to receive(:new).with(
150
+ "http://auth.service.io/auth/admin/realms/valid-realm", faraday_options).and_call_original
151
151
 
152
152
  @realm_client.update(realm_json)
153
153
  end
@@ -25,7 +25,7 @@ RSpec.describe KeycloakAdmin::RoleClient do
25
25
  @role_client = KeycloakAdmin.realm(realm_name).roles
26
26
 
27
27
  stub_token_client
28
- allow_any_instance_of(RestClient::Resource).to receive(:get).and_return '[{"id":"test_role_id","name":"test_role_name"}]'
28
+ allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return '[{"id":"test_role_id","name":"test_role_name"}]'
29
29
  end
30
30
 
31
31
  it "lists roles" do
@@ -35,11 +35,11 @@ RSpec.describe KeycloakAdmin::RoleClient do
35
35
  end
36
36
 
37
37
  it "passes rest client options" do
38
- rest_client_options = {timeout: 10}
39
- allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
38
+ faraday_options = {timeout: 10}
39
+ allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
40
40
 
41
- expect(RestClient::Resource).to receive(:new).with(
42
- "http://auth.service.io/auth/admin/realms/valid-realm/roles", rest_client_options).and_call_original
41
+ expect(KeycloakAdmin::Resource).to receive(:new).with(
42
+ "http://auth.service.io/auth/admin/realms/valid-realm/roles", faraday_options).and_call_original
43
43
 
44
44
  roles = @role_client.list
45
45
  expect(roles.length).to eq 1
@@ -59,7 +59,7 @@ RSpec.describe KeycloakAdmin::RoleClient do
59
59
  @role_client = KeycloakAdmin.realm(realm_name).roles
60
60
 
61
61
  stub_token_client
62
- expect_any_instance_of(RestClient::Resource).to receive(:post).with(role.to_json, anything)
62
+ expect_any_instance_of(KeycloakAdmin::Resource).to receive(:post).with(role.to_json, anything)
63
63
  end
64
64
 
65
65
  it "saves a role" do
@@ -67,11 +67,11 @@ RSpec.describe KeycloakAdmin::RoleClient do
67
67
  end
68
68
 
69
69
  it "passes rest client options" do
70
- rest_client_options = {timeout: 10}
71
- allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
70
+ faraday_options = {timeout: 10}
71
+ allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
72
72
 
73
- expect(RestClient::Resource).to receive(:new).with(
74
- "http://auth.service.io/auth/admin/realms/valid-realm/roles", rest_client_options).and_call_original
73
+ expect(KeycloakAdmin::Resource).to receive(:new).with(
74
+ "http://auth.service.io/auth/admin/realms/valid-realm/roles", faraday_options).and_call_original
75
75
 
76
76
  @role_client.save(role)
77
77
  end