keycloak-admin 2.0.0 → 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 +19 -0
- data/README.md +54 -2
- data/keycloak-admin.gemspec +14 -5
- data/lib/keycloak-admin/client/client.rb +30 -11
- 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/configurable_token_client.rb +2 -1
- data/lib/keycloak-admin/client/group_client.rb +4 -6
- data/lib/keycloak-admin/client/organization_client.rb +7 -7
- data/lib/keycloak-admin/client/resource.rb +98 -0
- data/lib/keycloak-admin/client/response.rb +36 -0
- data/lib/keycloak-admin/client/role_mapper_client.rb +2 -1
- data/lib/keycloak-admin/client/user_client.rb +22 -11
- data/lib/keycloak-admin/configuration.rb +22 -0
- data/lib/keycloak-admin/error.rb +62 -0
- data/lib/keycloak-admin/version.rb +1 -1
- data/lib/keycloak-admin.rb +1 -0
- metadata +38 -53
- data/.github/workflows/Dockerfile +0 -24
- data/.github/workflows/ci.yml +0 -94
- data/.gitignore +0 -10
- data/.rspec +0 -2
- data/Dockerfile +0 -13
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -52
- 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 -82
- 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 -48
- 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/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 -113
- 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 -29
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
RSpec.describe KeycloakAdmin::ImpersonationRepresentation do
|
|
2
|
-
describe "#parse_set_cookie_string" do
|
|
3
|
-
|
|
4
|
-
let(:origin) { "http://auth.service.io" }
|
|
5
|
-
let(:set_cookie_string) { "" }
|
|
6
|
-
|
|
7
|
-
before(:each) do
|
|
8
|
-
@cookie = KeycloakAdmin::ImpersonationRepresentation.parse_set_cookie_string(set_cookie_string, origin)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
shared_context "common properties are read properly" do
|
|
12
|
-
it "parses its domain property" do
|
|
13
|
-
expect(@cookie.domain).to eq "auth.service.io"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "parses its for_domain property" do
|
|
17
|
-
expect(@cookie.for_domain).to be false
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "parses its Path property" do
|
|
21
|
-
expect(@cookie.path).to eq "/auth/realms/a-realm"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "parses its Secure property" do
|
|
25
|
-
expect(@cookie.secure).to be false
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
context "when result is an expiring empty KEYCLOAK_IDENTITY" do
|
|
30
|
-
let(:set_cookie_string) { "KEYCLOAK_IDENTITY=; Version=1; Comment=Expiring cookie; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Max-Age=0; Path=/auth/realms/a-realm; HttpOnly" }
|
|
31
|
-
|
|
32
|
-
include_examples "common properties are read properly"
|
|
33
|
-
|
|
34
|
-
it "parses its name property" do
|
|
35
|
-
expect(@cookie.name).to eq "KEYCLOAK_IDENTITY"
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "parses its value property" do
|
|
39
|
-
expect(@cookie.value).to eq ""
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it "parses its Expires property" do
|
|
43
|
-
expect(@cookie.expires).to be <= Time.now
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it "parses its Max-Age property" do
|
|
47
|
-
expect(@cookie.max_age).to eq 0
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it "parses its HttpOnly property" do
|
|
51
|
-
expect(@cookie.httponly).to be true
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
context "when result is an expiring empty KEYCLOAK_SESSION" do
|
|
57
|
-
let(:set_cookie_string) { "KEYCLOAK_SESSION=; Version=1; Comment=Expiring cookie; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Max-Age=0; Path=/auth/realms/a-realm" }
|
|
58
|
-
|
|
59
|
-
include_examples "common properties are read properly"
|
|
60
|
-
|
|
61
|
-
it "parses its name property" do
|
|
62
|
-
expect(@cookie.name).to eq "KEYCLOAK_SESSION"
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it "parses its value property" do
|
|
66
|
-
expect(@cookie.value).to eq ""
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it "parses its Expires property" do
|
|
70
|
-
expect(@cookie.expires).to be <= Time.now
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it "parses its Max-Age property" do
|
|
74
|
-
expect(@cookie.max_age).to eq 0
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it "parses its HttpOnly property" do
|
|
78
|
-
expect(@cookie.httponly).to be false
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
context "when result is an expiring empty KEYCLOAK_REMEMBER_ME" do
|
|
84
|
-
let(:set_cookie_string) { "KEYCLOAK_REMEMBER_ME=; Version=1; Comment=Expiring cookie; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Max-Age=0; Path=/auth/realms/a-realm; HttpOnly" }
|
|
85
|
-
|
|
86
|
-
include_examples "common properties are read properly"
|
|
87
|
-
|
|
88
|
-
it "parses its name property" do
|
|
89
|
-
expect(@cookie.name).to eq "KEYCLOAK_REMEMBER_ME"
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
it "parses its value property" do
|
|
93
|
-
expect(@cookie.value).to eq ""
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it "parses its Expires property" do
|
|
97
|
-
expect(@cookie.expires).to be <= Time.now
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
it "parses its Max-Age property" do
|
|
101
|
-
expect(@cookie.max_age).to eq 0
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
it "parses its HttpOnly property" do
|
|
105
|
-
expect(@cookie.httponly).to be true
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
context "when result is a new KEYCLOAK_IDENTITY" do
|
|
110
|
-
let(:set_cookie_string) { "KEYCLOAK_IDENTITY=eyJhbGciOiJIUzI1NiIsImtpZCIgOiAiMDQyMTcwMWItY2I2Ny00YzQ4LWIzZWYtMDBlMDhhMmE4MjNjIn0.eyJqdGkiOiI5ZTEyODc3MC1mN2U1LTQ0OWYtYWMzYi03OTAzN2Q5NDBhOTMiLCJleHAiOjE1MTY2ODE2ODIsIm5iZiI6MCwiaWF0IjoxNTE2NjQ1NjgyLCJpc3MiOiJodHRwOi8vYXV0aDo4MDgwL2F1dGgvcmVhbG1zL2NvbW11dHkiLCJzdWIiOiI0NGM1MzdmMi1iMzBiLTRlZTctYjI4Ni1lZTY2NjI2NDcwYWMiLCJhdXRoX3RpbWUiOjAsInNlc3Npb25fc3RhdGUiOiI3ZDI5NTJlZS0xMjllLTRmOGQtYmFjNy1jMWE0YWUxNGRjY2QiLCJyZXNvdXJjZV9hY2Nlc3MiOnt9LCJzdGF0ZV9jaGVja2VyIjoiUEdXZVdXc3hMRmN3WG1QelFmMGxBQTJrN1V3Skg3UUlHU0lrN3hmWUFEbyJ9.Hw9EM1rZLXkUfE97tfS8jw8MFogfMoGpT34yoMupK3E; Version=1; Path=/auth/realms/a-realm; HttpOnly" }
|
|
111
|
-
|
|
112
|
-
include_examples "common properties are read properly"
|
|
113
|
-
|
|
114
|
-
it "parses its name property" do
|
|
115
|
-
expect(@cookie.name).to eq "KEYCLOAK_IDENTITY"
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
it "parses its value property" do
|
|
119
|
-
expect(@cookie.value).to eq "eyJhbGciOiJIUzI1NiIsImtpZCIgOiAiMDQyMTcwMWItY2I2Ny00YzQ4LWIzZWYtMDBlMDhhMmE4MjNjIn0.eyJqdGkiOiI5ZTEyODc3MC1mN2U1LTQ0OWYtYWMzYi03OTAzN2Q5NDBhOTMiLCJleHAiOjE1MTY2ODE2ODIsIm5iZiI6MCwiaWF0IjoxNTE2NjQ1NjgyLCJpc3MiOiJodHRwOi8vYXV0aDo4MDgwL2F1dGgvcmVhbG1zL2NvbW11dHkiLCJzdWIiOiI0NGM1MzdmMi1iMzBiLTRlZTctYjI4Ni1lZTY2NjI2NDcwYWMiLCJhdXRoX3RpbWUiOjAsInNlc3Npb25fc3RhdGUiOiI3ZDI5NTJlZS0xMjllLTRmOGQtYmFjNy1jMWE0YWUxNGRjY2QiLCJyZXNvdXJjZV9hY2Nlc3MiOnt9LCJzdGF0ZV9jaGVja2VyIjoiUEdXZVdXc3hMRmN3WG1QelFmMGxBQTJrN1V3Skg3UUlHU0lrN3hmWUFEbyJ9.Hw9EM1rZLXkUfE97tfS8jw8MFogfMoGpT34yoMupK3E"
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
it "parses its Expires property" do
|
|
123
|
-
expect(@cookie.expires).to be_nil
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
it "parses its Max-Age property" do
|
|
127
|
-
expect(@cookie.max_age).to be nil
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
it "parses its HttpOnly property" do
|
|
131
|
-
expect(@cookie.httponly).to be true
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
context "when result is a new KEYCLOAK_SESSION" do
|
|
136
|
-
let(:set_cookie_string) { "KEYCLOAK_SESSION=commuty/44c537f2-b30b-4ee7-b286-ee66626470ac/cd79f3c2-7cee-4c4e-980b-43293aaaff88; Version=1; Expires=Tue, 23-Jan-2018 23:56:32 GMT; Max-Age=36000; Path=/auth/realms/a-realm" }
|
|
137
|
-
|
|
138
|
-
include_examples "common properties are read properly"
|
|
139
|
-
|
|
140
|
-
it "parses its name property" do
|
|
141
|
-
expect(@cookie.name).to eq "KEYCLOAK_SESSION"
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
it "parses its value property" do
|
|
145
|
-
expect(@cookie.value).to eq "commuty/44c537f2-b30b-4ee7-b286-ee66626470ac/cd79f3c2-7cee-4c4e-980b-43293aaaff88"
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
it "parses its Expires property" do
|
|
149
|
-
expect(@cookie.expires).to_not be_nil
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
it "parses its Max-Age property" do
|
|
153
|
-
expect(@cookie.max_age).to be 36000
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
it "parses its HttpOnly property" do
|
|
157
|
-
expect(@cookie.httponly).to be false
|
|
158
|
-
end
|
|
159
|
-
end
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
|
|
@@ -1,64 +0,0 @@
|
|
|
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
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
RSpec.describe KeycloakAdmin::ProtocolMapperRepresentation do
|
|
2
|
-
describe "#to_json" do
|
|
3
|
-
before(:each) do
|
|
4
|
-
@mapper = KeycloakAdmin::ProtocolMapperRepresentation.from_hash(
|
|
5
|
-
{
|
|
6
|
-
"id" => "hello",
|
|
7
|
-
"name" => "abcd",
|
|
8
|
-
"protocol" => "openid-connect",
|
|
9
|
-
"protocolMapper" => "oidc-hardcoded-claim-mapper",
|
|
10
|
-
"consentRequired" => false,
|
|
11
|
-
"config" => {
|
|
12
|
-
"claim.value" => "123456",
|
|
13
|
-
"userinfo.token.claim" => "false",
|
|
14
|
-
"id.token.claim" => "false",
|
|
15
|
-
"access.token.claim" => "true",
|
|
16
|
-
"claim.name" => "abcd",
|
|
17
|
-
"jsonType.label" => "String",
|
|
18
|
-
"access.tokenResponse.claim" => "false"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "can convert to json" do
|
|
25
|
-
expect(@mapper.to_json).to eq "{\"id\":\"hello\",\"config\":{\"claim.value\":\"123456\",\"userinfo.token.claim\":\"false\",\"id.token.claim\":\"false\",\"access.token.claim\":\"true\",\"claim.name\":\"abcd\",\"jsonType.label\":\"String\",\"access.tokenResponse.claim\":\"false\"},\"name\":\"abcd\",\"protocol\":\"openid-connect\",\"protocolMapper\":\"oidc-hardcoded-claim-mapper\"}"
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
describe "array#to_json" do
|
|
30
|
-
before(:each) do
|
|
31
|
-
@mapper = [
|
|
32
|
-
KeycloakAdmin::ProtocolMapperRepresentation.from_hash(
|
|
33
|
-
{
|
|
34
|
-
"id" => "hello",
|
|
35
|
-
"name" => "abcd",
|
|
36
|
-
"protocol" => "openid-connect",
|
|
37
|
-
"protocolMapper" => "oidc-hardcoded-claim-mapper",
|
|
38
|
-
"consentRequired" => false,
|
|
39
|
-
"config" => {
|
|
40
|
-
"claim.value" => "123456",
|
|
41
|
-
"userinfo.token.claim" => "false",
|
|
42
|
-
"id.token.claim" => "false",
|
|
43
|
-
"access.token.claim" => "true",
|
|
44
|
-
"claim.name" => "abcd",
|
|
45
|
-
"jsonType.label" => "String",
|
|
46
|
-
"access.tokenResponse.claim" => "false"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
)
|
|
50
|
-
]
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it "can convert to json" do
|
|
54
|
-
expect(@mapper.to_json).to eq "[{\"id\":\"hello\",\"config\":{\"claim.value\":\"123456\",\"userinfo.token.claim\":\"false\",\"id.token.claim\":\"false\",\"access.token.claim\":\"true\",\"claim.name\":\"abcd\",\"jsonType.label\":\"String\",\"access.tokenResponse.claim\":\"false\"},\"name\":\"abcd\",\"protocol\":\"openid-connect\",\"protocolMapper\":\"oidc-hardcoded-claim-mapper\"}]"
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
RSpec.describe KeycloakAdmin::RoleRepresentation do
|
|
2
|
-
describe "#to_json" do
|
|
3
|
-
before(:each) do
|
|
4
|
-
@mapper = KeycloakAdmin::RoleRepresentation.from_hash(
|
|
5
|
-
{
|
|
6
|
-
"id" => "bb79fb10-a7b4-4728-a662-82a4de7844a3",
|
|
7
|
-
"name" => "abcd",
|
|
8
|
-
"composite" => true,
|
|
9
|
-
"clientRole" => false
|
|
10
|
-
}
|
|
11
|
-
)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "can convert to json" do
|
|
15
|
-
expect(@mapper.to_json).to eq "{\"id\":\"bb79fb10-a7b4-4728-a662-82a4de7844a3\",\"name\":\"abcd\",\"composite\":true,\"clientRole\":false,\"containerId\":null}"
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
describe "array#to_json" do
|
|
20
|
-
before(:each) do
|
|
21
|
-
@mappers = [
|
|
22
|
-
KeycloakAdmin::RoleRepresentation.from_hash(
|
|
23
|
-
{
|
|
24
|
-
"id" => "bb79fb10-a7b4-4728-a662-82a4de7844a3",
|
|
25
|
-
"name" => "abcd",
|
|
26
|
-
"composite" => true,
|
|
27
|
-
"clientRole" => false
|
|
28
|
-
}
|
|
29
|
-
)
|
|
30
|
-
]
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "can convert to json" do
|
|
34
|
-
expect(@mappers.to_json).to eq "[{\"id\":\"bb79fb10-a7b4-4728-a662-82a4de7844a3\",\"name\":\"abcd\",\"composite\":true,\"clientRole\":false,\"containerId\":null}]"
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe KeycloakAdmin::SessionRepresentation do
|
|
4
|
-
describe '.from_hash' do
|
|
5
|
-
it 'converts json response to class structure' do
|
|
6
|
-
rep = described_class.from_hash({
|
|
7
|
-
'username' => 'test_username',
|
|
8
|
-
'userId' => '95985b21-d884-4bbd-b852-cb8cd365afc2',
|
|
9
|
-
'ipAddress' => '1.1.1.1',
|
|
10
|
-
'start' => 12345678
|
|
11
|
-
})
|
|
12
|
-
expect(rep.user_id).to eq '95985b21-d884-4bbd-b852-cb8cd365afc2'
|
|
13
|
-
expect(rep).to be_a described_class
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
RSpec.describe KeycloakAdmin::UserRepresentation do
|
|
2
|
-
describe "#to_json" do
|
|
3
|
-
before(:each) do
|
|
4
|
-
@user = KeycloakAdmin::UserRepresentation.from_hash(
|
|
5
|
-
"username" => "test_username",
|
|
6
|
-
"createdTimestamp" => Time.at(1559836000).to_i,
|
|
7
|
-
"enabled" => true
|
|
8
|
-
)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "can convert to json" do
|
|
12
|
-
expect(@user.to_json).to eq '{"id":null,"createdTimestamp":1559836000,"origin":null,"username":"test_username","email":null,"enabled":true,"emailVerified":null,"firstName":null,"lastName":null,"attributes":null,"requiredActions":[],"totp":false,"credentials":[],"federatedIdentities":[]}'
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
RSpec.describe KeycloakAdmin::GroupResource do
|
|
2
|
-
describe "#resource_url" do
|
|
3
|
-
let(:realm_name) { "valid-realm" }
|
|
4
|
-
let(:group_id) { "95985b21-d884-4bbd-b852-cb8cd365afc2" }
|
|
5
|
-
|
|
6
|
-
before(:each) do
|
|
7
|
-
@built_url = KeycloakAdmin.realm(realm_name).group(group_id).resource_url
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it "return a proper url" do
|
|
11
|
-
expect(@built_url).to eq "http://auth.service.io/auth/admin/realms/valid-realm/groups/95985b21-d884-4bbd-b852-cb8cd365afc2"
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
RSpec.describe KeycloakAdmin::UserResource do
|
|
2
|
-
describe "#resource_url" do
|
|
3
|
-
let(:realm_name) { "valid-realm" }
|
|
4
|
-
let(:user_id) { "95985b21-d884-4bbd-b852-cb8cd365afc2" }
|
|
5
|
-
|
|
6
|
-
before(:each) do
|
|
7
|
-
@built_url = KeycloakAdmin.realm(realm_name).user(user_id).resource_url
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it "return a proper url" do
|
|
11
|
-
expect(@built_url).to eq "http://auth.service.io/auth/admin/realms/valid-realm/users/95985b21-d884-4bbd-b852-cb8cd365afc2"
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
require_relative "../lib/keycloak-admin"
|
|
2
|
-
|
|
3
|
-
require "byebug"
|
|
4
|
-
|
|
5
|
-
def configure
|
|
6
|
-
KeycloakAdmin.configure do |config|
|
|
7
|
-
config.server_url = "http://auth.service.io/auth"
|
|
8
|
-
config.server_domain = "auth.service.io"
|
|
9
|
-
config.client_id = "admin-cli"
|
|
10
|
-
config.client_secret = "aaaaaaaa"
|
|
11
|
-
config.client_realm_name = "master2"
|
|
12
|
-
config.use_service_account = true
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
RSpec.configure do |config|
|
|
17
|
-
config.expect_with :rspec do |expectations|
|
|
18
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
configure
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def stub_token_client
|
|
25
|
-
allow_any_instance_of(KeycloakAdmin::TokenClient).to receive(:get).and_return KeycloakAdmin::TokenRepresentation.new(
|
|
26
|
-
"test_access_token", "token_type", "expires_in", "refresh_token",
|
|
27
|
-
"refresh_expires_in", "id_token", "not_before_policy", "session_state"
|
|
28
|
-
)
|
|
29
|
-
end
|