keycloak-admin 1.1.5 → 1.1.7
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 +1 -1
- data/CHANGELOG.md +22 -0
- data/Gemfile.lock +10 -6
- data/README.md +128 -1
- data/keycloak-admin.gemspec +1 -1
- data/lib/keycloak-admin/client/client_scope_client.rb +65 -0
- data/lib/keycloak-admin/client/client_scope_protocol_mapper_client.rb +62 -0
- data/lib/keycloak-admin/client/organization_client.rb +245 -0
- data/lib/keycloak-admin/client/realm_client.rb +12 -0
- data/lib/keycloak-admin/representation/client_scope_representation.rb +21 -0
- data/lib/keycloak-admin/representation/identity_provider_representation.rb +4 -0
- data/lib/keycloak-admin/representation/member_representation.rb +11 -0
- data/lib/keycloak-admin/representation/organization_domain_representation.rb +18 -0
- data/lib/keycloak-admin/representation/organization_representation.rb +30 -0
- data/lib/keycloak-admin/version.rb +1 -1
- data/lib/keycloak-admin.rb +7 -0
- data/spec/client/client_scope_client_spec.rb +220 -0
- data/spec/client/client_scope_protocol_mapper_client_spec.rb +230 -0
- data/spec/client/organization_client_spec.rb +595 -0
- data/spec/representation/client_scope_representation_spec.rb +125 -0
- data/spec/representation/organization_representation_spec.rb +64 -0
- metadata +20 -8
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe KeycloakAdmin::ClientScopeRepresentation do
|
|
4
|
+
describe ".from_hash" do
|
|
5
|
+
context "with all fields" do
|
|
6
|
+
let(:hash) do
|
|
7
|
+
{
|
|
8
|
+
"id" => "valid-scope-id",
|
|
9
|
+
"name" => "my-scope",
|
|
10
|
+
"description" => "A test scope",
|
|
11
|
+
"protocol" => "openid-connect",
|
|
12
|
+
"attributes" => {
|
|
13
|
+
"display.on.consent.screen" => "true",
|
|
14
|
+
"include.in.token.scope" => "true"
|
|
15
|
+
},
|
|
16
|
+
"protocolMappers" => [
|
|
17
|
+
{
|
|
18
|
+
"id" => "mapper-id",
|
|
19
|
+
"name" => "my-claim",
|
|
20
|
+
"protocol" => "openid-connect",
|
|
21
|
+
"protocolMapper" => "oidc-hardcoded-claim-mapper",
|
|
22
|
+
"config" => { "claim.name" => "my_claim", "claim.value" => "bar" }
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
subject { described_class.from_hash(hash) }
|
|
29
|
+
|
|
30
|
+
it "returns an instance of the class" do
|
|
31
|
+
expect(subject).to be_a described_class
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "sets id" do
|
|
35
|
+
expect(subject.id).to eq "valid-scope-id"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "sets name" do
|
|
39
|
+
expect(subject.name).to eq "my-scope"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "sets description" do
|
|
43
|
+
expect(subject.description).to eq "A test scope"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "sets protocol" do
|
|
47
|
+
expect(subject.protocol).to eq "openid-connect"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "sets attributes" do
|
|
51
|
+
expect(subject.attributes).to eq(
|
|
52
|
+
"display.on.consent.screen" => "true",
|
|
53
|
+
"include.in.token.scope" => "true"
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "deserializes protocolMappers as ProtocolMapperRepresentation objects" do
|
|
58
|
+
expect(subject.protocol_mappers.size).to eq 1
|
|
59
|
+
expect(subject.protocol_mappers.first).to be_a KeycloakAdmin::ProtocolMapperRepresentation
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "sets the correct mapper attributes" do
|
|
63
|
+
expect(subject.protocol_mappers.first).to have_attributes(
|
|
64
|
+
id: "mapper-id",
|
|
65
|
+
name: "my-claim",
|
|
66
|
+
protocol: "openid-connect",
|
|
67
|
+
protocolMapper: "oidc-hardcoded-claim-mapper"
|
|
68
|
+
)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
context "without protocolMappers" do
|
|
73
|
+
subject { described_class.from_hash({ "id" => "valid-scope-id", "name" => "my-scope" }) }
|
|
74
|
+
|
|
75
|
+
it "defaults protocolMappers to an empty array" do
|
|
76
|
+
expect(subject.protocol_mappers).to eq []
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
context "with minimal fields" do
|
|
81
|
+
subject { described_class.from_hash({ "name" => "my-scope", "protocol" => "saml" }) }
|
|
82
|
+
|
|
83
|
+
it "sets name" do
|
|
84
|
+
expect(subject.name).to eq "my-scope"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "sets protocol" do
|
|
88
|
+
expect(subject.protocol).to eq "saml"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "leaves id nil" do
|
|
92
|
+
expect(subject.id).to be_nil
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "leaves description nil" do
|
|
96
|
+
expect(subject.description).to be_nil
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "leaves attributes nil" do
|
|
100
|
+
expect(subject.attributes).to be_nil
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
describe "#to_json" do
|
|
106
|
+
subject do
|
|
107
|
+
described_class.from_hash(
|
|
108
|
+
"id" => "valid-scope-id",
|
|
109
|
+
"name" => "my-scope",
|
|
110
|
+
"description" => "A test scope",
|
|
111
|
+
"protocol" => "openid-connect",
|
|
112
|
+
"attributes" => { "include.in.token.scope" => "true" }
|
|
113
|
+
)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it "serializes to JSON" do
|
|
117
|
+
parsed = JSON.parse(subject.to_json)
|
|
118
|
+
expect(parsed["id"]).to eq "valid-scope-id"
|
|
119
|
+
expect(parsed["name"]).to eq "my-scope"
|
|
120
|
+
expect(parsed["description"]).to eq "A test scope"
|
|
121
|
+
expect(parsed["protocol"]).to eq "openid-connect"
|
|
122
|
+
expect(parsed["attributes"]).to eq("include.in.token.scope" => "true")
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
|
|
2
|
+
RSpec.describe KeycloakAdmin::OrganizationRepresentation do
|
|
3
|
+
describe ".from_json" do
|
|
4
|
+
it "parse a single organization" do
|
|
5
|
+
json_payload = <<-'payload'
|
|
6
|
+
{
|
|
7
|
+
"id": "8f6e474e-e688-4bec-99ba-5dc862594f4b",
|
|
8
|
+
"name": "My organization",
|
|
9
|
+
"alias": "myorg",
|
|
10
|
+
"enabled": true,
|
|
11
|
+
"description": "A single organization",
|
|
12
|
+
"redirectUrl": "https://myapp.acme.com",
|
|
13
|
+
"attributes": {
|
|
14
|
+
"advanced": [
|
|
15
|
+
"yes"
|
|
16
|
+
],
|
|
17
|
+
"days": [
|
|
18
|
+
"monday",
|
|
19
|
+
"friday"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
"domains": [
|
|
23
|
+
{
|
|
24
|
+
"name": "hello.com",
|
|
25
|
+
"verified": false
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "gmail.com",
|
|
29
|
+
"verified": true
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
payload
|
|
34
|
+
|
|
35
|
+
organization = described_class.from_json(json_payload)
|
|
36
|
+
expect(organization).to be
|
|
37
|
+
expect(organization).to be_a described_class
|
|
38
|
+
expect(organization.id).to eq "8f6e474e-e688-4bec-99ba-5dc862594f4b"
|
|
39
|
+
expect(organization.name).to eq "My organization"
|
|
40
|
+
expect(organization.alias).to eq "myorg"
|
|
41
|
+
expect(organization.description).to eq "A single organization"
|
|
42
|
+
expect(organization.redirect_url).to eq "https://myapp.acme.com"
|
|
43
|
+
expect(organization.enabled).to be true
|
|
44
|
+
|
|
45
|
+
expect(organization.domains.size).to eq 2
|
|
46
|
+
expect(organization.domains[0]).to be_a KeycloakAdmin::OrganizationDomainRepresentation
|
|
47
|
+
expect(organization.domains[0].name).to eq "hello.com"
|
|
48
|
+
expect(organization.domains[0].verified).to be false
|
|
49
|
+
expect(organization.domains[1]).to be_a KeycloakAdmin::OrganizationDomainRepresentation
|
|
50
|
+
expect(organization.domains[1].name).to eq "gmail.com"
|
|
51
|
+
expect(organization.domains[1].verified).to be true
|
|
52
|
+
|
|
53
|
+
expect(organization.attributes.size).to eq 2
|
|
54
|
+
expect(organization.attributes["advanced"].size).to eq 1
|
|
55
|
+
expect(organization.attributes["advanced"][0]).to eq "yes"
|
|
56
|
+
expect(organization.attributes["days"].size).to eq 2
|
|
57
|
+
expect(organization.attributes["days"][0]).to eq "monday"
|
|
58
|
+
expect(organization.attributes["days"][1]).to eq "friday"
|
|
59
|
+
|
|
60
|
+
expect(organization.members.size).to eq 0
|
|
61
|
+
expect(organization.identity_providers.size).to eq 0
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: keycloak-admin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lorent Lempereur
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-03-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: http-cookie
|
|
@@ -64,14 +64,14 @@ dependencies:
|
|
|
64
64
|
requirements:
|
|
65
65
|
- - '='
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version:
|
|
67
|
+
version: 13.0.0
|
|
68
68
|
type: :development
|
|
69
69
|
prerelease: false
|
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
|
72
72
|
- - '='
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version:
|
|
74
|
+
version: 13.0.0
|
|
75
75
|
description: Keycloak Admin REST API client written in Ruby
|
|
76
76
|
email:
|
|
77
77
|
- lorent.lempereur.dev@gmail.com
|
|
@@ -101,9 +101,12 @@ files:
|
|
|
101
101
|
- lib/keycloak-admin/client/client_client.rb
|
|
102
102
|
- lib/keycloak-admin/client/client_role_client.rb
|
|
103
103
|
- lib/keycloak-admin/client/client_role_mappings_client.rb
|
|
104
|
+
- lib/keycloak-admin/client/client_scope_client.rb
|
|
105
|
+
- lib/keycloak-admin/client/client_scope_protocol_mapper_client.rb
|
|
104
106
|
- lib/keycloak-admin/client/configurable_token_client.rb
|
|
105
107
|
- lib/keycloak-admin/client/group_client.rb
|
|
106
108
|
- lib/keycloak-admin/client/identity_provider_client.rb
|
|
109
|
+
- lib/keycloak-admin/client/organization_client.rb
|
|
107
110
|
- lib/keycloak-admin/client/realm_client.rb
|
|
108
111
|
- lib/keycloak-admin/client/role_client.rb
|
|
109
112
|
- lib/keycloak-admin/client/role_mapper_client.rb
|
|
@@ -118,6 +121,7 @@ files:
|
|
|
118
121
|
- lib/keycloak-admin/representation/client_authz_resource_representation.rb
|
|
119
122
|
- lib/keycloak-admin/representation/client_authz_scope_representation.rb
|
|
120
123
|
- lib/keycloak-admin/representation/client_representation.rb
|
|
124
|
+
- lib/keycloak-admin/representation/client_scope_representation.rb
|
|
121
125
|
- lib/keycloak-admin/representation/credential_representation.rb
|
|
122
126
|
- lib/keycloak-admin/representation/federated_identity_representation.rb
|
|
123
127
|
- lib/keycloak-admin/representation/group_representation.rb
|
|
@@ -125,6 +129,9 @@ files:
|
|
|
125
129
|
- lib/keycloak-admin/representation/identity_provider_representation.rb
|
|
126
130
|
- lib/keycloak-admin/representation/impersonation_redirection_representation.rb
|
|
127
131
|
- lib/keycloak-admin/representation/impersonation_representation.rb
|
|
132
|
+
- lib/keycloak-admin/representation/member_representation.rb
|
|
133
|
+
- lib/keycloak-admin/representation/organization_domain_representation.rb
|
|
134
|
+
- lib/keycloak-admin/representation/organization_representation.rb
|
|
128
135
|
- lib/keycloak-admin/representation/protocol_mapper_representation.rb
|
|
129
136
|
- lib/keycloak-admin/representation/realm_representation.rb
|
|
130
137
|
- lib/keycloak-admin/representation/representation.rb
|
|
@@ -143,10 +150,13 @@ files:
|
|
|
143
150
|
- spec/client/client_authz_scope_client_spec.rb
|
|
144
151
|
- spec/client/client_client_spec.rb
|
|
145
152
|
- spec/client/client_role_mappings_client_spec.rb
|
|
153
|
+
- spec/client/client_scope_client_spec.rb
|
|
154
|
+
- spec/client/client_scope_protocol_mapper_client_spec.rb
|
|
146
155
|
- spec/client/client_spec.rb
|
|
147
156
|
- spec/client/configurable_token_client_spec.rb
|
|
148
157
|
- spec/client/group_client_spec.rb
|
|
149
158
|
- spec/client/identity_provider_client_spec.rb
|
|
159
|
+
- spec/client/organization_client_spec.rb
|
|
150
160
|
- spec/client/realm_client_spec.rb
|
|
151
161
|
- spec/client/role_client_spec.rb
|
|
152
162
|
- spec/client/role_mapper_client_spec.rb
|
|
@@ -160,11 +170,13 @@ files:
|
|
|
160
170
|
- spec/representation/client_authz_resource_representation_spec.rb
|
|
161
171
|
- spec/representation/client_authz_scope_representation_spec.rb
|
|
162
172
|
- spec/representation/client_representation_spec.rb
|
|
173
|
+
- spec/representation/client_scope_representation_spec.rb
|
|
163
174
|
- spec/representation/credential_representation_spec.rb
|
|
164
175
|
- spec/representation/group_representation_spec.rb
|
|
165
176
|
- spec/representation/identity_provider_mapper_representation_spec.rb
|
|
166
177
|
- spec/representation/identity_provider_representation_spec.rb
|
|
167
178
|
- spec/representation/impersonation_representation_spec.rb
|
|
179
|
+
- spec/representation/organization_representation_spec.rb
|
|
168
180
|
- spec/representation/protocol_mapper_representation_spec.rb
|
|
169
181
|
- spec/representation/role_representation_spec.rb
|
|
170
182
|
- spec/representation/session_representation_spec.rb
|
|
@@ -176,7 +188,7 @@ homepage: https://github.com/looorent/keycloak-admin-ruby
|
|
|
176
188
|
licenses:
|
|
177
189
|
- MIT
|
|
178
190
|
metadata: {}
|
|
179
|
-
post_install_message:
|
|
191
|
+
post_install_message:
|
|
180
192
|
rdoc_options: []
|
|
181
193
|
require_paths:
|
|
182
194
|
- lib
|
|
@@ -191,8 +203,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
191
203
|
- !ruby/object:Gem::Version
|
|
192
204
|
version: '0'
|
|
193
205
|
requirements: []
|
|
194
|
-
rubygems_version: 3.3.
|
|
195
|
-
signing_key:
|
|
206
|
+
rubygems_version: 3.0.3.1
|
|
207
|
+
signing_key:
|
|
196
208
|
specification_version: 4
|
|
197
209
|
summary: Keycloak Admin REST API client written in Ruby
|
|
198
210
|
test_files: []
|