workos 9.3.0 → 9.4.0

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 (100) hide show
  1. checksums.yaml +4 -4
  2. data/.last-synced-sha +1 -1
  3. data/.oagen-manifest.json +110 -1
  4. data/.release-please-manifest.json +1 -1
  5. data/CHANGELOG.md +123 -0
  6. data/Gemfile.lock +2 -2
  7. data/lib/workos/admin_portal/generate_link.rb +0 -3
  8. data/lib/workos/admin_portal.rb +0 -3
  9. data/lib/workos/authorization/user_role_assignment.rb +3 -0
  10. data/lib/workos/authorization/user_role_assignment_source.rb +22 -0
  11. data/lib/workos/pipes/connected_account_dto.rb +31 -0
  12. data/lib/workos/pipes/create_data_integration.rb +34 -0
  13. data/lib/workos/pipes/custom_provider_definition.rb +49 -0
  14. data/lib/workos/pipes/data_integration.rb +55 -0
  15. data/lib/workos/pipes/data_integration_credential.rb +25 -0
  16. data/lib/workos/pipes/data_integration_credentials_dto.rb +25 -0
  17. data/lib/workos/pipes/data_integration_credentials_response.rb +25 -0
  18. data/lib/workos/pipes/data_integration_credentials_response_credential.rb +34 -0
  19. data/lib/workos/pipes/data_integration_custom_provider.rb +49 -0
  20. data/lib/workos/pipes/data_integrations_upsert_api_key_request.rb +25 -0
  21. data/lib/workos/pipes/data_integrations_vend_credentials_request.rb +22 -0
  22. data/lib/workos/pipes/update_custom_provider_definition.rb +49 -0
  23. data/lib/workos/pipes/update_data_integration.rb +31 -0
  24. data/lib/workos/pipes.rb +304 -0
  25. data/lib/workos/radar/radar_standalone_assess_request.rb +5 -2
  26. data/lib/workos/radar.rb +5 -2
  27. data/lib/workos/shared/auth_method_mismatch_error.rb +22 -0
  28. data/lib/workos/types/audit_log_export_state.rb +2 -1
  29. data/lib/workos/types/connected_account_state.rb +1 -2
  30. data/lib/workos/types/create_webhook_endpoint_events.rb +8 -1
  31. data/lib/workos/types/custom_provider_definition_authenticate_via.rb +13 -0
  32. data/lib/workos/types/data_integration_credential_type.rb +13 -0
  33. data/lib/workos/types/data_integration_credentials_response_error.rb +9 -0
  34. data/lib/workos/types/data_integration_credentials_type.rb +9 -0
  35. data/lib/workos/types/data_integration_custom_provider_authenticate_via.rb +9 -0
  36. data/lib/workos/types/data_integration_state.rb +14 -0
  37. data/lib/workos/types/data_integrations_list_response_data_connected_account_state.rb +6 -1
  38. data/lib/workos/types/update_custom_provider_definition_authenticate_via.rb +9 -0
  39. data/lib/workos/types/user_role_assignment_source_type.rb +13 -0
  40. data/lib/workos/user_management/authorization_code_session_authenticate_request.rb +5 -2
  41. data/lib/workos/user_management/create_magic_code_and_return.rb +14 -2
  42. data/lib/workos/user_management/create_user.rb +9 -0
  43. data/lib/workos/user_management/magic_auth_code_session_authenticate_request.rb +5 -2
  44. data/lib/workos/user_management/magic_auth_send_magic_auth_code_and_return_response.rb +18 -0
  45. data/lib/workos/user_management/password_session_authenticate_request.rb +8 -2
  46. data/lib/workos/user_management/radar_email_challenge_code_session_authenticate_request.rb +43 -0
  47. data/lib/workos/user_management/radar_sms_challenge_code_session_authenticate_request.rb +46 -0
  48. data/lib/workos/user_management/send_radar_sms_challenge.rb +31 -0
  49. data/lib/workos/user_management/send_radar_sms_challenge_response.rb +22 -0
  50. data/lib/workos/user_management/user_create_response.rb +7 -0
  51. data/lib/workos/user_management.rb +165 -6
  52. data/lib/workos/version.rb +1 -1
  53. data/rbi/workos/admin_portal.rbi +1 -2
  54. data/rbi/workos/auth_method_mismatch_error.rbi +30 -0
  55. data/rbi/workos/authorization_code_session_authenticate_request.rbi +6 -0
  56. data/rbi/workos/connected_account_dto.rbi +48 -0
  57. data/rbi/workos/create_data_integration.rbi +54 -0
  58. data/rbi/workos/create_magic_code_and_return.rbi +24 -0
  59. data/rbi/workos/create_user.rbi +18 -0
  60. data/rbi/workos/custom_provider_definition.rbi +84 -0
  61. data/rbi/workos/data_integration.rbi +96 -0
  62. data/rbi/workos/data_integration_credential.rbi +36 -0
  63. data/rbi/workos/data_integration_credentials_dto.rbi +36 -0
  64. data/rbi/workos/data_integration_credentials_response.rbi +36 -0
  65. data/rbi/workos/data_integration_credentials_response_credential.rbi +54 -0
  66. data/rbi/workos/data_integration_custom_provider.rbi +84 -0
  67. data/rbi/workos/data_integrations_upsert_api_key_request.rbi +36 -0
  68. data/rbi/workos/data_integrations_vend_credentials_request.rbi +30 -0
  69. data/rbi/workos/generate_link.rbi +0 -6
  70. data/rbi/workos/magic_auth_code_session_authenticate_request.rbi +6 -0
  71. data/rbi/workos/magic_auth_send_magic_auth_code_and_return_response.rbi +24 -0
  72. data/rbi/workos/password_session_authenticate_request.rbi +12 -0
  73. data/rbi/workos/pipes.rbi +104 -0
  74. data/rbi/workos/radar.rbi +2 -1
  75. data/rbi/workos/radar_email_challenge_code_session_authenticate_request.rbi +72 -0
  76. data/rbi/workos/radar_sms_challenge_code_session_authenticate_request.rbi +78 -0
  77. data/rbi/workos/radar_standalone_assess_request.rbi +6 -0
  78. data/rbi/workos/send_radar_sms_challenge.rbi +48 -0
  79. data/rbi/workos/send_radar_sms_challenge_response.rbi +30 -0
  80. data/rbi/workos/update_custom_provider_definition.rbi +84 -0
  81. data/rbi/workos/update_data_integration.rbi +48 -0
  82. data/rbi/workos/user_create_response.rbi +24 -0
  83. data/rbi/workos/user_management.rbi +47 -5
  84. data/rbi/workos/user_role_assignment.rbi +6 -0
  85. data/rbi/workos/user_role_assignment_source.rbi +30 -0
  86. data/test/workos/test_admin_portal_model_round_trip.rb +33 -0
  87. data/test/workos/test_audit_logs_model_round_trip.rb +218 -0
  88. data/test/workos/test_authorization_model_round_trip.rb +456 -0
  89. data/test/workos/test_connect_model_round_trip.rb +30 -0
  90. data/test/workos/test_groups_model_round_trip.rb +33 -0
  91. data/test/workos/test_model_round_trip.rb +2 -7857
  92. data/test/workos/test_organizations_model_round_trip.rb +29 -0
  93. data/test/workos/test_pipes.rb +72 -0
  94. data/test/workos/test_pipes_model_round_trip.rb +389 -0
  95. data/test/workos/test_radar_model_round_trip.rb +85 -0
  96. data/test/workos/test_shared_model_round_trip.rb +92 -0
  97. data/test/workos/test_user_management.rb +24 -0
  98. data/test/workos/test_user_management_model_round_trip.rb +1048 -0
  99. data/test/workos/test_webhooks_model_round_trip.rb +53 -0
  100. metadata +62 -1
