keycloak-admin 1.1.2 → 1.1.4
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/Dockerfile +24 -0
- data/.github/workflows/ci.yml +80 -0
- data/.gitignore +9 -9
- data/.rspec +2 -2
- data/CHANGELOG.md +194 -183
- data/Dockerfile +12 -12
- data/Gemfile +3 -3
- data/Gemfile.lock +51 -49
- data/MIT-LICENSE +20 -20
- data/README.md +748 -482
- data/bin/console +9 -9
- data/keycloak-admin.gemspec +24 -24
- data/lib/keycloak-admin/client/attack_detection_client.rb +41 -41
- data/lib/keycloak-admin/client/client.rb +56 -56
- data/lib/keycloak-admin/client/client_authz_permission_client.rb +81 -0
- data/lib/keycloak-admin/client/client_authz_policy_client.rb +76 -0
- data/lib/keycloak-admin/client/client_authz_resource_client.rb +93 -0
- data/lib/keycloak-admin/client/client_authz_scope_client.rb +71 -0
- data/lib/keycloak-admin/client/client_client.rb +71 -71
- data/lib/keycloak-admin/client/client_role_client.rb +20 -20
- data/lib/keycloak-admin/client/client_role_mappings_client.rb +32 -32
- data/lib/keycloak-admin/client/configurable_token_client.rb +35 -35
- data/lib/keycloak-admin/client/group_client.rb +148 -131
- data/lib/keycloak-admin/client/identity_provider_client.rb +51 -51
- data/lib/keycloak-admin/client/realm_client.rb +122 -106
- data/lib/keycloak-admin/client/role_client.rb +59 -59
- data/lib/keycloak-admin/client/role_mapper_client.rb +47 -45
- data/lib/keycloak-admin/client/token_client.rb +29 -29
- data/lib/keycloak-admin/client/user_client.rb +266 -266
- data/lib/keycloak-admin/configuration.rb +52 -52
- data/lib/keycloak-admin/representation/attack_detection_representation.rb +17 -17
- data/lib/keycloak-admin/representation/camel_json.rb +12 -12
- data/lib/keycloak-admin/representation/client_authz_permission_representation.rb +34 -0
- data/lib/keycloak-admin/representation/client_authz_policy_config_representation.rb +15 -0
- data/lib/keycloak-admin/representation/client_authz_policy_representation.rb +27 -0
- data/lib/keycloak-admin/representation/client_authz_resource_representation.rb +26 -0
- data/lib/keycloak-admin/representation/client_authz_scope_representation.rb +17 -0
- data/lib/keycloak-admin/representation/client_representation.rb +71 -71
- data/lib/keycloak-admin/representation/credential_representation.rb +38 -38
- data/lib/keycloak-admin/representation/federated_identity_representation.rb +15 -15
- data/lib/keycloak-admin/representation/group_representation.rb +21 -21
- data/lib/keycloak-admin/representation/identity_provider_mapper_representation.rb +19 -19
- data/lib/keycloak-admin/representation/identity_provider_representation.rb +67 -67
- data/lib/keycloak-admin/representation/impersonation_redirection_representation.rb +16 -16
- data/lib/keycloak-admin/representation/impersonation_representation.rb +43 -43
- data/lib/keycloak-admin/representation/protocol_mapper_representation.rb +19 -19
- data/lib/keycloak-admin/representation/realm_representation.rb +14 -14
- data/lib/keycloak-admin/representation/representation.rb +23 -23
- data/lib/keycloak-admin/representation/role_representation.rb +19 -19
- data/lib/keycloak-admin/representation/session_representation.rb +22 -22
- data/lib/keycloak-admin/representation/token_representation.rb +39 -39
- data/lib/keycloak-admin/representation/user_representation.rb +47 -47
- data/lib/keycloak-admin/resource/base_role_containing_resource.rb +28 -28
- data/lib/keycloak-admin/resource/group_resource.rb +11 -11
- data/lib/keycloak-admin/resource/user_resource.rb +7 -7
- data/lib/keycloak-admin/version.rb +3 -3
- data/lib/keycloak-admin.rb +84 -75
- data/spec/client/attack_detection_client_spec.rb +102 -102
- data/spec/client/client_authz_permission_client_spec.rb +170 -0
- data/spec/client/client_authz_policy_client_spec.rb +170 -0
- data/spec/client/client_authz_resource_client_spec.rb +150 -0
- data/spec/client/client_authz_scope_client_spec.rb +134 -0
- data/spec/client/client_client_spec.rb +133 -133
- data/spec/client/client_role_mappings_client_spec.rb +82 -82
- data/spec/client/client_spec.rb +28 -28
- data/spec/client/configurable_token_client_spec.rb +34 -34
- data/spec/client/group_client_spec.rb +328 -258
- data/spec/client/identity_provider_client_spec.rb +92 -92
- data/spec/client/realm_client_spec.rb +155 -155
- data/spec/client/role_client_spec.rb +79 -79
- data/spec/client/role_mapper_client_spec.rb +113 -68
- data/spec/client/token_client_spec.rb +68 -68
- data/spec/client/user_client_spec.rb +373 -373
- data/spec/configuration_spec.rb +113 -113
- data/spec/integration/client_authorization_spec.rb +93 -0
- data/spec/representation/attack_detection_representation_spec.rb +15 -15
- data/spec/representation/client_authz_permission_representation_spec.rb +52 -0
- data/spec/representation/client_authz_policy_representation_spec.rb +47 -0
- data/spec/representation/client_authz_resource_representation_spec.rb +33 -0
- data/spec/representation/client_authz_scope_representation_spec.rb +19 -0
- data/spec/representation/client_representation_spec.rb +119 -119
- data/spec/representation/group_representation_spec.rb +22 -22
- data/spec/representation/identity_provider_mapper_representation_spec.rb +24 -24
- data/spec/representation/identity_provider_representation_spec.rb +113 -113
- data/spec/representation/impersonation_representation_spec.rb +163 -163
- data/spec/representation/protocol_mapper_representation_spec.rb +57 -57
- data/spec/representation/role_representation_spec.rb +37 -37
- data/spec/representation/session_representation_spec.rb +15 -15
- data/spec/representation/user_representation_spec.rb +15 -15
- data/spec/resource/group_resource_spec.rb +14 -14
- data/spec/resource/user_resource_spec.rb +14 -14
- data/spec/spec_helper.rb +37 -37
- metadata +29 -9
|
@@ -1,163 +1,163 @@
|
|
|
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
|
+
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,57 +1,57 @@
|
|
|
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
|
+
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 +1,37 @@
|
|
|
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
|
+
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 +1,16 @@
|
|
|
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
|
|
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
16
|
end
|
|
@@ -1,15 +1,15 @@
|
|
|
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
|
+
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 +1,14 @@
|
|
|
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
|
+
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 +1,14 @@
|
|
|
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
|
|
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
|