keycloak-admin 1.1.3 → 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.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/Dockerfile +24 -24
  3. data/.github/workflows/ci.yml +80 -83
  4. data/.gitignore +9 -9
  5. data/.rspec +2 -2
  6. data/CHANGELOG.md +194 -188
  7. data/Dockerfile +12 -12
  8. data/Gemfile +3 -3
  9. data/Gemfile.lock +51 -49
  10. data/MIT-LICENSE +20 -20
  11. data/README.md +748 -748
  12. data/bin/console +9 -9
  13. data/keycloak-admin.gemspec +24 -24
  14. data/lib/keycloak-admin/client/attack_detection_client.rb +41 -41
  15. data/lib/keycloak-admin/client/client.rb +56 -56
  16. data/lib/keycloak-admin/client/client_authz_permission_client.rb +80 -80
  17. data/lib/keycloak-admin/client/client_authz_policy_client.rb +75 -75
  18. data/lib/keycloak-admin/client/client_authz_resource_client.rb +92 -92
  19. data/lib/keycloak-admin/client/client_authz_scope_client.rb +70 -70
  20. data/lib/keycloak-admin/client/client_client.rb +71 -71
  21. data/lib/keycloak-admin/client/client_role_client.rb +20 -20
  22. data/lib/keycloak-admin/client/client_role_mappings_client.rb +32 -32
  23. data/lib/keycloak-admin/client/configurable_token_client.rb +35 -35
  24. data/lib/keycloak-admin/client/group_client.rb +148 -131
  25. data/lib/keycloak-admin/client/identity_provider_client.rb +51 -51
  26. data/lib/keycloak-admin/client/realm_client.rb +122 -122
  27. data/lib/keycloak-admin/client/role_client.rb +59 -59
  28. data/lib/keycloak-admin/client/role_mapper_client.rb +47 -45
  29. data/lib/keycloak-admin/client/token_client.rb +29 -29
  30. data/lib/keycloak-admin/client/user_client.rb +266 -266
  31. data/lib/keycloak-admin/configuration.rb +52 -52
  32. data/lib/keycloak-admin/representation/attack_detection_representation.rb +17 -17
  33. data/lib/keycloak-admin/representation/camel_json.rb +12 -12
  34. data/lib/keycloak-admin/representation/client_authz_permission_representation.rb +33 -33
  35. data/lib/keycloak-admin/representation/client_authz_policy_config_representation.rb +14 -14
  36. data/lib/keycloak-admin/representation/client_authz_policy_representation.rb +26 -26
  37. data/lib/keycloak-admin/representation/client_authz_resource_representation.rb +25 -25
  38. data/lib/keycloak-admin/representation/client_authz_scope_representation.rb +16 -16
  39. data/lib/keycloak-admin/representation/client_representation.rb +71 -71
  40. data/lib/keycloak-admin/representation/credential_representation.rb +38 -38
  41. data/lib/keycloak-admin/representation/federated_identity_representation.rb +15 -15
  42. data/lib/keycloak-admin/representation/group_representation.rb +21 -21
  43. data/lib/keycloak-admin/representation/identity_provider_mapper_representation.rb +19 -19
  44. data/lib/keycloak-admin/representation/identity_provider_representation.rb +67 -67
  45. data/lib/keycloak-admin/representation/impersonation_redirection_representation.rb +16 -16
  46. data/lib/keycloak-admin/representation/impersonation_representation.rb +43 -43
  47. data/lib/keycloak-admin/representation/protocol_mapper_representation.rb +19 -19
  48. data/lib/keycloak-admin/representation/realm_representation.rb +14 -14
  49. data/lib/keycloak-admin/representation/representation.rb +23 -23
  50. data/lib/keycloak-admin/representation/role_representation.rb +19 -19
  51. data/lib/keycloak-admin/representation/session_representation.rb +22 -22
  52. data/lib/keycloak-admin/representation/token_representation.rb +39 -39
  53. data/lib/keycloak-admin/representation/user_representation.rb +47 -47
  54. data/lib/keycloak-admin/resource/base_role_containing_resource.rb +28 -28
  55. data/lib/keycloak-admin/resource/group_resource.rb +11 -11
  56. data/lib/keycloak-admin/resource/user_resource.rb +7 -7
  57. data/lib/keycloak-admin/version.rb +3 -3
  58. data/lib/keycloak-admin.rb +84 -84
  59. data/spec/client/attack_detection_client_spec.rb +102 -102
  60. data/spec/client/client_authz_permission_client_spec.rb +170 -170
  61. data/spec/client/client_authz_policy_client_spec.rb +169 -169
  62. data/spec/client/client_authz_resource_client_spec.rb +150 -150
  63. data/spec/client/client_authz_scope_client_spec.rb +133 -133
  64. data/spec/client/client_client_spec.rb +133 -133
  65. data/spec/client/client_role_mappings_client_spec.rb +82 -82
  66. data/spec/client/client_spec.rb +28 -28
  67. data/spec/client/configurable_token_client_spec.rb +34 -34
  68. data/spec/client/group_client_spec.rb +328 -258
  69. data/spec/client/identity_provider_client_spec.rb +92 -92
  70. data/spec/client/realm_client_spec.rb +155 -155
  71. data/spec/client/role_client_spec.rb +79 -79
  72. data/spec/client/role_mapper_client_spec.rb +113 -68
  73. data/spec/client/token_client_spec.rb +68 -68
  74. data/spec/client/user_client_spec.rb +373 -373
  75. data/spec/configuration_spec.rb +113 -113
  76. data/spec/integration/client_authorization_spec.rb +93 -95
  77. data/spec/representation/attack_detection_representation_spec.rb +15 -15
  78. data/spec/representation/client_authz_permission_representation_spec.rb +52 -52
  79. data/spec/representation/client_authz_policy_representation_spec.rb +46 -46
  80. data/spec/representation/client_authz_resource_representation_spec.rb +33 -33
  81. data/spec/representation/client_authz_scope_representation_spec.rb +18 -18
  82. data/spec/representation/client_representation_spec.rb +119 -119
  83. data/spec/representation/group_representation_spec.rb +22 -22
  84. data/spec/representation/identity_provider_mapper_representation_spec.rb +24 -24
  85. data/spec/representation/identity_provider_representation_spec.rb +113 -113
  86. data/spec/representation/impersonation_representation_spec.rb +163 -163
  87. data/spec/representation/protocol_mapper_representation_spec.rb +57 -57
  88. data/spec/representation/role_representation_spec.rb +37 -37
  89. data/spec/representation/session_representation_spec.rb +15 -15
  90. data/spec/representation/user_representation_spec.rb +15 -15
  91. data/spec/resource/group_resource_spec.rb +14 -14
  92. data/spec/resource/user_resource_spec.rb +14 -14
  93. data/spec/spec_helper.rb +37 -37
  94. metadata +10 -10
