workos 10.2.0 → 10.3.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 (224) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/block-generated-edits.yml +1 -1
  3. data/.github/workflows/ci.yml +2 -2
  4. data/.github/workflows/docs.yml +2 -2
  5. data/.github/workflows/lint.yml +2 -2
  6. data/.github/workflows/release-please.yml +3 -3
  7. data/.github/workflows/release.yml +2 -2
  8. data/.last-synced-sha +1 -1
  9. data/.oagen-manifest.json +311 -0
  10. data/.release-please-manifest.json +1 -1
  11. data/CHANGELOG.md +161 -0
  12. data/Gemfile.lock +2 -2
  13. data/lib/workos/agents/agent_blueprint.rb +43 -0
  14. data/lib/workos/agents/agent_blueprint_invocable_by.rb +7 -0
  15. data/lib/workos/agents/agent_blueprint_session_setting.rb +25 -0
  16. data/lib/workos/agents/agent_blueprints_create_request.rb +31 -0
  17. data/lib/workos/agents/agent_blueprints_create_request_invocable_by.rb +22 -0
  18. data/lib/workos/agents/agent_blueprints_create_request_session_setting.rb +7 -0
  19. data/lib/workos/agents/agent_blueprints_token_mint_token_request.rb +34 -0
  20. data/lib/workos/agents/agent_blueprints_token_validate_token_request.rb +18 -0
  21. data/lib/workos/agents/agent_blueprints_update_request.rb +31 -0
  22. data/lib/workos/agents/agent_blueprints_update_request_invocable_by.rb +7 -0
  23. data/lib/workos/agents/agent_blueprints_update_request_session_setting.rb +25 -0
  24. data/lib/workos/agents/agent_instance.rb +40 -0
  25. data/lib/workos/agents/agent_instance_session.rb +40 -0
  26. data/lib/workos/agents/agent_token.rb +40 -0
  27. data/lib/workos/agents/agent_token_validation.rb +40 -0
  28. data/lib/workos/agents.rb +395 -0
  29. data/lib/workos/api_keys/validate_api_key.rb +1 -12
  30. data/lib/workos/audit_logs.rb +23 -5
  31. data/lib/workos/authorization.rb +3 -3
  32. data/lib/workos/base_client.rb +14 -1
  33. data/lib/workos/client.rb +4 -0
  34. data/lib/workos/inflections.rb +15 -0
  35. data/lib/workos/organizations/create_it_contact.rb +18 -0
  36. data/lib/workos/organizations/invite_it_contact.rb +18 -0
  37. data/lib/workos/organizations/it_contact.rb +31 -0
  38. data/lib/workos/organizations/it_contact_list.rb +25 -0
  39. data/lib/workos/organizations/organization_input.rb +10 -1
  40. data/lib/workos/organizations/update_audit_logs_retention.rb +13 -1
  41. data/lib/workos/organizations.rb +110 -1
  42. data/lib/workos/platform_teams/create_team.rb +22 -0
  43. data/lib/workos/platform_teams/team.rb +37 -0
  44. data/lib/workos/platform_teams.rb +58 -0
  45. data/lib/workos/shared/agent_blueprint_created.rb +34 -0
  46. data/lib/workos/shared/agent_blueprint_created_data.rb +43 -0
  47. data/lib/workos/shared/agent_blueprint_created_data_invocable_by.rb +22 -0
  48. data/lib/workos/shared/agent_blueprint_created_data_session_setting.rb +25 -0
  49. data/lib/workos/shared/agent_blueprint_deleted.rb +34 -0
  50. data/lib/workos/shared/agent_blueprint_deleted_data.rb +31 -0
  51. data/lib/workos/shared/agent_blueprint_updated.rb +34 -0
  52. data/lib/workos/shared/agent_blueprint_updated_data.rb +7 -0
  53. data/lib/workos/shared/agent_blueprint_updated_data_invocable_by.rb +7 -0
  54. data/lib/workos/shared/agent_blueprint_updated_data_session_setting.rb +7 -0
  55. data/lib/workos/shared/agent_instance_created.rb +34 -0
  56. data/lib/workos/shared/agent_instance_created_data.rb +40 -0
  57. data/lib/workos/shared/agent_instance_deleted.rb +34 -0
  58. data/lib/workos/shared/agent_instance_deleted_data.rb +40 -0
  59. data/lib/workos/shared/agent_instance_session_created.rb +34 -0
  60. data/lib/workos/shared/agent_instance_session_created_data.rb +43 -0
  61. data/lib/workos/shared/agent_instance_session_revoked.rb +34 -0
  62. data/lib/workos/shared/agent_instance_session_revoked_data.rb +40 -0
  63. data/lib/workos/shared/resource_export_completed.rb +34 -0
  64. data/lib/workos/shared/resource_export_completed_data.rb +22 -0
  65. data/lib/workos/shared/resource_export_created.rb +34 -0
  66. data/lib/workos/shared/resource_export_created_data.rb +22 -0
  67. data/lib/workos/shared/resource_export_downloaded.rb +34 -0
  68. data/lib/workos/shared/resource_export_downloaded_data.rb +22 -0
  69. data/lib/workos/shared/resource_export_failed.rb +34 -0
  70. data/lib/workos/shared/resource_export_failed_data.rb +22 -0
  71. data/lib/workos/shared/waitlist_user.rb +8 -5
  72. data/lib/workos/sso/create_connection.rb +37 -0
  73. data/lib/workos/sso/create_connection_attribute_maps.rb +22 -0
  74. data/lib/workos/sso/create_connection_key_pair.rb +22 -0
  75. data/lib/workos/sso/create_connection_oidc_options.rb +43 -0
  76. data/lib/workos/sso/create_connection_saml_options.rb +40 -0
  77. data/lib/workos/sso/create_connection_standard_attributes.rb +34 -0
  78. data/lib/workos/sso/create_saml_idp_signing_certificate.rb +18 -0
  79. data/lib/workos/sso/patch_connection.rb +34 -0
  80. data/lib/workos/sso/patch_connection_attribute_maps.rb +22 -0
  81. data/lib/workos/sso/patch_connection_oidc_options.rb +40 -0
  82. data/lib/workos/sso/patch_connection_saml_options.rb +31 -0
  83. data/lib/workos/sso/patch_connection_standard_attributes.rb +7 -0
  84. data/lib/workos/sso/saml_idp_signing_certificate.rb +34 -0
  85. data/lib/workos/sso/saml_idp_signing_certificate_list.rb +22 -0
  86. data/lib/workos/sso/saml_sp_encryption_certificate.rb +34 -0
  87. data/lib/workos/sso/saml_sp_encryption_certificate_list.rb +22 -0
  88. data/lib/workos/sso/saml_sp_signing_certificate.rb +34 -0
  89. data/lib/workos/sso/token_query.rb +11 -2
  90. data/lib/workos/sso.rb +305 -4
  91. data/lib/workos/types/agent_blueprints_token_mint_token_request_type.rb +15 -0
  92. data/lib/workos/types/agent_instance_created_data_type.rb +13 -0
  93. data/lib/workos/types/agent_instance_deleted_data_type.rb +9 -0
  94. data/lib/workos/types/agent_instance_session_status.rb +14 -0
  95. data/lib/workos/types/agent_instance_type.rb +9 -0
  96. data/lib/workos/types/authenticate_response_authentication_method.rb +1 -4
  97. data/lib/workos/types/connection_activated_data_connection_type.rb +1 -4
  98. data/lib/workos/types/connection_type.rb +1 -4
  99. data/lib/workos/types/connections_connection_type.rb +1 -4
  100. data/lib/workos/types/create_connection_oidc_options_id_token_signature_algorithm.rb +24 -0
  101. data/lib/workos/types/create_connection_oidc_options_token_authentication_method.rb +14 -0
  102. data/lib/workos/types/create_webhook_endpoint_events.rb +8 -1
  103. data/lib/workos/types/invite_it_contact_intents.rb +16 -0
  104. data/lib/workos/types/patch_connection_oidc_options_id_token_signature_algorithm.rb +9 -0
  105. data/lib/workos/types/patch_connection_oidc_options_token_authentication_method.rb +9 -0
  106. data/lib/workos/types/resource_export_completed_data_resource_type.rb +16 -0
  107. data/lib/workos/types/resource_export_created_data_resource_type.rb +9 -0
  108. data/lib/workos/types/resource_export_downloaded_data_resource_type.rb +9 -0
  109. data/lib/workos/types/resource_export_failed_data_resource_type.rb +9 -0
  110. data/lib/workos/types/session_created_data_status.rb +1 -6
  111. data/lib/workos/types/session_revoked_data_status.rb +1 -1
  112. data/lib/workos/types/sso_grant_type.rb +13 -0
  113. data/lib/workos/types/team_production_state.rb +15 -0
  114. data/lib/workos/types/token_query_grant_type.rb +9 -0
  115. data/lib/workos/types/update_audit_logs_retention_retention_period.rb +32 -0
  116. data/lib/workos/types/user_identities_get_item_provider.rb +1 -4
  117. data/lib/workos/types/user_management_waitlists_state.rb +14 -0
  118. data/lib/workos/types/user_sessions_status.rb +1 -1
  119. data/lib/workos/types/waitlist_entry_state.rb +9 -0
  120. data/lib/workos/types/waitlist_user_state.rb +1 -6
  121. data/lib/workos/user_management/authentication_oauth_failed_data.rb +5 -2
  122. data/lib/workos/user_management/authentication_oauth_succeeded_data.rb +5 -2
  123. data/lib/workos/user_management/create_password_reset_token.rb +1 -12
  124. data/lib/workos/user_management/create_waitlist_entry.rb +25 -0
  125. data/lib/workos/user_management/email_completion_session_authenticate_request.rb +43 -0
  126. data/lib/workos/user_management/waitlist.rb +28 -0
  127. data/lib/workos/user_management/waitlist_entry.rb +43 -0
  128. data/lib/workos/user_management.rb +176 -0
  129. data/lib/workos/version.rb +1 -1
  130. data/lib/workos.rb +1 -0
  131. data/rbi/workos/agent_blueprint.rbi +72 -0
  132. data/rbi/workos/agent_blueprint_created.rbi +54 -0
  133. data/rbi/workos/agent_blueprint_created_data.rbi +72 -0
  134. data/rbi/workos/agent_blueprint_created_data_invocable_by.rbi +30 -0
  135. data/rbi/workos/agent_blueprint_created_data_session_setting.rbi +36 -0
  136. data/rbi/workos/agent_blueprint_deleted.rbi +54 -0
  137. data/rbi/workos/agent_blueprint_deleted_data.rbi +48 -0
  138. data/rbi/workos/agent_blueprint_invocable_by.rbi +30 -0
  139. data/rbi/workos/agent_blueprint_session_setting.rbi +36 -0
  140. data/rbi/workos/agent_blueprint_updated.rbi +54 -0
  141. data/rbi/workos/agent_blueprint_updated_data.rbi +72 -0
  142. data/rbi/workos/agent_blueprint_updated_data_invocable_by.rbi +30 -0
  143. data/rbi/workos/agent_blueprint_updated_data_session_setting.rbi +36 -0
  144. data/rbi/workos/agent_blueprints_create_request.rbi +48 -0
  145. data/rbi/workos/agent_blueprints_create_request_invocable_by.rbi +30 -0
  146. data/rbi/workos/agent_blueprints_create_request_session_setting.rbi +36 -0
  147. data/rbi/workos/agent_blueprints_token_mint_token_request.rbi +54 -0
  148. data/rbi/workos/agent_blueprints_token_validate_token_request.rbi +24 -0
  149. data/rbi/workos/agent_blueprints_update_request.rbi +48 -0
  150. data/rbi/workos/agent_blueprints_update_request_invocable_by.rbi +30 -0
  151. data/rbi/workos/agent_blueprints_update_request_session_setting.rbi +36 -0
  152. data/rbi/workos/agent_instance.rbi +66 -0
  153. data/rbi/workos/agent_instance_created.rbi +54 -0
  154. data/rbi/workos/agent_instance_created_data.rbi +66 -0
  155. data/rbi/workos/agent_instance_deleted.rbi +54 -0
  156. data/rbi/workos/agent_instance_deleted_data.rbi +66 -0
  157. data/rbi/workos/agent_instance_session.rbi +66 -0
  158. data/rbi/workos/agent_instance_session_created.rbi +54 -0
  159. data/rbi/workos/agent_instance_session_created_data.rbi +72 -0
  160. data/rbi/workos/agent_instance_session_revoked.rbi +54 -0
  161. data/rbi/workos/agent_instance_session_revoked_data.rbi +66 -0
  162. data/rbi/workos/agent_token.rbi +66 -0
  163. data/rbi/workos/agent_token_validation.rbi +66 -0
  164. data/rbi/workos/agents.rbi +133 -0
  165. data/rbi/workos/audit_logs.rbi +26 -2
  166. data/rbi/workos/authentication_oauth_failed_data.rbi +6 -0
  167. data/rbi/workos/authentication_oauth_succeeded_data.rbi +6 -0
  168. data/rbi/workos/client.rbi +3 -0
  169. data/rbi/workos/create_connection.rbi +60 -0
  170. data/rbi/workos/create_connection_attribute_maps.rbi +30 -0
  171. data/rbi/workos/create_connection_key_pair.rbi +30 -0
  172. data/rbi/workos/create_connection_oidc_options.rbi +72 -0
  173. data/rbi/workos/create_connection_saml_options.rbi +66 -0
  174. data/rbi/workos/create_connection_standard_attributes.rbi +54 -0
  175. data/rbi/workos/create_it_contact.rbi +24 -0
  176. data/rbi/workos/create_saml_idp_signing_certificate.rbi +24 -0
  177. data/rbi/workos/create_team.rbi +30 -0
  178. data/rbi/workos/create_waitlist_entry.rbi +36 -0
  179. data/rbi/workos/email_completion_session_authenticate_request.rbi +72 -0
  180. data/rbi/workos/invite_it_contact.rbi +24 -0
  181. data/rbi/workos/it_contact.rbi +48 -0
  182. data/rbi/workos/organizations.rbi +45 -0
  183. data/rbi/workos/patch_connection.rbi +54 -0
  184. data/rbi/workos/patch_connection_attribute_maps.rbi +30 -0
  185. data/rbi/workos/patch_connection_oidc_options.rbi +66 -0
  186. data/rbi/workos/patch_connection_saml_options.rbi +48 -0
  187. data/rbi/workos/patch_connection_standard_attributes.rbi +54 -0
  188. data/rbi/workos/platform_teams.rbi +30 -0
  189. data/rbi/workos/resource_export_completed.rbi +54 -0
  190. data/rbi/workos/resource_export_completed_data.rbi +30 -0
  191. data/rbi/workos/resource_export_created.rbi +54 -0
  192. data/rbi/workos/resource_export_created_data.rbi +30 -0
  193. data/rbi/workos/resource_export_downloaded.rbi +54 -0
  194. data/rbi/workos/resource_export_downloaded_data.rbi +30 -0
  195. data/rbi/workos/resource_export_failed.rbi +54 -0
  196. data/rbi/workos/resource_export_failed_data.rbi +30 -0
  197. data/rbi/workos/saml_idp_signing_certificate.rbi +54 -0
  198. data/rbi/workos/saml_idp_signing_certificate_list.rbi +30 -0
  199. data/rbi/workos/saml_sp_encryption_certificate.rbi +54 -0
  200. data/rbi/workos/saml_sp_encryption_certificate_list.rbi +30 -0
  201. data/rbi/workos/saml_sp_signing_certificate.rbi +54 -0
  202. data/rbi/workos/sso.rbi +155 -2
  203. data/rbi/workos/team.rbi +60 -0
  204. data/rbi/workos/token_query.rbi +20 -2
  205. data/rbi/workos/update_audit_logs_retention.rbi +8 -2
  206. data/rbi/workos/user_management.rbi +64 -0
  207. data/rbi/workos/waitlist.rbi +42 -0
  208. data/rbi/workos/waitlist_entry.rbi +72 -0
  209. data/rbi/workos/waitlist_user.rbi +12 -6
  210. data/test/workos/test_agents.rb +105 -1
  211. data/test/workos/test_agents_model_round_trip.rb +245 -0
  212. data/test/workos/test_audit_logs.rb +11 -2
  213. data/test/workos/test_authorization.rb +6 -6
  214. data/test/workos/test_base_client.rb +155 -0
  215. data/test/workos/test_organizations.rb +41 -1
  216. data/test/workos/test_organizations_model_round_trip.rb +40 -1
  217. data/test/workos/test_platform_teams.rb +41 -0
  218. data/test/workos/test_platform_teams_model_round_trip.rb +41 -0
  219. data/test/workos/test_shared_model_round_trip.rb +449 -2
  220. data/test/workos/test_sso.rb +108 -2
  221. data/test/workos/test_sso_model_round_trip.rb +262 -2
  222. data/test/workos/test_user_management.rb +56 -0
  223. data/test/workos/test_user_management_model_round_trip.rb +78 -2
  224. metadata +160 -1
