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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +4 -2
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +17 -20
- data/README.md +9 -5
- data/keycloak-admin.gemspec +4 -3
- data/lib/keycloak-admin/client/attack_detection_client.rb +3 -3
- data/lib/keycloak-admin/client/client.rb +10 -6
- data/lib/keycloak-admin/client/client_authz_permission_client.rb +7 -7
- data/lib/keycloak-admin/client/client_authz_policy_client.rb +5 -5
- data/lib/keycloak-admin/client/client_authz_resource_client.rb +6 -6
- data/lib/keycloak-admin/client/client_authz_scope_client.rb +5 -5
- data/lib/keycloak-admin/client/client_client.rb +6 -6
- data/lib/keycloak-admin/client/client_role_client.rb +1 -1
- data/lib/keycloak-admin/client/client_role_mappings_client.rb +2 -2
- data/lib/keycloak-admin/client/client_scope_client.rb +5 -5
- data/lib/keycloak-admin/client/client_scope_protocol_mapper_client.rb +5 -5
- data/lib/keycloak-admin/client/configurable_token_client.rb +2 -2
- data/lib/keycloak-admin/client/group_client.rb +13 -13
- data/lib/keycloak-admin/client/identity_provider_client.rb +4 -4
- data/lib/keycloak-admin/client/organization_client.rb +18 -18
- data/lib/keycloak-admin/client/realm_client.rb +4 -4
- data/lib/keycloak-admin/client/role_client.rb +6 -6
- data/lib/keycloak-admin/client/role_mapper_client.rb +7 -7
- data/lib/keycloak-admin/client/token_client.rb +1 -3
- data/lib/keycloak-admin/client/user_client.rb +24 -24
- data/lib/keycloak-admin/configuration.rb +1 -1
- data/lib/keycloak-admin/version.rb +1 -1
- data/lib/keycloak-admin.rb +3 -1
- data/spec/client/attack_detection_client_spec.rb +3 -3
- data/spec/client/client_authz_permission_client_spec.rb +5 -5
- data/spec/client/client_authz_policy_client_spec.rb +5 -5
- data/spec/client/client_authz_resource_client_spec.rb +7 -7
- data/spec/client/client_authz_scope_client_spec.rb +5 -5
- data/spec/client/client_client_spec.rb +14 -14
- data/spec/client/client_role_mappings_client_spec.rb +10 -10
- data/spec/client/client_scope_client_spec.rb +7 -7
- data/spec/client/client_scope_protocol_mapper_client_spec.rb +7 -7
- data/spec/client/client_spec.rb +27 -7
- data/spec/client/group_client_spec.rb +47 -47
- data/spec/client/identity_provider_client_spec.rb +5 -5
- data/spec/client/organization_client_spec.rb +31 -31
- data/spec/client/realm_client_spec.rb +20 -20
- data/spec/client/role_client_spec.rb +10 -10
- data/spec/client/role_mapper_client_spec.rb +10 -10
- data/spec/client/token_client_spec.rb +5 -5
- data/spec/client/user_client_spec.rb +29 -29
- data/spec/configuration_spec.rb +2 -2
- data/spec/gemspec_spec.rb +25 -0
- data/spec/integration/client_authorization_spec.rb +4 -4
- data/spec/representation/client_authz_policy_representation_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -8
- 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(
|
|
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
|
-
|
|
43
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:
|
|
42
|
+
faraday_options = {timeout: 10}
|
|
43
|
+
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
44
44
|
|
|
45
|
-
expect(
|
|
46
|
-
"http://auth.service.io/auth/admin/realms/valid-realm/groups/test_group_id",
|
|
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(
|
|
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
|
-
|
|
72
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:
|
|
71
|
+
faraday_options = {timeout: 10}
|
|
72
|
+
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
73
73
|
|
|
74
|
-
expect(
|
|
75
|
-
"http://auth.service.io/auth/admin/realms/valid-realm/groups",
|
|
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(
|
|
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
|
-
|
|
102
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:
|
|
101
|
+
faraday_options = {timeout: 10}
|
|
102
|
+
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
103
103
|
|
|
104
|
-
expect(
|
|
105
|
-
"http://auth.service.io/auth/admin/realms/valid-realm/groups/parent_group_id/children",
|
|
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(
|
|
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
|
-
|
|
142
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:
|
|
141
|
+
faraday_options = {timeout: 10}
|
|
142
|
+
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
143
143
|
|
|
144
|
-
expect(
|
|
145
|
-
"http://auth.service.io/auth/admin/realms/valid-realm/groups",
|
|
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(
|
|
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
|
-
|
|
172
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:
|
|
171
|
+
faraday_options = {timeout: 10}
|
|
172
|
+
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
173
173
|
|
|
174
|
-
expect(
|
|
175
|
-
"http://auth.service.io/auth/admin/realms/valid-realm/groups/test_group_id",
|
|
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
|
-
|
|
191
|
-
|
|
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(
|
|
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
|
-
|
|
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
|
|
220
|
-
location: 'http://auth.service.io/auth/admin/realms/valid-realm/groups/7686af34-204c-4515-8122-78d19febbf6e'
|
|
221
|
-
|
|
222
|
-
|
|
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(
|
|
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
|
-
|
|
250
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:
|
|
249
|
+
faraday_options = {timeout: 10}
|
|
250
|
+
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
251
251
|
|
|
252
|
-
expect(
|
|
253
|
-
"http://auth.service.io/auth/admin/realms/valid-realm/groups/test_group_id",
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
82
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:
|
|
81
|
+
faraday_options = {timeout: 10}
|
|
82
|
+
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
83
83
|
|
|
84
|
-
expect(
|
|
85
|
-
"http://auth.service.io/auth/admin/realms/valid-realm/identity-provider/instances",
|
|
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(
|
|
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
|
-
|
|
57
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:
|
|
56
|
+
faraday_options = {timeout: 10}
|
|
57
|
+
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
58
58
|
|
|
59
|
-
expect(
|
|
60
|
-
"http://auth.service.io/auth/admin/realms/valid-realm/organizations?briefRepresentation=true",
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
193
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:
|
|
192
|
+
faraday_options = {timeout: 10}
|
|
193
|
+
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
194
194
|
|
|
195
|
-
expect(
|
|
196
|
-
"http://auth.service.io/auth/admin/realms/valid-realm/organizations/2904e1a1-e5f4-4143-8725-003e54cc8b58",
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
336
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:
|
|
335
|
+
faraday_options = {timeout: 10}
|
|
336
|
+
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
337
337
|
|
|
338
|
-
expect(
|
|
339
|
-
"http://auth.service.io/auth/admin/realms/valid-realm/organizations/8f6e474e-e688-4bec-99ba-5dc862594f4b",
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
557
|
-
allow_any_instance_of(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
64
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:
|
|
63
|
+
faraday_options = {timeout: 10}
|
|
64
|
+
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
65
65
|
|
|
66
|
-
expect(
|
|
67
|
-
"http://auth.service.io/auth/admin/realms",
|
|
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(
|
|
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
|
-
|
|
91
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:
|
|
90
|
+
faraday_options = {timeout: 10}
|
|
91
|
+
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
92
92
|
|
|
93
|
-
expect(
|
|
94
|
-
"http://auth.service.io/auth/admin/realms/valid-realm",
|
|
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(
|
|
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
|
-
|
|
121
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:
|
|
120
|
+
faraday_options = {timeout: 10}
|
|
121
|
+
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
122
122
|
|
|
123
|
-
expect(
|
|
124
|
-
"http://auth.service.io/auth/admin/realms",
|
|
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(
|
|
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
|
-
|
|
147
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:
|
|
146
|
+
faraday_options = {timeout: 10}
|
|
147
|
+
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
148
148
|
|
|
149
|
-
expect(
|
|
150
|
-
"http://auth.service.io/auth/admin/realms/valid-realm",
|
|
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(
|
|
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
|
-
|
|
39
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:
|
|
38
|
+
faraday_options = {timeout: 10}
|
|
39
|
+
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
40
40
|
|
|
41
|
-
expect(
|
|
42
|
-
"http://auth.service.io/auth/admin/realms/valid-realm/roles",
|
|
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(
|
|
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
|
-
|
|
71
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:
|
|
70
|
+
faraday_options = {timeout: 10}
|
|
71
|
+
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
72
72
|
|
|
73
|
-
expect(
|
|
74
|
-
"http://auth.service.io/auth/admin/realms/valid-realm/roles",
|
|
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
|