@@ -1,113 +1,113 @@
1
- RSpec.describe KeycloakAdmin::IdentityProviderRepresentation do
2
- describe "#from_hash" do
3
- before(:each) do
4
- json = <<-JSON
5
- {
6
- "alias": "acme",
7
- "displayName": "ACME",
8
- "internalId": "20fea77e-ae3d-411e-9467-2b3a20cd3e6d",
9
- "providerId": "saml",
10
- "enabled": true,
11
- "updateProfileFirstLoginMode": "on",
12
- "trustEmail": true,
13
- "storeToken": false,
14
- "addReadTokenRoleOnCreate": false,
15
- "authenticateByDefault": false,
16
- "linkOnly": false,
17
- "firstBrokerLoginFlowAlias": "first broker login",
18
- "config": {
19
- "hideOnLoginPage": "",
20
- "validateSignature": "true",
21
- "samlXmlKeyNameTranformer": "KEY_ID",
22
- "signingCertificate": "",
23
- "postBindingLogout": "false",
24
- "nameIDPolicyFormat": "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
25
- "postBindingResponse": "true",
26
- "backchannelSupported": "",
27
- "signatureAlgorithm": "RSA_SHA256",
28
- "wantAssertionsEncrypted": "false",
29
- "xmlSigKeyInfoKeyNameTransformer": "CERT_SUBJECT",
30
- "useJwksUrl": "true",
31
- "wantAssertionsSigned": "true",
32
- "postBindingAuthnRequest": "true",
33
- "forceAuthn": "",
34
- "wantAuthnRequestsSigned": "true",
35
- "singleSignOnServiceUrl": "https://login.microsoftonline.com/test/saml2",
36
- "addExtensionsElementWithKeyInfo": "false"
37
- }
38
- }
39
- JSON
40
- payload = JSON.parse(json)
41
- @identity_provider = KeycloakAdmin::IdentityProviderRepresentation.from_hash(payload)
42
- end
43
-
44
- it "parses the alias" do
45
- expect(@identity_provider.alias).to eq "acme"
46
- end
47
-
48
- it "parses the display name" do
49
- expect(@identity_provider.display_name).to eq "ACME"
50
- end
51
-
52
- it "parses the internalId" do
53
- expect(@identity_provider.internal_id).to eq "20fea77e-ae3d-411e-9467-2b3a20cd3e6d"
54
- end
55
-
56
- it "parses the provider id" do
57
- expect(@identity_provider.provider_id).to eq "saml"
58
- end
59
-
60
- it "parses the enabled" do
61
- expect(@identity_provider.enabled).to eq true
62
- end
63
-
64
- it "parses the update_profile_first_login_mode" do
65
- expect(@identity_provider.update_profile_first_login_mode).to eq "on"
66
- end
67
-
68
- it "parses the trust_email" do
69
- expect(@identity_provider.trust_email).to eq true
70
- end
71
-
72
- it "parses the store_token" do
73
- expect(@identity_provider.store_token).to eq false
74
- end
75
-
76
- it "parses the add_read_token_role_on_create" do
77
- expect(@identity_provider.add_read_token_role_on_create).to eq false
78
- end
79
-
80
- it "parses the authenticate_by_default" do
81
- expect(@identity_provider.authenticate_by_default).to eq false
82
- end
83
-
84
- it "parses the link_only" do
85
- expect(@identity_provider.link_only).to eq false
86
- end
87
-
88
- it "parses the first_broker_login_flow_alias" do
89
- expect(@identity_provider.first_broker_login_flow_alias).to eq "first broker login"
90
- end
91
-
92
- it "parses the configuration as a hash with camel properties" do
93
- expect(@identity_provider.config["hideOnLoginPage"]).to eq ""
94
- expect(@identity_provider.config["validateSignature"]).to eq "true"
95
- expect(@identity_provider.config["samlXmlKeyNameTranformer"]).to eq "KEY_ID"
96
- expect(@identity_provider.config["signingCertificate"]).to eq ""
97
- expect(@identity_provider.config["postBindingLogout"]).to eq "false"
98
- expect(@identity_provider.config["nameIDPolicyFormat"]).to eq "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"
99
- expect(@identity_provider.config["postBindingResponse"]).to eq "true"
100
- expect(@identity_provider.config["backchannelSupported"]).to eq ""
101
- expect(@identity_provider.config["signatureAlgorithm"]).to eq "RSA_SHA256"
102
- expect(@identity_provider.config["wantAssertionsEncrypted"]).to eq "false"
103
- expect(@identity_provider.config["xmlSigKeyInfoKeyNameTransformer"]).to eq "CERT_SUBJECT"
104
- expect(@identity_provider.config["useJwksUrl"]).to eq "true"
105
- expect(@identity_provider.config["wantAssertionsSigned"]).to eq "true"
106
- expect(@identity_provider.config["postBindingAuthnRequest"]).to eq "true"
107
- expect(@identity_provider.config["forceAuthn"]).to eq ""
108
- expect(@identity_provider.config["wantAuthnRequestsSigned"]).to eq "true"
109
- expect(@identity_provider.config["singleSignOnServiceUrl"]).to eq "https://login.microsoftonline.com/test/saml2"
110
- expect(@identity_provider.config["addExtensionsElementWithKeyInfo"]).to eq "false"
111
- end
112
- end
113
- end
1
+ RSpec.describe KeycloakAdmin::IdentityProviderRepresentation do
2
+ describe "#from_hash" do
3
+ before(:each) do
4
+ json = <<-JSON
5
+ {
6
+ "alias": "acme",
7
+ "displayName": "ACME",
8
+ "internalId": "20fea77e-ae3d-411e-9467-2b3a20cd3e6d",
9
+ "providerId": "saml",
10
+ "enabled": true,
11
+ "updateProfileFirstLoginMode": "on",
12
+ "trustEmail": true,
13
+ "storeToken": false,
14
+ "addReadTokenRoleOnCreate": false,
15
+ "authenticateByDefault": false,
16
+ "linkOnly": false,
17
+ "firstBrokerLoginFlowAlias": "first broker login",
18
+ "config": {
19
+ "hideOnLoginPage": "",
20
+ "validateSignature": "true",
21
+ "samlXmlKeyNameTranformer": "KEY_ID",
22
+ "signingCertificate": "",
23
+ "postBindingLogout": "false",
24
+ "nameIDPolicyFormat": "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
25
+ "postBindingResponse": "true",
26
+ "backchannelSupported": "",
27
+ "signatureAlgorithm": "RSA_SHA256",
28
+ "wantAssertionsEncrypted": "false",
29
+ "xmlSigKeyInfoKeyNameTransformer": "CERT_SUBJECT",
30
+ "useJwksUrl": "true",
31
+ "wantAssertionsSigned": "true",
32
+ "postBindingAuthnRequest": "true",
33
+ "forceAuthn": "",
34
+ "wantAuthnRequestsSigned": "true",
35
+ "singleSignOnServiceUrl": "https://login.microsoftonline.com/test/saml2",
36
+ "addExtensionsElementWithKeyInfo": "false"
37
+ }
38
+ }
39
+ JSON
40
+ payload = JSON.parse(json)
41
+ @identity_provider = KeycloakAdmin::IdentityProviderRepresentation.from_hash(payload)
42
+ end
43
+
44
+ it "parses the alias" do
45
+ expect(@identity_provider.alias).to eq "acme"
46
+ end
47
+
48
+ it "parses the display name" do
49
+ expect(@identity_provider.display_name).to eq "ACME"
50
+ end
51
+
52
+ it "parses the internalId" do
53
+ expect(@identity_provider.internal_id).to eq "20fea77e-ae3d-411e-9467-2b3a20cd3e6d"
54
+ end
55
+
56
+ it "parses the provider id" do
57
+ expect(@identity_provider.provider_id).to eq "saml"
58
+ end
59
+
60
+ it "parses the enabled" do
61
+ expect(@identity_provider.enabled).to eq true
62
+ end
63
+
64
+ it "parses the update_profile_first_login_mode" do
65
+ expect(@identity_provider.update_profile_first_login_mode).to eq "on"
66
+ end
67
+
68
+ it "parses the trust_email" do
69
+ expect(@identity_provider.trust_email).to eq true
70
+ end
71
+
72
+ it "parses the store_token" do
73
+ expect(@identity_provider.store_token).to eq false
74
+ end
75
+
76
+ it "parses the add_read_token_role_on_create" do
77
+ expect(@identity_provider.add_read_token_role_on_create).to eq false
78
+ end
79
+
80
+ it "parses the authenticate_by_default" do
81
+ expect(@identity_provider.authenticate_by_default).to eq false
82
+ end
83
+
84
+ it "parses the link_only" do
85
+ expect(@identity_provider.link_only).to eq false
86
+ end
87
+
88
+ it "parses the first_broker_login_flow_alias" do
89
+ expect(@identity_provider.first_broker_login_flow_alias).to eq "first broker login"
90
+ end
91
+
92
+ it "parses the configuration as a hash with camel properties" do
93
+ expect(@identity_provider.config["hideOnLoginPage"]).to eq ""
94
+ expect(@identity_provider.config["validateSignature"]).to eq "true"
95
+ expect(@identity_provider.config["samlXmlKeyNameTranformer"]).to eq "KEY_ID"
96
+ expect(@identity_provider.config["signingCertificate"]).to eq ""
97
+ expect(@identity_provider.config["postBindingLogout"]).to eq "false"
98
+ expect(@identity_provider.config["nameIDPolicyFormat"]).to eq "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"
99
+ expect(@identity_provider.config["postBindingResponse"]).to eq "true"
100
+ expect(@identity_provider.config["backchannelSupported"]).to eq ""
101
+ expect(@identity_provider.config["signatureAlgorithm"]).to eq "RSA_SHA256"
102
+ expect(@identity_provider.config["wantAssertionsEncrypted"]).to eq "false"
103
+ expect(@identity_provider.config["xmlSigKeyInfoKeyNameTransformer"]).to eq "CERT_SUBJECT"
104
+ expect(@identity_provider.config["useJwksUrl"]).to eq "true"
105
+ expect(@identity_provider.config["wantAssertionsSigned"]).to eq "true"
106
+ expect(@identity_provider.config["postBindingAuthnRequest"]).to eq "true"
107
+ expect(@identity_provider.config["forceAuthn"]).to eq ""
108
+ expect(@identity_provider.config["wantAuthnRequestsSigned"]).to eq "true"
109
+ expect(@identity_provider.config["singleSignOnServiceUrl"]).to eq "https://login.microsoftonline.com/test/saml2"
110
+ expect(@identity_provider.config["addExtensionsElementWithKeyInfo"]).to eq "false"
111
+ end
112
+ end
113
+ end
@@ -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
+