@@ -82,6 +82,24 @@ class BaseClientTest < Minitest::Test
82
82
  end
83
83
  end
84
84
 
85
+ # A pooled connection that either returns a canned response or raises when
86
+ # driven, so execute_request can be exercised without real TCP+TLS.
87
+ class StubConnection < FakeConnection
88
+ attr_accessor :read_timeout, :open_timeout
89
+
90
+ def initialize(response: nil, error: nil, **kwargs)
91
+ super(**kwargs)
92
+ @response = response
93
+ @error = error
94
+ end
95
+
96
+ def request(_request)
97
+ raise @error if @error
98
+
99
+ @response
100
+ end
101
+ end
102
+
85
103
  def setup
86
104
  @client = WorkOS::BaseClient.new(api_key: "sk_test_123", max_retries: 1)
87
105
  end
@@ -206,6 +224,143 @@ class BaseClientTest < Minitest::Test
206
224
  refute keep.finished
207
225
  end
208
226
 
227
+ # An exception execute_request's rescue clause doesn't list still leaves the
228
+ # socket mid-stream, so the connection must not survive in the pool for the
229
+ # next request on this thread to pick up.
230
+ def test_unlisted_request_error_evicts_the_pooled_connection
231
+ conn = StubConnection.new(error: Net::HTTPBadResponse.new("wrong version"))
232
+ cache = @client.send(:thread_connections)
233
+ cache["https:api.workos.com:443:30"] = conn
234
+
235
+ assert_raises(Net::HTTPBadResponse) do
236
+ @client.execute_request(request: Net::HTTP::Get.new("/things"))
237
+ end
238
+
239
+ refute cache.key?("https:api.workos.com:443:30"),
240
+ "a connection whose request did not complete must not stay pooled"
241
+ assert conn.finished
242
+ end
243
+
244
+ def test_completed_request_keeps_the_connection_pooled
245
+ conn = StubConnection.new(response: Net::HTTPOK.new("1.1", "200", "OK"))
246
+ cache = @client.send(:thread_connections)
247
+ cache["https:api.workos.com:443:30"] = conn
248
+
249
+ @client.execute_request(request: Net::HTTP::Get.new("/things"))
250
+
251
+ assert cache.key?("https:api.workos.com:443:30")
252
+ refute conn.finished
253
+ end
254
+
255
+ # Raised asynchronously into the worker thread to stand in for a caller-side
256
+ # abort: Timeout.timeout, Thread#kill, a signal handler unwinding the stack.
257
+ # It descends from Exception rather than StandardError so that nothing in
258
+ # execute_request can catch it — the `ensure` is the only cleanup that runs.
259
+ class AbortSignal < Exception; end # standard:disable Lint/InheritException
260
+
261
+ # End-to-end regression test over a real keep-alive socket, for the failure
262
+ # the eviction actually prevents: request one is abandoned mid-flight, the
263
+ # server then writes response one onto that socket, and request two on the
264
+ # same thread reads those stale bytes as if they were its own response.
265
+ #
266
+ # Before the fix, request two sees marker "one" (or a mangled response) off
267
+ # the pooled socket. After it, the abandoned socket is closed and the server
268
+ # accepts a fresh connection for request two.
269
+ def test_aborted_request_does_not_leak_its_response_to_the_next_request
270
+ WebMock.disable!
271
+ server = TCPServer.new("127.0.0.1", 0)
272
+ port = server.addr[1]
273
+ client = WorkOS::BaseClient.new(
274
+ api_key: "sk_test_123",
275
+ base_url: "http://127.0.0.1:#{port}",
276
+ timeout: 5,
277
+ max_retries: 0
278
+ )
279
+
280
+ request_one_read = Queue.new
281
+ release_response_one = Queue.new
282
+ response_one_written = Queue.new
283
+ aborted = Queue.new
284
+ connections = Queue.new
285
+
286
+ server_thread = Thread.new do
287
+ # Connection one: read the request, then hold the response back until
288
+ # the client has been aborted and has unwound.
289
+ first = server.accept
290
+ connections << first
291
+ read_http_request(first)
292
+ request_one_read << true
293
+ release_response_one.pop
294
+ begin
295
+ write_http_response(first, {marker: "one"})
296
+ rescue Errno::EPIPE, Errno::ECONNRESET, IOError
297
+ # Expected once the fix closes the abandoned socket.
298
+ end
299
+ response_one_written << true
300
+
301
+ # Connection two: a fresh accept, which only completes because the
302
+ # client did not reuse the socket above.
303
+ second = server.accept
304
+ connections << second
305
+ read_http_request(second)
306
+ write_http_response(second, {marker: "two"})
307
+ end
308
+
309
+ worker = Thread.new do
310
+ begin
311
+ client.execute_request(request: Net::HTTP::Get.new("/one"))
312
+ rescue AbortSignal
313
+ # The caller unwinds but the thread survives and goes on to serve more
314
+ # work, the way a Puma or Solid Queue worker does. execute_request's
315
+ # `ensure` has already run by the time this body executes.
316
+ aborted << true
317
+ response_one_written.pop
318
+ end
319
+ response = client.execute_request(request: Net::HTTP::Get.new("/two"))
320
+ JSON.parse(response.body)["marker"]
321
+ end
322
+
323
+ marker = Timeout.timeout(15) do
324
+ request_one_read.pop
325
+ worker.raise(AbortSignal)
326
+ aborted.pop
327
+ release_response_one << true
328
+ worker.value
329
+ end
330
+
331
+ assert_equal "two", marker,
332
+ "request two read the abandoned socket's response instead of its own"
333
+ ensure
334
+ server_thread&.kill
335
+ worker&.kill
336
+ until connections.nil? || connections.empty?
337
+ socket = connections.pop
338
+ socket.close unless socket.closed?
339
+ end
340
+ server&.close
341
+ WebMock.enable!
342
+ end
343
+
344
+ def read_http_request(socket)
345
+ socket.gets # request line
346
+ loop do
347
+ line = socket.gets
348
+ break if line.nil? || line == "\r\n"
349
+ end
350
+ end
351
+
352
+ def write_http_response(socket, body)
353
+ payload = JSON.generate(body)
354
+ socket.write(
355
+ "HTTP/1.1 200 OK\r\n" \
356
+ "Content-Type: application/json\r\n" \
357
+ "Content-Length: #{payload.bytesize}\r\n" \
358
+ "Connection: keep-alive\r\n" \
359
+ "\r\n#{payload}"
360
+ )
361
+ socket.flush
362
+ end
363
+
209
364
  # Regression test for https://github.com/workos/workos-ruby/issues/496
