keycloak-admin 2.0.1 → 2.0.2
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/CHANGELOG.md +13 -0
- data/README.md +40 -4
- data/keycloak-admin.gemspec +14 -6
- data/lib/keycloak-admin/client/client.rb +22 -10
- data/lib/keycloak-admin/client/client_authz_permission_client.rb +1 -1
- data/lib/keycloak-admin/client/client_authz_policy_client.rb +1 -1
- data/lib/keycloak-admin/client/client_authz_resource_client.rb +1 -1
- data/lib/keycloak-admin/client/client_authz_scope_client.rb +1 -1
- data/lib/keycloak-admin/client/group_client.rb +2 -5
- data/lib/keycloak-admin/client/organization_client.rb +7 -7
- data/lib/keycloak-admin/client/user_client.rb +8 -4
- data/lib/keycloak-admin/error.rb +62 -0
- data/lib/keycloak-admin/version.rb +1 -1
- data/lib/keycloak-admin.rb +1 -0
- metadata +21 -56
- data/.github/workflows/Dockerfile +0 -24
- data/.github/workflows/ci.yml +0 -94
- data/.github/workflows/release.yml +0 -112
- data/.gitignore +0 -10
- data/.rspec +0 -2
- data/Dockerfile +0 -13
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -54
- data/Rakefile +0 -6
- data/bin/console +0 -9
- data/spec/client/attack_detection_client_spec.rb +0 -102
- data/spec/client/client_authz_permission_client_spec.rb +0 -170
- data/spec/client/client_authz_policy_client_spec.rb +0 -170
- data/spec/client/client_authz_resource_client_spec.rb +0 -150
- data/spec/client/client_authz_scope_client_spec.rb +0 -134
- data/spec/client/client_client_spec.rb +0 -133
- data/spec/client/client_role_mappings_client_spec.rb +0 -83
- data/spec/client/client_scope_client_spec.rb +0 -220
- data/spec/client/client_scope_protocol_mapper_client_spec.rb +0 -230
- data/spec/client/client_spec.rb +0 -101
- data/spec/client/configurable_token_client_spec.rb +0 -34
- data/spec/client/group_client_spec.rb +0 -328
- data/spec/client/identity_provider_client_spec.rb +0 -92
- data/spec/client/organization_client_spec.rb +0 -595
- data/spec/client/realm_client_spec.rb +0 -155
- data/spec/client/resource_spec.rb +0 -223
- data/spec/client/response_spec.rb +0 -68
- data/spec/client/role_client_spec.rb +0 -79
- data/spec/client/role_mapper_client_spec.rb +0 -113
- data/spec/client/token_client_spec.rb +0 -68
- data/spec/client/user_client_spec.rb +0 -418
- data/spec/configuration_spec.rb +0 -150
- data/spec/gemspec_spec.rb +0 -25
- data/spec/integration/client_authorization_spec.rb +0 -93
- data/spec/representation/attack_detection_representation_spec.rb +0 -16
- data/spec/representation/client_authz_permission_representation_spec.rb +0 -52
- data/spec/representation/client_authz_policy_representation_spec.rb +0 -47
- data/spec/representation/client_authz_resource_representation_spec.rb +0 -33
- data/spec/representation/client_authz_scope_representation_spec.rb +0 -19
- data/spec/representation/client_representation_spec.rb +0 -119
- data/spec/representation/client_scope_representation_spec.rb +0 -125
- data/spec/representation/credential_representation_spec.rb +0 -68
- data/spec/representation/group_representation_spec.rb +0 -22
- data/spec/representation/identity_provider_mapper_representation_spec.rb +0 -24
- data/spec/representation/identity_provider_representation_spec.rb +0 -113
- data/spec/representation/impersonation_representation_spec.rb +0 -163
- data/spec/representation/organization_representation_spec.rb +0 -64
- data/spec/representation/protocol_mapper_representation_spec.rb +0 -57
- data/spec/representation/role_representation_spec.rb +0 -37
- data/spec/representation/session_representation_spec.rb +0 -16
- data/spec/representation/user_representation_spec.rb +0 -15
- data/spec/resource/group_resource_spec.rb +0 -14
- data/spec/resource/user_resource_spec.rb +0 -14
- data/spec/spec_helper.rb +0 -36
|
@@ -1,595 +0,0 @@
|
|
|
1
|
-
RSpec.describe KeycloakAdmin::OrganizationClient do
|
|
2
|
-
describe "#organization_url" do
|
|
3
|
-
let(:realm_name) { "valid-realm" }
|
|
4
|
-
let(:organization_id) { nil }
|
|
5
|
-
|
|
6
|
-
before(:each) do
|
|
7
|
-
@built_url = KeycloakAdmin.realm(realm_name).organizations.organization_url(organization_id)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
context "when organization_id is defined" do
|
|
11
|
-
let(:organization_id) { "95985b21-d884-4bbd-b852-cb8cd365afc2" }
|
|
12
|
-
it "return a proper url with the organization id" do
|
|
13
|
-
expect(@built_url).to eq "http://auth.service.io/auth/admin/realms/valid-realm/organizations/95985b21-d884-4bbd-b852-cb8cd365afc2"
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
describe "#list" do
|
|
19
|
-
let(:realm_name) { "valid-realm" }
|
|
20
|
-
|
|
21
|
-
before(:each) do
|
|
22
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
23
|
-
stub_token_client
|
|
24
|
-
json_payload = <<-'payload'
|
|
25
|
-
[
|
|
26
|
-
{
|
|
27
|
-
"id": "8f6e474e-e688-4bec-99ba-5dc862594f4b",
|
|
28
|
-
"name": "My organization",
|
|
29
|
-
"alias": "myorg",
|
|
30
|
-
"enabled": true,
|
|
31
|
-
"description": "A single organization",
|
|
32
|
-
"domains": [
|
|
33
|
-
{
|
|
34
|
-
"name": "hello.com",
|
|
35
|
-
"verified": false
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"name": "gmail.com",
|
|
39
|
-
"verified": true
|
|
40
|
-
}
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
-
payload
|
|
45
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it "lists organizations" do
|
|
49
|
-
organizations = @organization_client.list
|
|
50
|
-
expect(organizations.length).to eq 1
|
|
51
|
-
expect(organizations[0].id).to eq "8f6e474e-e688-4bec-99ba-5dc862594f4b"
|
|
52
|
-
expect(organizations[0].name).to eq "My organization"
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "passes rest client options" do
|
|
56
|
-
faraday_options = {timeout: 10}
|
|
57
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
58
|
-
|
|
59
|
-
expect(KeycloakAdmin::Resource).to receive(:new).with(
|
|
60
|
-
"http://auth.service.io/auth/admin/realms/valid-realm/organizations?briefRepresentation=true", faraday_options, anything).and_call_original
|
|
61
|
-
|
|
62
|
-
organizations = @organization_client.list
|
|
63
|
-
expect(organizations.length).to eq 1
|
|
64
|
-
expect(organizations[0]).to be_a KeycloakAdmin::OrganizationRepresentation
|
|
65
|
-
expect(organizations[0].id).to eq "8f6e474e-e688-4bec-99ba-5dc862594f4b"
|
|
66
|
-
expect(organizations[0].name).to eq "My organization"
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
describe "#count" do
|
|
71
|
-
let(:realm_name) { "valid-realm" }
|
|
72
|
-
|
|
73
|
-
before(:each) do
|
|
74
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
75
|
-
stub_token_client
|
|
76
|
-
json_payload = "2"
|
|
77
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
it "count organizations" do
|
|
81
|
-
count = @organization_client.count(false, nil, "test")
|
|
82
|
-
expect(count).to eq 2
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
context "when building the count url" do
|
|
86
|
-
let(:exact) { nil }
|
|
87
|
-
let(:query) { nil }
|
|
88
|
-
let(:search) { nil }
|
|
89
|
-
|
|
90
|
-
before(:each) do
|
|
91
|
-
@count_url = @organization_client.count_url(exact, query, search)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
context "with everything null" do
|
|
95
|
-
it "return a proper url" do
|
|
96
|
-
expect(@count_url).to eq "http://auth.service.io/auth/admin/realms/valid-realm/organizations/count?"
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
context "with exact=false" do
|
|
101
|
-
let(:exact) { false }
|
|
102
|
-
it "return a proper url" do
|
|
103
|
-
expect(@count_url).to eq "http://auth.service.io/auth/admin/realms/valid-realm/organizations/count?exact=false"
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
context "with exact=true" do
|
|
108
|
-
let(:exact) { true }
|
|
109
|
-
it "return a proper url" do
|
|
110
|
-
expect(@count_url).to eq "http://auth.service.io/auth/admin/realms/valid-realm/organizations/count?exact=true"
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
context "with query=test" do
|
|
115
|
-
let(:query) { "test" }
|
|
116
|
-
it "return a proper url" do
|
|
117
|
-
expect(@count_url).to eq "http://auth.service.io/auth/admin/realms/valid-realm/organizations/count?q=test"
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
context "with search=nameoforg" do
|
|
122
|
-
let(:search) { "nameoforg" }
|
|
123
|
-
it "return a proper url" do
|
|
124
|
-
expect(@count_url).to eq "http://auth.service.io/auth/admin/realms/valid-realm/organizations/count?search=nameoforg"
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
context "with every argument setup" do
|
|
129
|
-
let(:exact) { true }
|
|
130
|
-
let(:query) { "a query" }
|
|
131
|
-
let(:search) { "a name" }
|
|
132
|
-
it "return a proper url" do
|
|
133
|
-
expect(@count_url).to eq "http://auth.service.io/auth/admin/realms/valid-realm/organizations/count?exact=true&q=a query&search=a name"
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
describe "#associated_with_member" do
|
|
140
|
-
let(:realm_name) { "valid-realm" }
|
|
141
|
-
|
|
142
|
-
before(:each) do
|
|
143
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
144
|
-
stub_token_client
|
|
145
|
-
json_payload = <<-'payload'
|
|
146
|
-
[
|
|
147
|
-
{
|
|
148
|
-
"id": "8f6e474e-e688-4bec-99ba-5dc862594f4b",
|
|
149
|
-
"name": "My organization",
|
|
150
|
-
"alias": "myorg",
|
|
151
|
-
"enabled": true,
|
|
152
|
-
"description": "A single organization",
|
|
153
|
-
"domains": [
|
|
154
|
-
{
|
|
155
|
-
"name": "hello.com",
|
|
156
|
-
"verified": false
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
"name": "gmail.com",
|
|
160
|
-
"verified": true
|
|
161
|
-
}
|
|
162
|
-
]
|
|
163
|
-
}
|
|
164
|
-
]
|
|
165
|
-
payload
|
|
166
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
it "list organizations of members organizations" do
|
|
170
|
-
organizations = @organization_client.associated_with_member("648ebe7f-e4ba-4d82-a87d-c585c866d0e7")
|
|
171
|
-
expect(organizations.size).to eq 1
|
|
172
|
-
expect(organizations[0]).to be_a KeycloakAdmin::OrganizationRepresentation
|
|
173
|
-
expect(organizations[0].id).to eq "8f6e474e-e688-4bec-99ba-5dc862594f4b"
|
|
174
|
-
end
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
describe "#delete" do
|
|
178
|
-
let(:realm_name) { "valid-realm" }
|
|
179
|
-
|
|
180
|
-
before(:each) do
|
|
181
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
182
|
-
stub_token_client
|
|
183
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:delete).and_return ""
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
it "deletes an organization" do
|
|
187
|
-
result = @organization_client.delete("2904e1a1-e5f4-4143-8725-003e54cc8b58")
|
|
188
|
-
expect(result).to be(true)
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
it "raises a delete error" do
|
|
192
|
-
faraday_options = {timeout: 10}
|
|
193
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
194
|
-
|
|
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, anything).and_raise("error")
|
|
197
|
-
|
|
198
|
-
expect { @organization_client.delete("2904e1a1-e5f4-4143-8725-003e54cc8b58") }.to raise_error("error")
|
|
199
|
-
end
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
describe "#identity_providers" do
|
|
203
|
-
let(:realm_name) { "valid-realm" }
|
|
204
|
-
|
|
205
|
-
before(:each) do
|
|
206
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
207
|
-
stub_token_client
|
|
208
|
-
json_payload = <<-'payload'
|
|
209
|
-
[
|
|
210
|
-
{
|
|
211
|
-
"alias": "google",
|
|
212
|
-
"displayName": "",
|
|
213
|
-
"internalId": "59b28b03-07db-4281-b637-4040368df082",
|
|
214
|
-
"providerId": "google",
|
|
215
|
-
"enabled": true,
|
|
216
|
-
"updateProfileFirstLoginMode": "on",
|
|
217
|
-
"trustEmail": false,
|
|
218
|
-
"storeToken": false,
|
|
219
|
-
"addReadTokenRoleOnCreate": false,
|
|
220
|
-
"authenticateByDefault": false,
|
|
221
|
-
"linkOnly": false,
|
|
222
|
-
"hideOnLogin": true,
|
|
223
|
-
"organizationId": "8f6e474e-e688-4bec-99ba-5dc862594f4b",
|
|
224
|
-
"config": {
|
|
225
|
-
"syncMode": "LEGACY",
|
|
226
|
-
"clientSecret": "**********",
|
|
227
|
-
"clientId": "test",
|
|
228
|
-
"kc.org.broker.redirect.mode.email-matches": "false"
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
]
|
|
232
|
-
payload
|
|
233
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
it "get identity providers" do
|
|
237
|
-
identity_providers = @organization_client.identity_providers("8f6e474e-e688-4bec-99ba-5dc862594f4b")
|
|
238
|
-
expect(identity_providers.size).to eq 1
|
|
239
|
-
expect(identity_providers[0]).to be_a KeycloakAdmin::IdentityProviderRepresentation
|
|
240
|
-
expect(identity_providers[0].alias).to eq "google"
|
|
241
|
-
expect(identity_providers[0].organization_id).to eq "8f6e474e-e688-4bec-99ba-5dc862594f4b"
|
|
242
|
-
end
|
|
243
|
-
end
|
|
244
|
-
|
|
245
|
-
describe "#add_identity_provider" do
|
|
246
|
-
let(:realm_name) { "valid-realm" }
|
|
247
|
-
|
|
248
|
-
before(:each) do
|
|
249
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
250
|
-
stub_token_client
|
|
251
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:post).and_return ""
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
it "adds one identity provider" do
|
|
255
|
-
@organization_client.add_identity_provider("8f6e474e-e688-4bec-99ba-5dc862594f4b", "google")
|
|
256
|
-
end
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
describe "#get_identity_provider" do
|
|
260
|
-
let(:realm_name) { "valid-realm" }
|
|
261
|
-
|
|
262
|
-
before(:each) do
|
|
263
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
264
|
-
json_payload = <<-'payload'
|
|
265
|
-
{
|
|
266
|
-
"alias": "google",
|
|
267
|
-
"displayName": "",
|
|
268
|
-
"internalId": "59b28b03-07db-4281-b637-4040368df082",
|
|
269
|
-
"providerId": "google",
|
|
270
|
-
"enabled": true,
|
|
271
|
-
"updateProfileFirstLoginMode": "on",
|
|
272
|
-
"trustEmail": false,
|
|
273
|
-
"storeToken": false,
|
|
274
|
-
"addReadTokenRoleOnCreate": false,
|
|
275
|
-
"authenticateByDefault": false,
|
|
276
|
-
"linkOnly": false,
|
|
277
|
-
"hideOnLogin": true,
|
|
278
|
-
"organizationId": "8f6e474e-e688-4bec-99ba-5dc862594f4b",
|
|
279
|
-
"config": {
|
|
280
|
-
"syncMode": "LEGACY",
|
|
281
|
-
"clientSecret": "**********",
|
|
282
|
-
"clientId": "test",
|
|
283
|
-
"kc.org.broker.redirect.mode.email-matches": "false"
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
payload
|
|
287
|
-
stub_token_client
|
|
288
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
|
|
289
|
-
end
|
|
290
|
-
|
|
291
|
-
it "get identity provider" do
|
|
292
|
-
idp = @organization_client.get_identity_provider("8f6e474e-e688-4bec-99ba-5dc862594f4b", "google")
|
|
293
|
-
expect(idp).to be_a KeycloakAdmin::IdentityProviderRepresentation
|
|
294
|
-
expect(idp.alias).to eq "google"
|
|
295
|
-
end
|
|
296
|
-
end
|
|
297
|
-
|
|
298
|
-
describe "#get" do
|
|
299
|
-
let(:realm_name) { "valid-realm" }
|
|
300
|
-
|
|
301
|
-
before(:each) do
|
|
302
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
303
|
-
stub_token_client
|
|
304
|
-
json_payload = <<-'payload'
|
|
305
|
-
{
|
|
306
|
-
"id": "8f6e474e-e688-4bec-99ba-5dc862594f4b",
|
|
307
|
-
"name": "My organization",
|
|
308
|
-
"alias": "myorg",
|
|
309
|
-
"enabled": true,
|
|
310
|
-
"description": "A single organization",
|
|
311
|
-
"domains": [
|
|
312
|
-
{
|
|
313
|
-
"name": "hello.com",
|
|
314
|
-
"verified": false
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
"name": "gmail.com",
|
|
318
|
-
"verified": true
|
|
319
|
-
}
|
|
320
|
-
]
|
|
321
|
-
}
|
|
322
|
-
payload
|
|
323
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
|
|
324
|
-
end
|
|
325
|
-
|
|
326
|
-
it "get organization" do
|
|
327
|
-
organization = @organization_client.get("8f6e474e-e688-4bec-99ba-5dc862594f4b")
|
|
328
|
-
expect(organization).to be
|
|
329
|
-
expect(organization).to be_a KeycloakAdmin::OrganizationRepresentation
|
|
330
|
-
expect(organization.id).to eq "8f6e474e-e688-4bec-99ba-5dc862594f4b"
|
|
331
|
-
expect(organization.name).to eq "My organization"
|
|
332
|
-
end
|
|
333
|
-
|
|
334
|
-
it "passes rest client options" do
|
|
335
|
-
faraday_options = {timeout: 10}
|
|
336
|
-
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:faraday_options).and_return faraday_options
|
|
337
|
-
|
|
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, anything).and_call_original
|
|
340
|
-
|
|
341
|
-
organization = @organization_client.get("8f6e474e-e688-4bec-99ba-5dc862594f4b")
|
|
342
|
-
expect(organization).to be
|
|
343
|
-
expect(organization).to be_a KeycloakAdmin::OrganizationRepresentation
|
|
344
|
-
expect(organization.id).to eq "8f6e474e-e688-4bec-99ba-5dc862594f4b"
|
|
345
|
-
end
|
|
346
|
-
end
|
|
347
|
-
|
|
348
|
-
describe "#members_count" do
|
|
349
|
-
let(:realm_name) { "valid-realm" }
|
|
350
|
-
|
|
351
|
-
before(:each) do
|
|
352
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
353
|
-
stub_token_client
|
|
354
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return "2"
|
|
355
|
-
end
|
|
356
|
-
|
|
357
|
-
it "get count of members" do
|
|
358
|
-
count = @organization_client.members_count("8f6e474e-e688-4bec-99ba-5dc862594f4b")
|
|
359
|
-
expect(count).to eq 2
|
|
360
|
-
end
|
|
361
|
-
end
|
|
362
|
-
|
|
363
|
-
describe "#members" do
|
|
364
|
-
let(:realm_name) { "valid-realm" }
|
|
365
|
-
|
|
366
|
-
before(:each) do
|
|
367
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
368
|
-
json_payload = <<-'payload'
|
|
369
|
-
[
|
|
370
|
-
{
|
|
371
|
-
"id": "648ebe7f-e4ba-4d82-a87d-c585c866d0e7",
|
|
372
|
-
"username": "admin",
|
|
373
|
-
"emailVerified": false,
|
|
374
|
-
"attributes": {
|
|
375
|
-
"is_temporary_admin": [
|
|
376
|
-
"true"
|
|
377
|
-
]
|
|
378
|
-
},
|
|
379
|
-
"enabled": true,
|
|
380
|
-
"createdTimestamp": 1767600090489,
|
|
381
|
-
"totp": false,
|
|
382
|
-
"disableableCredentialTypes": [],
|
|
383
|
-
"requiredActions": [],
|
|
384
|
-
"notBefore": 0,
|
|
385
|
-
"membershipType": "UNMANAGED"
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
"id": "2167481a-6a08-44f3-aa9a-42e33afa6834",
|
|
389
|
-
"username": "client",
|
|
390
|
-
"emailVerified": true,
|
|
391
|
-
"enabled": true,
|
|
392
|
-
"createdTimestamp": 1767601626861,
|
|
393
|
-
"totp": false,
|
|
394
|
-
"disableableCredentialTypes": [],
|
|
395
|
-
"requiredActions": [],
|
|
396
|
-
"notBefore": 0,
|
|
397
|
-
"membershipType": "MANAGED"
|
|
398
|
-
}
|
|
399
|
-
]
|
|
400
|
-
payload
|
|
401
|
-
stub_token_client
|
|
402
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
|
|
403
|
-
end
|
|
404
|
-
|
|
405
|
-
it "get members" do
|
|
406
|
-
members = @organization_client.members("8f6e474e-e688-4bec-99ba-5dc862594f4b")
|
|
407
|
-
expect(members.size).to eq 2
|
|
408
|
-
expect(members[0]).to be_a KeycloakAdmin::MemberRepresentation
|
|
409
|
-
expect(members[0].id).to eq "648ebe7f-e4ba-4d82-a87d-c585c866d0e7"
|
|
410
|
-
expect(members[0].membership_type).to eq "UNMANAGED"
|
|
411
|
-
expect(members[1]).to be_a KeycloakAdmin::MemberRepresentation
|
|
412
|
-
expect(members[1].id).to eq "2167481a-6a08-44f3-aa9a-42e33afa6834"
|
|
413
|
-
expect(members[1].membership_type).to eq "MANAGED"
|
|
414
|
-
end
|
|
415
|
-
end
|
|
416
|
-
|
|
417
|
-
describe "#invite_existing_user" do
|
|
418
|
-
let(:realm_name) { "valid-realm" }
|
|
419
|
-
|
|
420
|
-
before(:each) do
|
|
421
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
422
|
-
stub_token_client
|
|
423
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:post).and_return ""
|
|
424
|
-
end
|
|
425
|
-
|
|
426
|
-
it "invites an existing user" do
|
|
427
|
-
@organization_client.invite_existing_user("8f6e474e-e688-4bec-99ba-5dc862594f4b", "9a2ff47d-759c-4126-a281-8e4a7c6465e4")
|
|
428
|
-
end
|
|
429
|
-
end
|
|
430
|
-
|
|
431
|
-
describe "#invite_user" do
|
|
432
|
-
let(:realm_name) { "valid-realm" }
|
|
433
|
-
|
|
434
|
-
before(:each) do
|
|
435
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
436
|
-
stub_token_client
|
|
437
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:post).and_return ""
|
|
438
|
-
end
|
|
439
|
-
|
|
440
|
-
it "invites an existing user" do
|
|
441
|
-
@organization_client.invite_user("8f6e474e-e688-4bec-99ba-5dc862594f4b", "hello@acme.com", "John", "Doe")
|
|
442
|
-
end
|
|
443
|
-
end
|
|
444
|
-
|
|
445
|
-
describe "#delete_member" do
|
|
446
|
-
let(:realm_name) { "valid-realm" }
|
|
447
|
-
|
|
448
|
-
before(:each) do
|
|
449
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
450
|
-
stub_token_client
|
|
451
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:delete).and_return ""
|
|
452
|
-
end
|
|
453
|
-
|
|
454
|
-
it "deletes a member" do
|
|
455
|
-
result = @organization_client.delete_member("8f6e474e-e688-4bec-99ba-5dc862594f4b", "e226d9d3-868e-453b-9bfc-d9d9cc534526")
|
|
456
|
-
expect(result).to be(true)
|
|
457
|
-
end
|
|
458
|
-
end
|
|
459
|
-
|
|
460
|
-
describe "#get_member" do
|
|
461
|
-
let(:realm_name) { "valid-realm" }
|
|
462
|
-
|
|
463
|
-
before(:each) do
|
|
464
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
465
|
-
json_payload = <<-'payload'
|
|
466
|
-
{
|
|
467
|
-
"id": "9a2ff47d-759c-4126-a281-8e4a7c6465e4",
|
|
468
|
-
"username": "hello",
|
|
469
|
-
"email": "hello@gmail.com",
|
|
470
|
-
"emailVerified": true,
|
|
471
|
-
"enabled": true,
|
|
472
|
-
"createdTimestamp": 1767608088024,
|
|
473
|
-
"totp": false,
|
|
474
|
-
"disableableCredentialTypes": [],
|
|
475
|
-
"requiredActions": [],
|
|
476
|
-
"notBefore": 0,
|
|
477
|
-
"membershipType": "UNMANAGED"
|
|
478
|
-
}
|
|
479
|
-
payload
|
|
480
|
-
stub_token_client
|
|
481
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:get).and_return json_payload
|
|
482
|
-
end
|
|
483
|
-
|
|
484
|
-
it "gets a member" do
|
|
485
|
-
member = @organization_client.get_member("8f6e474e-e688-4bec-99ba-5dc862594f4b", "9a2ff47d-759c-4126-a281-8e4a7c6465e4")
|
|
486
|
-
expect(member).to be
|
|
487
|
-
expect(member).to be_a KeycloakAdmin::MemberRepresentation
|
|
488
|
-
expect(member.id).to eq "9a2ff47d-759c-4126-a281-8e4a7c6465e4"
|
|
489
|
-
expect(member.membership_type).to eq "UNMANAGED"
|
|
490
|
-
end
|
|
491
|
-
end
|
|
492
|
-
|
|
493
|
-
describe "#add_member" do
|
|
494
|
-
let(:realm_name) { "valid-realm" }
|
|
495
|
-
|
|
496
|
-
before(:each) do
|
|
497
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
498
|
-
stub_token_client
|
|
499
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:post).and_return ""
|
|
500
|
-
end
|
|
501
|
-
|
|
502
|
-
it "creates a member from an existing user" do
|
|
503
|
-
result = @organization_client.add_member("8f6e474e-e688-4bec-99ba-5dc862594f4b", "9a2ff47d-759c-4126-a281-8e4a7c6465e4")
|
|
504
|
-
expect(result).to be true
|
|
505
|
-
end
|
|
506
|
-
end
|
|
507
|
-
|
|
508
|
-
describe "#add_member" do
|
|
509
|
-
let(:realm_name) { "valid-realm" }
|
|
510
|
-
|
|
511
|
-
before(:each) do
|
|
512
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
513
|
-
stub_token_client
|
|
514
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:post).and_return ""
|
|
515
|
-
end
|
|
516
|
-
|
|
517
|
-
it "creates a member from an existing user" do
|
|
518
|
-
result = @organization_client.add_member("8f6e474e-e688-4bec-99ba-5dc862594f4b", "9a2ff47d-759c-4126-a281-8e4a7c6465e4")
|
|
519
|
-
expect(result).to be true
|
|
520
|
-
end
|
|
521
|
-
end
|
|
522
|
-
|
|
523
|
-
describe "#update" do
|
|
524
|
-
let(:realm_name) { "valid-realm" }
|
|
525
|
-
let(:json_payload) do
|
|
526
|
-
<<-'payload'
|
|
527
|
-
{
|
|
528
|
-
"id": "8f6e474e-e688-4bec-99ba-5dc862594f4b",
|
|
529
|
-
"name": "Company",
|
|
530
|
-
"alias": "company",
|
|
531
|
-
"enabled": true,
|
|
532
|
-
"description": "A test organization",
|
|
533
|
-
"redirectUrl": "https://myapp.acme.com/redirect",
|
|
534
|
-
"attributes": {
|
|
535
|
-
"hello": [
|
|
536
|
-
"yes"
|
|
537
|
-
]
|
|
538
|
-
},
|
|
539
|
-
"domains": [
|
|
540
|
-
{
|
|
541
|
-
"name": "hello.com",
|
|
542
|
-
"verified": false
|
|
543
|
-
},
|
|
544
|
-
{
|
|
545
|
-
"name": "help.com",
|
|
546
|
-
"verified": false
|
|
547
|
-
}
|
|
548
|
-
]
|
|
549
|
-
}
|
|
550
|
-
payload
|
|
551
|
-
end
|
|
552
|
-
|
|
553
|
-
before(:each) do
|
|
554
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
555
|
-
stub_token_client
|
|
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
|
-
end
|
|
559
|
-
|
|
560
|
-
it "updates an organization" do
|
|
561
|
-
organization = KeycloakAdmin::OrganizationRepresentation.from_json(json_payload)
|
|
562
|
-
updated_organization = @organization_client.update(organization)
|
|
563
|
-
expect(updated_organization).to be
|
|
564
|
-
expect(updated_organization).to be_a KeycloakAdmin::OrganizationRepresentation
|
|
565
|
-
expect(updated_organization.id).to eq "8f6e474e-e688-4bec-99ba-5dc862594f4b"
|
|
566
|
-
end
|
|
567
|
-
end
|
|
568
|
-
|
|
569
|
-
describe "#create!" do
|
|
570
|
-
let(:realm_name) { "valid-realm" }
|
|
571
|
-
before(:each) do
|
|
572
|
-
@organization_client = KeycloakAdmin.realm(realm_name).organizations
|
|
573
|
-
stub_token_client
|
|
574
|
-
allow_any_instance_of(KeycloakAdmin::Resource).to receive(:post).and_return ""
|
|
575
|
-
end
|
|
576
|
-
|
|
577
|
-
it "creates an organization" do
|
|
578
|
-
@organization_client.create!(
|
|
579
|
-
"new name",
|
|
580
|
-
"alias_name",
|
|
581
|
-
"enabled",
|
|
582
|
-
"description",
|
|
583
|
-
"http://redirect_url",
|
|
584
|
-
[
|
|
585
|
-
KeycloakAdmin::OrganizationDomainRepresentation.new("acme.com", true),
|
|
586
|
-
KeycloakAdmin::OrganizationDomainRepresentation.new("doe.com", false)
|
|
587
|
-
],
|
|
588
|
-
{
|
|
589
|
-
"advanced": ["yes", "no"],
|
|
590
|
-
"hello": ["maybe"]
|
|
591
|
-
}
|
|
592
|
-
)
|
|
593
|
-
end
|
|
594
|
-
end
|
|
595
|
-
end
|