@@ -0,0 +1,1048 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is auto-generated by oagen. Do not edit.
4
+
5
+ require "test_helper"
6
+
7
+ class UserManagementModelRoundTripTest < Minitest::Test
8
+ def test_create_cors_origin_round_trip
9
+ fixture = {
10
+ "origin" => "stub"
11
+ }
12
+ model = WorkOS::CreateCORSOrigin.new(fixture.to_json)
13
+ json = model.to_h
14
+ assert_kind_of Hash, json
15
+ assert_equal fixture["origin"], json[:origin]
16
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
17
+ end
18
+
19
+ def test_update_jwt_template_round_trip
20
+ fixture = {
21
+ "content" => "stub"
22
+ }
23
+ model = WorkOS::UpdateJWTTemplate.new(fixture.to_json)
24
+ json = model.to_h
25
+ assert_kind_of Hash, json
26
+ assert_equal fixture["content"], json[:content]
27
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
28
+ end
29
+
30
+ def test_send_radar_sms_challenge_round_trip
31
+ fixture = {
32
+ "user_id" => "stub",
33
+ "pending_authentication_token" => "stub",
34
+ "phone_number" => "stub",
35
+ "ip_address" => "stub",
36
+ "user_agent" => "stub"
37
+ }
38
+ model = WorkOS::SendRadarSmsChallenge.new(fixture.to_json)
39
+ json = model.to_h
40
+ assert_kind_of Hash, json
41
+ assert_equal fixture["user_id"], json[:user_id]
42
+ assert_equal fixture["pending_authentication_token"], json[:pending_authentication_token]
43
+ assert_equal fixture["phone_number"], json[:phone_number]
44
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
45
+ end
46
+
47
+ def test_create_redirect_uri_round_trip
48
+ fixture = {
49
+ "uri" => "stub"
50
+ }
51
+ model = WorkOS::CreateRedirectUri.new(fixture.to_json)
52
+ json = model.to_h
53
+ assert_kind_of Hash, json
54
+ assert_equal fixture["uri"], json[:uri]
55
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
56
+ end
57
+
58
+ def test_create_magic_code_and_return_round_trip
59
+ fixture = {
60
+ "email" => "stub",
61
+ "invitation_token" => "stub",
62
+ "ip_address" => "stub",
63
+ "user_agent" => "stub",
64
+ "radar_auth_attempt_id" => "stub",
65
+ "signals_id" => "stub"
66
+ }
67
+ model = WorkOS::CreateMagicCodeAndReturn.new(fixture.to_json)
68
+ json = model.to_h
69
+ assert_kind_of Hash, json
70
+ assert_equal fixture["email"], json[:email]
71
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
72
+ end
73
+
74
+ def test_create_user_invite_options_round_trip
75
+ fixture = {
76
+ "email" => "stub",
77
+ "organization_id" => "stub",
78
+ "role_slug" => "stub",
79
+ "expires_in_days" => 1,
80
+ "inviter_user_id" => "stub",
81
+ "locale" => "stub"
82
+ }
83
+ model = WorkOS::CreateUserInviteOptions.new(fixture.to_json)
84
+ json = model.to_h
85
+ assert_kind_of Hash, json
86
+ assert_equal fixture["email"], json[:email]
87
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
88
+ end
89
+
90
+ def test_resend_user_invite_options_round_trip
91
+ fixture = {
92
+ "locale" => "stub"
93
+ }
94
+ model = WorkOS::ResendUserInviteOptions.new(fixture.to_json)
95
+ json = model.to_h
96
+ assert_kind_of Hash, json
97
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
98
+ end
99
+
100
+ def test_create_user_api_key_round_trip
101
+ fixture = {
102
+ "name" => "stub",
103
+ "organization_id" => "stub",
104
+ "permissions" => [],
105
+ "expires_at" => "stub"
106
+ }
107
+ model = WorkOS::CreateUserApiKey.new(fixture.to_json)
108
+ json = model.to_h
109
+ assert_kind_of Hash, json
110
+ assert_equal fixture["name"], json[:name]
111
+ assert_equal fixture["organization_id"], json[:organization_id]
112
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
113
+ end
114
+
115
+ def test_create_user_round_trip
116
+ fixture = {
117
+ "email" => "stub",
118
+ "first_name" => nil,
119
+ "last_name" => nil,
120
+ "name" => nil,
121
+ "email_verified" => nil,
122
+ "metadata" => nil,
123
+ "external_id" => nil,
124
+ "ip_address" => nil,
125
+ "user_agent" => nil,
126
+ "signals_id" => "stub",
127
+ "password" => nil,
128
+ "password_hash" => "stub",
129
+ "password_hash_type" => "stub"
130
+ }
131
+ model = WorkOS::CreateUser.new(fixture.to_json)
132
+ json = model.to_h
133
+ assert_kind_of Hash, json
134
+ assert_equal fixture["email"], json[:email]
135
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
136
+ end
137
+
138
+ def test_update_user_round_trip
139
+ fixture = {
140
+ "email" => "stub",
141
+ "first_name" => "stub",
142
+ "last_name" => "stub",
143
+ "name" => "stub",
144
+ "email_verified" => true,
145
+ "metadata" => nil,
146
+ "external_id" => nil,
147
+ "locale" => nil,
148
+ "password" => "stub",
149
+ "password_hash" => "stub",
150
+ "password_hash_type" => "stub"
151
+ }
152
+ model = WorkOS::UpdateUser.new(fixture.to_json)
153
+ json = model.to_h
154
+ assert_kind_of Hash, json
155
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
156
+ end
157
+
158
+ def test_verify_email_address_round_trip
159
+ fixture = {
160
+ "code" => "stub"
161
+ }
162
+ model = WorkOS::VerifyEmailAddress.new(fixture.to_json)
163
+ json = model.to_h
164
+ assert_kind_of Hash, json
165
+ assert_equal fixture["code"], json[:code]
166
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
167
+ end
168
+
169
+ def test_create_password_reset_token_round_trip
170
+ fixture = {
171
+ "email" => "stub"
172
+ }
173
+ model = WorkOS::CreatePasswordResetToken.new(fixture.to_json)
174
+ json = model.to_h
175
+ assert_kind_of Hash, json
176
+ assert_equal fixture["email"], json[:email]
177
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
178
+ end
179
+
180
+ def test_create_password_reset_round_trip
181
+ fixture = {
182
+ "token" => "stub",
183
+ "new_password" => "stub"
184
+ }
185
+ model = WorkOS::CreatePasswordReset.new(fixture.to_json)
186
+ json = model.to_h
187
+ assert_kind_of Hash, json
188
+ assert_equal fixture["token"], json[:token]
189
+ assert_equal fixture["new_password"], json[:new_password]
190
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
191
+ end
192
+
193
+ def test_send_email_change_round_trip
194
+ fixture = {
195
+ "new_email" => "stub"
196
+ }
197
+ model = WorkOS::SendEmailChange.new(fixture.to_json)
198
+ json = model.to_h
199
+ assert_kind_of Hash, json
200
+ assert_equal fixture["new_email"], json[:new_email]
201
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
202
+ end
203
+
204
+ def test_confirm_email_change_round_trip
205
+ fixture = {
206
+ "code" => "stub"
207
+ }
208
+ model = WorkOS::ConfirmEmailChange.new(fixture.to_json)
209
+ json = model.to_h
210
+ assert_kind_of Hash, json
211
+ assert_equal fixture["code"], json[:code]
212
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
213
+ end
214
+
215
+ def test_revoke_session_round_trip
216
+ fixture = {
217
+ "session_id" => "stub"
218
+ }
219
+ model = WorkOS::RevokeSession.new(fixture.to_json)
220
+ json = model.to_h
221
+ assert_kind_of Hash, json
222
+ assert_equal fixture["session_id"], json[:session_id]
223
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
224
+ end
225
+
226
+ def test_user_round_trip
227
+ fixture = {
228
+ "object" => "user",
229
+ "id" => "stub",
230
+ "first_name" => nil,
231
+ "last_name" => nil,
232
+ "name" => nil,
233
+ "profile_picture_url" => nil,
234
+ "email" => "stub",
235
+ "email_verified" => true,
236
+ "external_id" => nil,
237
+ "metadata" => {},
238
+ "last_sign_in_at" => nil,
239
+ "locale" => nil,
240
+ "created_at" => "stub",
241
+ "updated_at" => "stub"
242
+ }
243
+ model = WorkOS::User.new(fixture.to_json)
244
+ json = model.to_h
245
+ assert_kind_of Hash, json
246
+ assert_equal fixture["id"], json[:id]
247
+ assert_nil json[:first_name]
248
+ assert_nil json[:last_name]
249
+ assert_nil json[:profile_picture_url]
250
+ assert_equal fixture["email"], json[:email]
251
+ assert_equal fixture["email_verified"], json[:email_verified]
252
+ assert_nil json[:external_id]
253
+ assert_nil json[:last_sign_in_at]
254
+ assert_equal fixture["created_at"], json[:created_at]
255
+ assert_equal fixture["updated_at"], json[:updated_at]
256
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
257
+ end
258
+
259
+ def test_cors_origin_response_round_trip
260
+ fixture = {
261
+ "object" => "cors_origin",
262
+ "id" => "stub",
263
+ "origin" => "stub",
264
+ "created_at" => "stub",
265
+ "updated_at" => "stub"
266
+ }
267
+ model = WorkOS::CORSOriginResponse.new(fixture.to_json)
268
+ json = model.to_h
269
+ assert_kind_of Hash, json
270
+ assert_equal fixture["id"], json[:id]
271
+ assert_equal fixture["origin"], json[:origin]
272
+ assert_equal fixture["created_at"], json[:created_at]
273
+ assert_equal fixture["updated_at"], json[:updated_at]
274
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
275
+ end
276
+
277
+ def test_send_radar_sms_challenge_response_round_trip
278
+ fixture = {
279
+ "verification_id" => "stub",
280
+ "phone_number" => "stub"
281
+ }
282
+ model = WorkOS::SendRadarSmsChallengeResponse.new(fixture.to_json)
283
+ json = model.to_h
284
+ assert_kind_of Hash, json
285
+ assert_equal fixture["verification_id"], json[:verification_id]
286
+ assert_equal fixture["phone_number"], json[:phone_number]
287
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
288
+ end
289
+
290
+ def test_redirect_uri_round_trip
291
+ fixture = {
292
+ "object" => "redirect_uri",
293
+ "id" => "stub",
294
+ "uri" => "stub",
295
+ "default" => true,
296
+ "created_at" => "stub",
297
+ "updated_at" => "stub"
298
+ }
299
+ model = WorkOS::RedirectUri.new(fixture.to_json)
300
+ json = model.to_h
301
+ assert_kind_of Hash, json
302
+ assert_equal fixture["id"], json[:id]
303
+ assert_equal fixture["uri"], json[:uri]
304
+ assert_equal fixture["default"], json[:default]
305
+ assert_equal fixture["created_at"], json[:created_at]
306
+ assert_equal fixture["updated_at"], json[:updated_at]
307
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
308
+ end
309
+
310
+ def test_magic_auth_round_trip
311
+ fixture = {
312
+ "object" => "magic_auth",
313
+ "id" => "stub",
314
+ "user_id" => "stub",
315
+ "email" => "stub",
316
+ "expires_at" => "stub",
317
+ "created_at" => "stub",
318
+ "updated_at" => "stub",
319
+ "code" => "stub"
320
+ }
321
+ model = WorkOS::MagicAuth.new(fixture.to_json)
322
+ json = model.to_h
323
+ assert_kind_of Hash, json
324
+ assert_equal fixture["id"], json[:id]
325
+ assert_equal fixture["user_id"], json[:user_id]
326
+ assert_equal fixture["email"], json[:email]
327
+ assert_equal fixture["expires_at"], json[:expires_at]
328
+ assert_equal fixture["created_at"], json[:created_at]
329
+ assert_equal fixture["updated_at"], json[:updated_at]
330
+ assert_equal fixture["code"], json[:code]
331
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
332
+ end
333
+
334
+ def test_user_invite_round_trip
335
+ fixture = {
336
+ "object" => "invitation",
337
+ "id" => "stub",
338
+ "email" => "stub",
339
+ "state" => "stub",
340
+ "accepted_at" => nil,
341
+ "revoked_at" => nil,
342
+ "expires_at" => "stub",
343
+ "organization_id" => nil,
344
+ "inviter_user_id" => nil,
345
+ "accepted_user_id" => nil,
346
+ "role_slug" => nil,
347
+ "created_at" => "stub",
348
+ "updated_at" => "stub",
349
+ "token" => "stub",
350
+ "accept_invitation_url" => "stub"
351
+ }
352
+ model = WorkOS::UserInvite.new(fixture.to_json)
353
+ json = model.to_h
354
+ assert_kind_of Hash, json
355
+ assert_equal fixture["id"], json[:id]
356
+ assert_equal fixture["email"], json[:email]
357
+ assert_nil json[:accepted_at]
358
+ assert_nil json[:revoked_at]
359
+ assert_equal fixture["expires_at"], json[:expires_at]
360
+ assert_nil json[:organization_id]
361
+ assert_nil json[:inviter_user_id]
362
+ assert_nil json[:accepted_user_id]
363
+ assert_nil json[:role_slug]
364
+ assert_equal fixture["created_at"], json[:created_at]
365
+ assert_equal fixture["updated_at"], json[:updated_at]
366
+ assert_equal fixture["token"], json[:token]
367
+ assert_equal fixture["accept_invitation_url"], json[:accept_invitation_url]
368
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
369
+ end
370
+
371
+ def test_user_api_key_round_trip
372
+ fixture = {
373
+ "object" => "api_key",
374
+ "id" => "stub",
375
+ "owner" => {},
376
+ "name" => "stub",
377
+ "obfuscated_value" => "stub",
378
+ "last_used_at" => nil,
379
+ "expires_at" => nil,
380
+ "permissions" => [],
381
+ "created_at" => "stub",
382
+ "updated_at" => "stub"
383
+ }
384
+ model = WorkOS::UserApiKey.new(fixture.to_json)
385
+ json = model.to_h
386
+ assert_kind_of Hash, json
387
+ assert_equal fixture["id"], json[:id]
388
+ assert_equal fixture["name"], json[:name]
389
+ assert_equal fixture["obfuscated_value"], json[:obfuscated_value]
390
+ assert_nil json[:last_used_at]
391
+ assert_nil json[:expires_at]
392
+ assert_equal fixture["created_at"], json[:created_at]
393
+ assert_equal fixture["updated_at"], json[:updated_at]
394
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
395
+ end
396
+
397
+ def test_user_api_key_with_value_round_trip
398
+ fixture = {
399
+ "object" => "api_key",
400
+ "id" => "stub",
401
+ "owner" => {},
402
+ "name" => "stub",
403
+ "obfuscated_value" => "stub",
404
+ "last_used_at" => nil,
405
+ "expires_at" => nil,
406
+ "permissions" => [],
407
+ "created_at" => "stub",
408
+ "updated_at" => "stub",
409
+ "value" => "stub"
410
+ }
411
+ model = WorkOS::UserApiKeyWithValue.new(fixture.to_json)
412
+ json = model.to_h
413
+ assert_kind_of Hash, json
414
+ assert_equal fixture["id"], json[:id]
415
+ assert_equal fixture["name"], json[:name]
416
+ assert_equal fixture["obfuscated_value"], json[:obfuscated_value]
417
+ assert_nil json[:last_used_at]
418
+ assert_nil json[:expires_at]
419
+ assert_equal fixture["created_at"], json[:created_at]
420
+ assert_equal fixture["updated_at"], json[:updated_at]
421
+ assert_equal fixture["value"], json[:value]
422
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
423
+ end
424
+
425
+ def test_email_verification_round_trip
426
+ fixture = {
427
+ "object" => "email_verification",
428
+ "id" => "stub",
429
+ "user_id" => "stub",
430
+ "email" => "stub",
431
+ "expires_at" => "stub",
432
+ "created_at" => "stub",
433
+ "updated_at" => "stub",
434
+ "code" => "stub"
435
+ }
436
+ model = WorkOS::EmailVerification.new(fixture.to_json)
437
+ json = model.to_h
438
+ assert_kind_of Hash, json
439
+ assert_equal fixture["id"], json[:id]
440
+ assert_equal fixture["user_id"], json[:user_id]
441
+ assert_equal fixture["email"], json[:email]
442
+ assert_equal fixture["expires_at"], json[:expires_at]
443
+ assert_equal fixture["created_at"], json[:created_at]
444
+ assert_equal fixture["updated_at"], json[:updated_at]
445
+ assert_equal fixture["code"], json[:code]
446
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
447
+ end
448
+
449
+ def test_send_verification_email_response_round_trip
450
+ fixture = {
451
+ "user" => {}
452
+ }
453
+ model = WorkOS::SendVerificationEmailResponse.new(fixture.to_json)
454
+ json = model.to_h
455
+ assert_kind_of Hash, json
456
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
457
+ end
458
+
459
+ def test_verify_email_response_round_trip
460
+ fixture = {
461
+ "user" => {}
462
+ }
463
+ model = WorkOS::VerifyEmailResponse.new(fixture.to_json)
464
+ json = model.to_h
465
+ assert_kind_of Hash, json
466
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
467
+ end
468
+
469
+ def test_password_reset_round_trip
470
+ fixture = {
471
+ "object" => "password_reset",
472
+ "id" => "stub",
473
+ "user_id" => "stub",
474
+ "email" => "stub",
475
+ "expires_at" => "stub",
476
+ "created_at" => "stub",
477
+ "password_reset_token" => "stub",
478
+ "password_reset_url" => "stub"
479
+ }
480
+ model = WorkOS::PasswordReset.new(fixture.to_json)
481
+ json = model.to_h
482
+ assert_kind_of Hash, json
483
+ assert_equal fixture["id"], json[:id]
484
+ assert_equal fixture["user_id"], json[:user_id]
485
+ assert_equal fixture["email"], json[:email]
486
+ assert_equal fixture["expires_at"], json[:expires_at]
487
+ assert_equal fixture["created_at"], json[:created_at]
488
+ assert_equal fixture["password_reset_token"], json[:password_reset_token]
489
+ assert_equal fixture["password_reset_url"], json[:password_reset_url]
490
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
491
+ end
492
+
493
+ def test_reset_password_response_round_trip
494
+ fixture = {
495
+ "user" => {}
496
+ }
497
+ model = WorkOS::ResetPasswordResponse.new(fixture.to_json)
498
+ json = model.to_h
499
+ assert_kind_of Hash, json
500
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
501
+ end
502
+
503
+ def test_email_change_round_trip
504
+ fixture = {
505
+ "object" => "email_change",
506
+ "user" => {},
507
+ "new_email" => "stub",
508
+ "expires_at" => "stub",
509
+ "created_at" => "stub"
510
+ }
511
+ model = WorkOS::EmailChange.new(fixture.to_json)
512
+ json = model.to_h
513
+ assert_kind_of Hash, json
514
+ assert_equal fixture["new_email"], json[:new_email]
515
+ assert_equal fixture["expires_at"], json[:expires_at]
516
+ assert_equal fixture["created_at"], json[:created_at]
517
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
518
+ end
519
+
520
+ def test_authenticate_response_round_trip
521
+ fixture = {
522
+ "user" => {},
523
+ "organization_id" => "stub",
524
+ "authkit_authorization_code" => "stub",
525
+ "access_token" => "stub",
526
+ "refresh_token" => "stub",
527
+ "authentication_method" => "stub",
528
+ "impersonator" => {},
529
+ "oauth_tokens" => {}
530
+ }
531
+ model = WorkOS::AuthenticateResponse.new(fixture.to_json)
532
+ json = model.to_h
533
+ assert_kind_of Hash, json
534
+ assert_equal fixture["access_token"], json[:access_token]
535
+ assert_equal fixture["refresh_token"], json[:refresh_token]
536
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
537
+ end
538
+
539
+ def test_device_authorization_response_round_trip
540
+ fixture = {
541
+ "device_code" => "stub",
542
+ "user_code" => "stub",
543
+ "verification_uri" => "stub",
544
+ "verification_uri_complete" => "stub",
545
+ "expires_in" => 1.0,
546
+ "interval" => 1.0
547
+ }
548
+ model = WorkOS::DeviceAuthorizationResponse.new(fixture.to_json)
549
+ json = model.to_h
550
+ assert_kind_of Hash, json
551
+ assert_equal fixture["device_code"], json[:device_code]
552
+ assert_equal fixture["user_code"], json[:user_code]
553
+ assert_equal fixture["verification_uri"], json[:verification_uri]
554
+ assert_equal fixture["expires_in"], json[:expires_in]
555
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
556
+ end
557
+
558
+ def test_jwks_response_round_trip
559
+ fixture = {
560
+ "keys" => []
561
+ }
562
+ model = WorkOS::JwksResponse.new(fixture.to_json)
563
+ json = model.to_h
564
+ assert_kind_of Hash, json
565
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
566
+ end
567
+
568
+ def test_jwt_template_response_round_trip
569
+ fixture = {
570
+ "object" => "jwt_template",
571
+ "content" => "stub",
572
+ "created_at" => "stub",
573
+ "updated_at" => "stub"
574
+ }
575
+ model = WorkOS::JWTTemplateResponse.new(fixture.to_json)
576
+ json = model.to_h
577
+ assert_kind_of Hash, json
578
+ assert_equal fixture["content"], json[:content]
579
+ assert_equal fixture["created_at"], json[:created_at]
580
+ assert_equal fixture["updated_at"], json[:updated_at]
581
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
582
+ end
583
+
584
+ def test_jwks_response_keys_round_trip
585
+ fixture = {
586
+ "alg" => "RS256",
587
+ "kty" => "RSA",
588
+ "use" => "sig",
589
+ "x5c" => [],
590
+ "n" => "stub",
591
+ "e" => "stub",
592
+ "kid" => "stub",
593
+ "x5t#S256" => "stub"
594
+ }
595
+ model = WorkOS::JwksResponseKeys.new(fixture.to_json)
596
+ json = model.to_h
597
+ assert_kind_of Hash, json
598
+ assert_equal fixture["n"], json[:n]
599
+ assert_equal fixture["e"], json[:e]
600
+ assert_equal fixture["kid"], json[:kid]
601
+ assert_equal fixture["x5t#S256"], json["x5t#S256"]
602
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
603
+ end
604
+
605
+ def test_authenticate_response_impersonator_round_trip
606
+ fixture = {
607
+ "email" => "stub",
608
+ "reason" => nil
609
+ }
610
+ model = WorkOS::AuthenticateResponseImpersonator.new(fixture.to_json)
611
+ json = model.to_h
612
+ assert_kind_of Hash, json
613
+ assert_equal fixture["email"], json[:email]
614
+ assert_nil json[:reason]
615
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
616
+ end
617
+
618
+ def test_authenticate_response_oauth_token_round_trip
619
+ fixture = {
620
+ "provider" => "stub",
621
+ "refresh_token" => "stub",
622
+ "access_token" => "stub",
623
+ "expires_at" => 1,
624
+ "scopes" => []
625
+ }
626
+ model = WorkOS::AuthenticateResponseOAuthToken.new(fixture.to_json)
627
+ json = model.to_h
628
+ assert_kind_of Hash, json
629
+ assert_equal fixture["provider"], json[:provider]
630
+ assert_equal fixture["refresh_token"], json[:refresh_token]
631
+ assert_equal fixture["access_token"], json[:access_token]
632
+ assert_equal fixture["expires_at"], json[:expires_at]
633
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
634
+ end
635
+
636
+ def test_user_api_key_with_value_owner_round_trip
637
+ fixture = {
638
+ "type" => "user",
639
+ "id" => "stub",
640
+ "organization_id" => "stub"
641
+ }
642
+ model = WorkOS::UserApiKeyWithValueOwner.new(fixture.to_json)
643
+ json = model.to_h
644
+ assert_kind_of Hash, json
645
+ assert_equal fixture["id"], json[:id]
646
+ assert_equal fixture["organization_id"], json[:organization_id]
647
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
648
+ end
649
+
650
+ def test_user_api_key_owner_round_trip
651
+ fixture = {
652
+ "type" => "user",
653
+ "id" => "stub",
654
+ "organization_id" => "stub"
655
+ }
656
+ model = WorkOS::UserApiKeyOwner.new(fixture.to_json)
657
+ json = model.to_h
658
+ assert_kind_of Hash, json
659
+ assert_equal fixture["id"], json[:id]
660
+ assert_equal fixture["organization_id"], json[:organization_id]
661
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
662
+ end
663
+
664
+ def test_authorization_code_session_authenticate_request_round_trip
665
+ fixture = {
666
+ "client_id" => "stub",
667
+ "client_secret" => "stub",
668
+ "grant_type" => "authorization_code",
669
+ "code" => "stub",
670
+ "code_verifier" => "stub",
671
+ "invitation_token" => "stub",
672
+ "ip_address" => "stub",
673
+ "device_id" => "stub",
674
+ "user_agent" => "stub",
675
+ "signals_id" => "stub"
676
+ }
677
+ model = WorkOS::AuthorizationCodeSessionAuthenticateRequest.new(fixture.to_json)
678
+ json = model.to_h
679
+ assert_kind_of Hash, json
680
+ assert_equal fixture["client_id"], json[:client_id]
681
+ assert_equal fixture["code"], json[:code]
682
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
683
+ end
684
+
685
+ def test_password_session_authenticate_request_round_trip
686
+ fixture = {
687
+ "client_id" => "stub",
688
+ "client_secret" => "stub",
689
+ "grant_type" => "password",
690
+ "email" => "stub",
691
+ "password" => "stub",
692
+ "invitation_token" => "stub",
693
+ "ip_address" => "stub",
694
+ "device_id" => "stub",
695
+ "user_agent" => "stub",
696
+ "signals_id" => "stub",
697
+ "radar_auth_attempt_id" => "stub"
698
+ }
699
+ model = WorkOS::PasswordSessionAuthenticateRequest.new(fixture.to_json)
700
+ json = model.to_h
701
+ assert_kind_of Hash, json
702
+ assert_equal fixture["client_id"], json[:client_id]
703
+ assert_equal fixture["client_secret"], json[:client_secret]
704
+ assert_equal fixture["email"], json[:email]
705
+ assert_equal fixture["password"], json[:password]
706
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
707
+ end
708
+
709
+ def test_refresh_token_session_authenticate_request_round_trip
710
+ fixture = {
711
+ "client_id" => "stub",
712
+ "client_secret" => "stub",
713
+ "grant_type" => "refresh_token",
714
+ "refresh_token" => "stub",
715
+ "organization_id" => "stub",
716
+ "ip_address" => "stub",
717
+ "device_id" => "stub",
718
+ "user_agent" => "stub"
719
+ }
720
+ model = WorkOS::RefreshTokenSessionAuthenticateRequest.new(fixture.to_json)
721
+ json = model.to_h
722
+ assert_kind_of Hash, json
723
+ assert_equal fixture["client_id"], json[:client_id]
724
+ assert_equal fixture["refresh_token"], json[:refresh_token]
725
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
726
+ end
727
+
728
+ def test_magic_auth_code_session_authenticate_request_round_trip
729
+ fixture = {
730
+ "client_id" => "stub",
731
+ "client_secret" => "stub",
732
+ "grant_type" => "urn:workos:oauth:grant-type:magic-auth:code",
733
+ "code" => "stub",
734
+ "email" => "stub",
735
+ "invitation_token" => "stub",
736
+ "ip_address" => "stub",
737
+ "device_id" => "stub",
738
+ "user_agent" => "stub",
739
+ "radar_auth_attempt_id" => "stub"
740
+ }
741
+ model = WorkOS::MagicAuthCodeSessionAuthenticateRequest.new(fixture.to_json)
742
+ json = model.to_h
743
+ assert_kind_of Hash, json
744
+ assert_equal fixture["client_id"], json[:client_id]
745
+ assert_equal fixture["client_secret"], json[:client_secret]
746
+ assert_equal fixture["code"], json[:code]
747
+ assert_equal fixture["email"], json[:email]
748
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
749
+ end
750
+
751
+ def test_email_verification_code_session_authenticate_request_round_trip
752
+ fixture = {
753
+ "client_id" => "stub",
754
+ "client_secret" => "stub",
755
+ "grant_type" => "urn:workos:oauth:grant-type:email-verification:code",
756
+ "code" => "stub",
757
+ "pending_authentication_token" => "stub",
758
+ "ip_address" => "stub",
759
+ "device_id" => "stub",
760
+ "user_agent" => "stub"
761
+ }
762
+ model = WorkOS::EmailVerificationCodeSessionAuthenticateRequest.new(fixture.to_json)
763
+ json = model.to_h
764
+ assert_kind_of Hash, json
765
+ assert_equal fixture["client_id"], json[:client_id]
766
+ assert_equal fixture["client_secret"], json[:client_secret]
767
+ assert_equal fixture["code"], json[:code]
768
+ assert_equal fixture["pending_authentication_token"], json[:pending_authentication_token]
769
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
770
+ end
771
+
772
+ def test_mfa_totp_session_authenticate_request_round_trip
773
+ fixture = {
774
+ "client_id" => "stub",
775
+ "client_secret" => "stub",
776
+ "grant_type" => "urn:workos:oauth:grant-type:mfa-totp",
777
+ "code" => "stub",
778
+ "pending_authentication_token" => "stub",
779
+ "authentication_challenge_id" => "stub",
780
+ "ip_address" => "stub",
781
+ "device_id" => "stub",
782
+ "user_agent" => "stub"
783
+ }
784
+ model = WorkOS::MFATotpSessionAuthenticateRequest.new(fixture.to_json)
785
+ json = model.to_h
786
+ assert_kind_of Hash, json
787
+ assert_equal fixture["client_id"], json[:client_id]
788
+ assert_equal fixture["client_secret"], json[:client_secret]
789
+ assert_equal fixture["code"], json[:code]
790
+ assert_equal fixture["pending_authentication_token"], json[:pending_authentication_token]
791
+ assert_equal fixture["authentication_challenge_id"], json[:authentication_challenge_id]
792
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
793
+ end
794
+
795
+ def test_organization_selection_session_authenticate_request_round_trip
796
+ fixture = {
797
+ "client_id" => "stub",
798
+ "client_secret" => "stub",
799
+ "grant_type" => "urn:workos:oauth:grant-type:organization-selection",
800
+ "pending_authentication_token" => "stub",
801
+ "organization_id" => "stub",
802
+ "ip_address" => "stub",
803
+ "device_id" => "stub",
804
+ "user_agent" => "stub"
805
+ }
806
+ model = WorkOS::OrganizationSelectionSessionAuthenticateRequest.new(fixture.to_json)
807
+ json = model.to_h
808
+ assert_kind_of Hash, json
809
+ assert_equal fixture["client_id"], json[:client_id]
810
+ assert_equal fixture["client_secret"], json[:client_secret]
811
+ assert_equal fixture["pending_authentication_token"], json[:pending_authentication_token]
812
+ assert_equal fixture["organization_id"], json[:organization_id]
813
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
814
+ end
815
+
816
+ def test_radar_email_challenge_code_session_authenticate_request_round_trip
817
+ fixture = {
818
+ "client_id" => "stub",
819
+ "client_secret" => "stub",
820
+ "grant_type" => "urn:workos:oauth:grant-type:radar-email-challenge:code",
821
+ "code" => "stub",
822
+ "radar_challenge_id" => "stub",
823
+ "pending_authentication_token" => "stub",
824
+ "ip_address" => "stub",
825
+ "device_id" => "stub",
826
+ "user_agent" => "stub"
827
+ }
828
+ model = WorkOS::RadarEmailChallengeCodeSessionAuthenticateRequest.new(fixture.to_json)
829
+ json = model.to_h
830
+ assert_kind_of Hash, json
831
+ assert_equal fixture["client_id"], json[:client_id]
832
+ assert_equal fixture["client_secret"], json[:client_secret]
833
+ assert_equal fixture["code"], json[:code]
834
+ assert_equal fixture["radar_challenge_id"], json[:radar_challenge_id]
835
+ assert_equal fixture["pending_authentication_token"], json[:pending_authentication_token]
836
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
837
+ end
838
+
839
+ def test_radar_sms_challenge_code_session_authenticate_request_round_trip
840
+ fixture = {
841
+ "client_id" => "stub",
842
+ "client_secret" => "stub",
843
+ "grant_type" => "urn:workos:oauth:grant-type:radar-sms-challenge:code",
844
+ "code" => "stub",
845
+ "verification_id" => "stub",
846
+ "phone_number" => "stub",
847
+ "pending_authentication_token" => "stub",
848
+ "ip_address" => "stub",
849
+ "device_id" => "stub",
850
+ "user_agent" => "stub"
851
+ }
852
+ model = WorkOS::RadarSmsChallengeCodeSessionAuthenticateRequest.new(fixture.to_json)
853
+ json = model.to_h
854
+ assert_kind_of Hash, json
855
+ assert_equal fixture["client_id"], json[:client_id]
856
+ assert_equal fixture["client_secret"], json[:client_secret]
857
+ assert_equal fixture["code"], json[:code]
858
+ assert_equal fixture["verification_id"], json[:verification_id]
859
+ assert_equal fixture["phone_number"], json[:phone_number]
860
+ assert_equal fixture["pending_authentication_token"], json[:pending_authentication_token]
861
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
862
+ end
863
+
864
+ def test_device_code_session_authenticate_request_round_trip
865
+ fixture = {
866
+ "client_id" => "stub",
867
+ "grant_type" => "urn:ietf:params:oauth:grant-type:device_code",
868
+ "device_code" => "stub",
869
+ "ip_address" => "stub",
870
+ "device_id" => "stub",
871
+ "user_agent" => "stub"
872
+ }
873
+ model = WorkOS::DeviceCodeSessionAuthenticateRequest.new(fixture.to_json)
874
+ json = model.to_h
875
+ assert_kind_of Hash, json
876
+ assert_equal fixture["client_id"], json[:client_id]
877
+ assert_equal fixture["device_code"], json[:device_code]
878
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
879
+ end
880
+
881
+ def test_sso_device_authorization_request_round_trip
882
+ fixture = {
883
+ "client_id" => "stub"
884
+ }
885
+ model = WorkOS::SSODeviceAuthorizationRequest.new(fixture.to_json)
886
+ json = model.to_h
887
+ assert_kind_of Hash, json
888
+ assert_equal fixture["client_id"], json[:client_id]
889
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
890
+ end
891
+
892
+ def test_invitation_round_trip
893
+ fixture = {
894
+ "object" => "invitation",
895
+ "id" => "stub",
896
+ "email" => "stub",
897
+ "state" => "stub",
898
+ "accepted_at" => nil,
899
+ "revoked_at" => nil,
900
+ "expires_at" => "stub",
901
+ "organization_id" => nil,
902
+ "inviter_user_id" => nil,
903
+ "accepted_user_id" => nil,
904
+ "role_slug" => nil,
905
+ "created_at" => "stub",
906
+ "updated_at" => "stub",
907
+ "token" => "stub",
908
+ "accept_invitation_url" => "stub"
909
+ }
910
+ model = WorkOS::Invitation.new(fixture.to_json)
911
+ json = model.to_h
912
+ assert_kind_of Hash, json
913
+ assert_equal fixture["id"], json[:id]
914
+ assert_equal fixture["email"], json[:email]
915
+ assert_nil json[:accepted_at]
916
+ assert_nil json[:revoked_at]
917
+ assert_equal fixture["expires_at"], json[:expires_at]
918
+ assert_nil json[:organization_id]
919
+ assert_nil json[:inviter_user_id]
920
+ assert_nil json[:accepted_user_id]
921
+ assert_nil json[:role_slug]
922
+ assert_equal fixture["created_at"], json[:created_at]
923
+ assert_equal fixture["updated_at"], json[:updated_at]
924
+ assert_equal fixture["token"], json[:token]
925
+ assert_equal fixture["accept_invitation_url"], json[:accept_invitation_url]
926
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
927
+ end
928
+
929
+ def test_magic_auth_send_magic_auth_code_and_return_response_round_trip
930
+ fixture = {
931
+ "radar_auth_attempt_id" => "stub"
932
+ }
933
+ model = WorkOS::MagicAuthSendMagicAuthCodeAndReturnResponse.new(fixture.to_json)
934
+ json = model.to_h
935
+ assert_kind_of Hash, json
936
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
937
+ end
938
+
939
+ def test_user_create_response_round_trip
940
+ fixture = {
941
+ "radar_auth_attempt_id" => "stub"
942
+ }
943
+ model = WorkOS::UserCreateResponse.new(fixture.to_json)
944
+ json = model.to_h
945
+ assert_kind_of Hash, json
946
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
947
+ end
948
+
949
+ def test_email_change_confirmation_round_trip
950
+ fixture = {
951
+ "object" => "email_change_confirmation",
952
+ "user" => {}
953
+ }
954
+ model = WorkOS::EmailChangeConfirmation.new(fixture.to_json)
955
+ json = model.to_h
956
+ assert_kind_of Hash, json
957
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
958
+ end
959
+
960
+ def test_email_change_confirmation_user_round_trip
961
+ fixture = {
962
+ "object" => "user",
963
+ "id" => "stub",
964
+ "first_name" => nil,
965
+ "last_name" => nil,
966
+ "name" => nil,
967
+ "profile_picture_url" => nil,
968
+ "email" => "stub",
969
+ "email_verified" => true,
970
+ "external_id" => nil,
971
+ "metadata" => {},
972
+ "last_sign_in_at" => nil,
973
+ "locale" => nil,
974
+ "created_at" => "stub",
975
+ "updated_at" => "stub"
976
+ }
977
+ model = WorkOS::EmailChangeConfirmationUser.new(fixture.to_json)
978
+ json = model.to_h
979
+ assert_kind_of Hash, json
980
+ assert_equal fixture["id"], json[:id]
981
+ assert_nil json[:first_name]
982
+ assert_nil json[:last_name]
983
+ assert_nil json[:profile_picture_url]
984
+ assert_equal fixture["email"], json[:email]
985
+ assert_equal fixture["email_verified"], json[:email_verified]
986
+ assert_nil json[:external_id]
987
+ assert_nil json[:last_sign_in_at]
988
+ assert_equal fixture["created_at"], json[:created_at]
989
+ assert_equal fixture["updated_at"], json[:updated_at]
990
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
991
+ end
992
+
993
+ def test_user_identities_get_item_round_trip
994
+ fixture = {
995
+ "idp_id" => "stub",
996
+ "type" => "OAuth",
997
+ "provider" => "stub"
998
+ }
999
+ model = WorkOS::UserIdentitiesGetItem.new(fixture.to_json)
1000
+ json = model.to_h
1001
+ assert_kind_of Hash, json
1002
+ assert_equal fixture["idp_id"], json[:idp_id]
1003
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
1004
+ end
1005
+
1006
+ def test_user_sessions_list_item_round_trip
1007
+ fixture = {
1008
+ "object" => "session",
1009
+ "id" => "stub",
1010
+ "impersonator" => {},
1011
+ "ip_address" => nil,
1012
+ "organization_id" => "stub",
1013
+ "user_agent" => nil,
1014
+ "user_id" => "stub",
1015
+ "auth_method" => "stub",
1016
+ "status" => "stub",
1017
+ "expires_at" => "stub",
1018
+ "ended_at" => nil,
1019
+ "created_at" => "stub",
1020
+ "updated_at" => "stub"
1021
+ }
1022
+ model = WorkOS::UserSessionsListItem.new(fixture.to_json)
1023
+ json = model.to_h
1024
+ assert_kind_of Hash, json
1025
+ assert_equal fixture["id"], json[:id]
1026
+ assert_nil json[:ip_address]
1027
+ assert_nil json[:user_agent]
1028
+ assert_equal fixture["user_id"], json[:user_id]
1029
+ assert_equal fixture["expires_at"], json[:expires_at]
1030
+ assert_nil json[:ended_at]
1031
+ assert_equal fixture["created_at"], json[:created_at]
1032
+ assert_equal fixture["updated_at"], json[:updated_at]
1033
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
1034
+ end
1035
+
1036
+ def test_user_sessions_impersonator_round_trip
1037
+ fixture = {
1038
+ "email" => "stub",
1039
+ "reason" => nil
1040
+ }
1041
+ model = WorkOS::UserSessionsImpersonator.new(fixture.to_json)
1042
+ json = model.to_h
1043
+ assert_kind_of Hash, json
1044
+ assert_equal fixture["email"], json[:email]
1045
+ assert_nil json[:reason]
1046
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
1047
+ end
1048
+ end