210
365
  #
211
366
  # The connection cache must be isolated per thread. A previous version
@@ -67,6 +67,41 @@ class OrganizationsTest < Minitest::Test
67
67
  assert_kind_of WorkOS::Types::ListStruct, result
68
68
  end
69
69
 
70
+ def test_list_it_contacts_returns_expected_result
71
+ stub_request(:get, %r{\Ahttps://api\.workos\.com/organizations/stub/it_contacts(\?|\z)})
72
+ .to_return(body: '{"data": [], "list_metadata": {}}', status: 200)
73
+ result = @client.organizations.list_it_contacts(organization_id: "stub")
74
+ assert_kind_of WorkOS::Types::ListStruct, result
75
+ end
76
+
77
+ def test_create_it_contact_returns_expected_result
78
+ stub_request(:post, %r{\Ahttps://api\.workos\.com/organizations/stub/it_contacts(\?|\z)})
79
+ .to_return(body: "{}", status: 200)
80
+ result = @client.organizations.create_it_contact(organization_id: "stub", email: "stub")
81
+ refute_nil result
82
+ end
83
+
84
+ def test_delete_it_contact_returns_expected_result
85
+ stub_request(:delete, %r{\Ahttps://api\.workos\.com/organizations/stub/it_contacts/stub(\?|\z)})
86
+ .to_return(body: "{}", status: 200)
87
+ result = @client.organizations.delete_it_contact(organization_id: "stub", contact_id: "stub")
88
+ assert_nil result
89
+ end
90
+
91
+ def test_invite_it_contact_returns_expected_result
92
+ stub_request(:post, %r{\Ahttps://api\.workos\.com/organizations/stub/it_contacts/stub/invite(\?|\z)})
93
+ .to_return(body: "{}", status: 200)
94
+ result = @client.organizations.invite_it_contact(organization_id: "stub", contact_id: "stub", intents: ["stub"])
95
+ assert_nil result
96
+ end
97
+
98
+ def test_revoke_it_contact_returns_expected_result
99
+ stub_request(:post, %r{\Ahttps://api\.workos\.com/organizations/stub/it_contacts/stub/revoke(\?|\z)})
100
+ .to_return(body: "{}", status: 200)
101
+ result = @client.organizations.revoke_it_contact(organization_id: "stub", contact_id: "stub")
102
+ assert_nil result
103
+ end
104
+
70
105
  # Parameterized authentication error tests (one per endpoint).
71
106
  [
72
107
  {name: :list_organizations, verb: :get, url: %r{\Ahttps://api\.workos\.com/organizations(\?|\z)}},
@@ -76,7 +111,12 @@ class OrganizationsTest < Minitest::Test
76
111
  {name: :update_organization, verb: :put, url: %r{\Ahttps://api\.workos\.com/organizations/stub(\?|\z)}, args: {id: "stub"}},
77
112
  {name: :delete_organization, verb: :delete, url: %r{\Ahttps://api\.workos\.com/organizations/stub(\?|\z)}, args: {id: "stub"}},
78
113
  {name: :get_audit_log_configuration, verb: :get, url: %r{\Ahttps://api\.workos\.com/organizations/stub/audit_log_configuration(\?|\z)}, args: {id: "stub"}},
79
- {name: :list_authorized_applications, verb: :get, url: %r{\Ahttps://api\.workos\.com/organizations/stub/authorized_applications(\?|\z)}, args: {organization_id: "stub"}}
114
+ {name: :list_authorized_applications, verb: :get, url: %r{\Ahttps://api\.workos\.com/organizations/stub/authorized_applications(\?|\z)}, args: {organization_id: "stub"}},
115
+ {name: :list_it_contacts, verb: :get, url: %r{\Ahttps://api\.workos\.com/organizations/stub/it_contacts(\?|\z)}, args: {organization_id: "stub"}},
116
+ {name: :create_it_contact, verb: :post, url: %r{\Ahttps://api\.workos\.com/organizations/stub/it_contacts(\?|\z)}, args: {organization_id: "stub", email: "stub"}},
117
+ {name: :delete_it_contact, verb: :delete, url: %r{\Ahttps://api\.workos\.com/organizations/stub/it_contacts/stub(\?|\z)}, args: {organization_id: "stub", contact_id: "stub"}},
118
+ {name: :invite_it_contact, verb: :post, url: %r{\Ahttps://api\.workos\.com/organizations/stub/it_contacts/stub/invite(\?|\z)}, args: {organization_id: "stub", contact_id: "stub", intents: ["stub"]}},
119
+ {name: :revoke_it_contact, verb: :post, url: %r{\Ahttps://api\.workos\.com/organizations/stub/it_contacts/stub/revoke(\?|\z)}, args: {organization_id: "stub", contact_id: "stub"}}
80
120
  ].each do |spec|
81
121
  define_method("test_#{spec[:name]}_raises_authentication_error_on_401") do
82
122
  stub_request(spec[:verb], spec[:url])
@@ -7,12 +7,33 @@ require "test_helper"
7
7
  class OrganizationsModelRoundTripTest < Minitest::Test
8
8
  def test_update_audit_logs_retention_round_trip
9
9
  fixture = {
10
+ "retention_period" => "stub",
10
11
  "retention_period_in_days" => 1
11
12
  }
12
13
  model = WorkOS::UpdateAuditLogsRetention.new(fixture.to_json)
13
14
  json = model.to_h
14
15
  assert_kind_of Hash, json
15
- assert_equal fixture["retention_period_in_days"], json[:retention_period_in_days]
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_create_it_contact_round_trip
20
+ fixture = {
21
+ "email" => "stub"
22
+ }
23
+ model = WorkOS::CreateItContact.new(fixture.to_json)
24
+ json = model.to_h
25
+ assert_kind_of Hash, json
26
+ assert_equal fixture["email"], json[:email]
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_invite_it_contact_round_trip
31
+ fixture = {
32
+ "intents" => []
33
+ }
34
+ model = WorkOS::InviteItContact.new(fixture.to_json)
35
+ json = model.to_h
36
+ assert_kind_of Hash, json
16
37
  fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
17
38
  end
18
39
 
@@ -544,6 +565,24 @@ class OrganizationsModelRoundTripTest < Minitest::Test
544
565
  fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
545
566
  end
546
567
 
568
+ def test_it_contact_round_trip
569
+ fixture = {
570
+ "object" => "it_contact",
571
+ "id" => "stub",
572
+ "email" => "stub",
573
+ "created_at" => "stub",
574
+ "updated_at" => "stub"
575
+ }
576
+ model = WorkOS::ItContact.new(fixture.to_json)
577
+ json = model.to_h
578
+ assert_kind_of Hash, json
579
+ assert_equal fixture["id"], json[:id]
580
+ assert_equal fixture["email"], json[:email]
581
+ assert_equal fixture["created_at"], json[:created_at]
582
+ assert_equal fixture["updated_at"], json[:updated_at]
583
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
584
+ end
585
+
547
586
  def test_organization_round_trip
548
587
  fixture = {
549
588
  "object" => "organization",
@@ -0,0 +1,41 @@
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 PlatformTeamsTest < Minitest::Test
8
+ include FixtureHelper
9
+
10
+ def setup
11
+ @client = WorkOS::Client.new(api_key: "sk_test_123")
12
+ end
13
+
14
+ def test_create_team_returns_expected_result
15
+ stub_request(:post, %r{\Ahttps://api\.workos\.com/platform/teams(\?|\z)})
16
+ .to_return(body: "{}", status: 200)
17
+ result = @client.platform_teams.create_team(admin_email: "stub", name: "stub")
18
+ refute_nil result
19
+ end
20
+
21
+ def test_get_team_returns_expected_result
22
+ stub_request(:get, %r{\Ahttps://api\.workos\.com/platform/teams/stub(\?|\z)})
23
+ .to_return(body: "{}", status: 200)
24
+ result = @client.platform_teams.get_team(team_id: "stub")
25
+ refute_nil result
26
+ end
27
+
28
+ # Parameterized authentication error tests (one per endpoint).
29
+ [
30
+ {name: :create_team, verb: :post, url: %r{\Ahttps://api\.workos\.com/platform/teams(\?|\z)}, args: {admin_email: "stub", name: "stub"}},
31
+ {name: :get_team, verb: :get, url: %r{\Ahttps://api\.workos\.com/platform/teams/stub(\?|\z)}, args: {team_id: "stub"}}
32
+ ].each do |spec|
33
+ define_method("test_#{spec[:name]}_raises_authentication_error_on_401") do
34
+ stub_request(spec[:verb], spec[:url])
35
+ .to_return(body: '{"message": "Unauthorized"}', status: 401)
36
+ assert_raises(WorkOS::AuthenticationError) do
37
+ @client.platform_teams.send(spec[:name], **(spec[:args] || {}))
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
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 PlatformTeamsModelRoundTripTest < Minitest::Test
8
+ def test_create_team_round_trip
9
+ fixture = {
10
+ "admin_email" => "stub",
11
+ "name" => "stub"
12
+ }
13
+ model = WorkOS::CreateTeam.new(fixture.to_json)
14
+ json = model.to_h
15
+ assert_kind_of Hash, json
16
+ assert_equal fixture["admin_email"], json[:admin_email]
17
+ assert_equal fixture["name"], json[:name]
18
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
19
+ end
20
+
21
+ def test_team_round_trip
22
+ fixture = {
23
+ "object" => "team",
24
+ "id" => "stub",
25
+ "name" => "stub",
26
+ "production_state" => "stub",
27
+ "production_enabled_at" => nil,
28
+ "created_at" => "stub",
29
+ "updated_at" => "stub"
30
+ }
31
+ model = WorkOS::Team.new(fixture.to_json)
32
+ json = model.to_h
33
+ assert_kind_of Hash, json
34
+ assert_equal fixture["id"], json[:id]
35
+ assert_equal fixture["name"], json[:name]
36
+ assert_nil json[:production_enabled_at]
37
+ assert_equal fixture["created_at"], json[:created_at]
38
+ assert_equal fixture["updated_at"], json[:updated_at]
39
+ fixture.each_key { |k| assert json.key?(k.to_sym) || json.key?(k), "Expected to_h to include key #{k}" }
40
+ end
41
+ end