workos 0.10.3 → 1.1.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 (108) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/.ruby-version +1 -1
  4. data/.semaphore/semaphore.yml +10 -4
  5. data/Gemfile.lock +49 -36
  6. data/LICENSE +1 -1
  7. data/README.md +13 -230
  8. data/lib/workos.rb +5 -0
  9. data/lib/workos/client.rb +24 -6
  10. data/lib/workos/connection.rb +12 -1
  11. data/lib/workos/directory.rb +53 -0
  12. data/lib/workos/directory_group.rb +44 -0
  13. data/lib/workos/directory_sync.rb +63 -7
  14. data/lib/workos/directory_user.rb +63 -0
  15. data/lib/workos/organizations.rb +150 -0
  16. data/lib/workos/passwordless.rb +4 -0
  17. data/lib/workos/portal.rb +0 -80
  18. data/lib/workos/profile.rb +9 -12
  19. data/lib/workos/profile_and_token.rb +28 -0
  20. data/lib/workos/sso.rb +35 -102
  21. data/lib/workos/types.rb +3 -0
  22. data/lib/workos/types/connection_struct.rb +3 -0
  23. data/lib/workos/types/directory_group_struct.rb +13 -0
  24. data/lib/workos/types/directory_struct.rb +16 -0
  25. data/lib/workos/types/directory_user_struct.rb +19 -0
  26. data/lib/workos/version.rb +1 -1
  27. data/sorbet/rbi/gems/addressable.rbi +199 -0
  28. data/sorbet/rbi/gems/ast.rbi +49 -0
  29. data/sorbet/rbi/gems/codecov.rbi +37 -0
  30. data/sorbet/rbi/gems/crack.rbi +62 -0
  31. data/sorbet/rbi/gems/docile.rbi +36 -0
  32. data/sorbet/rbi/gems/hashdiff.rbi +66 -0
  33. data/sorbet/rbi/gems/parallel.rbi +83 -0
  34. data/sorbet/rbi/gems/parser.rbi +1429 -0
  35. data/sorbet/rbi/gems/public_suffix.rbi +104 -0
  36. data/sorbet/rbi/gems/rainbow.rbi +118 -0
  37. data/sorbet/rbi/gems/rake.rbi +644 -0
  38. data/sorbet/rbi/gems/regexp_parser.rbi +926 -0
  39. data/sorbet/rbi/gems/rexml.rbi +628 -0
  40. data/sorbet/rbi/gems/rspec-core.rbi +1898 -0
  41. data/sorbet/rbi/gems/rspec-expectations.rbi +1127 -0
  42. data/sorbet/rbi/gems/rspec-mocks.rbi +1099 -0
  43. data/sorbet/rbi/gems/rspec-support.rbi +280 -0
  44. data/sorbet/rbi/gems/rspec.rbi +15 -0
  45. data/sorbet/rbi/gems/rubocop-ast.rbi +1355 -0
  46. data/sorbet/rbi/gems/rubocop.rbi +7253 -0
  47. data/sorbet/rbi/gems/ruby-progressbar.rbi +304 -0
  48. data/sorbet/rbi/gems/simplecov-html.rbi +35 -0
  49. data/sorbet/rbi/gems/simplecov.rbi +406 -0
  50. data/sorbet/rbi/gems/unicode-display_width.rbi +17 -0
  51. data/sorbet/rbi/gems/vcr.rbi +572 -0
  52. data/sorbet/rbi/gems/webmock.rbi +556 -0
  53. data/sorbet/rbi/gems/yard.rbi +1165 -0
  54. data/sorbet/rbi/sorbet-typed/lib/rake/all/rake.rbi +645 -0
  55. data/sorbet/rbi/sorbet-typed/lib/rspec-core/all/rspec-core.rbi +1891 -0
  56. data/sorbet/rbi/sorbet-typed/lib/rubocop/~>0.85/rubocop.rbi +2072 -0
  57. data/sorbet/rbi/sorbet-typed/lib/yard/all/yard.rbi +1214 -0
  58. data/sorbet/rbi/todo.rbi +1 -3
  59. data/spec/lib/workos/directory_sync_spec.rb +347 -32
  60. data/spec/lib/workos/organizations_spec.rb +164 -0
  61. data/spec/lib/workos/portal_spec.rb +0 -113
  62. data/spec/lib/workos/sso_spec.rb +137 -142
  63. data/spec/spec_helper.rb +1 -1
  64. data/spec/support/fixtures/vcr_cassettes/directory_sync/delete_directory.yml +72 -0
  65. data/spec/support/fixtures/vcr_cassettes/{sso/list_connections.yml → directory_sync/list_directories/with_after.yml} +7 -7
  66. data/spec/support/fixtures/vcr_cassettes/{sso/list_connections_with_limit_param.yml → directory_sync/list_directories/with_before.yml} +8 -8
  67. data/spec/support/fixtures/vcr_cassettes/{sso/list_connections_with_connection_type_param.yml → directory_sync/list_directories/with_domain.yml} +11 -10
  68. data/spec/support/fixtures/vcr_cassettes/{sso/list_connections_with_after_param.yml → directory_sync/list_directories/with_limit.yml} +12 -10
  69. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_directories.yml → list_directories/with_no_options.yml} +1 -1
  70. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories/with_search.yml +73 -0
  71. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_after.yml +76 -0
  72. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_before.yml +74 -0
  73. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_directory.yml +78 -0
  74. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_limit.yml +74 -0
  75. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_groups.yml → list_groups/with_no_options.yml} +16 -6
  76. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_user.yml +72 -0
  77. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_after.yml +86 -0
  78. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_before.yml +75 -0
  79. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_directory.yml +93 -0
  80. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_group.yml +76 -0
  81. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_limit.yml +75 -0
  82. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_users.yml → list_users/with_no_options.yml} +16 -6
  83. data/spec/support/fixtures/vcr_cassettes/organization/get.yml +73 -0
  84. data/spec/support/fixtures/vcr_cassettes/organization/get_invalid.yml +72 -0
  85. data/spec/support/fixtures/vcr_cassettes/organization/update.yml +73 -0
  86. data/spec/support/fixtures/vcr_cassettes/organization/update_invalid.yml +73 -0
  87. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_after.yml +73 -0
  88. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_before.yml +73 -0
  89. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_connection_type.yml +73 -0
  90. data/spec/support/fixtures/vcr_cassettes/sso/{list_connections_with_domain_param.yml → list_connections/with_domain.yml} +6 -6
  91. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_limit.yml +74 -0
  92. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_no_options.yml +73 -0
  93. data/spec/support/fixtures/vcr_cassettes/sso/{list_connections_with_organization_id_param.yml → list_connections/with_organization_id.yml} +6 -6
  94. data/spec/support/fixtures/vcr_cassettes/sso/profile.yml +74 -0
  95. data/workos.gemspec +2 -0
  96. metadata +110 -43
  97. data/sorbet/rbi/hidden-definitions/errors.txt +0 -24896
  98. data/sorbet/rbi/hidden-definitions/hidden.rbi +0 -38411
  99. data/sorbet/rbi/sorbet-typed/lib/bundler/all/bundler.rbi +0 -8684
  100. data/sorbet/rbi/sorbet-typed/lib/ruby/all/gem.rbi +0 -4222
  101. data/sorbet/rbi/sorbet-typed/lib/ruby/all/open3.rbi +0 -111
  102. data/sorbet/rbi/sorbet-typed/lib/ruby/all/resolv.rbi +0 -543
  103. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories_with_domain_param.yml +0 -63
  104. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups_with_directory_param.yml +0 -62
  105. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users_with_directory_param.yml +0 -62
  106. data/spec/support/fixtures/vcr_cassettes/sso/create_connection_with_invalid_source.yml +0 -58
  107. data/spec/support/fixtures/vcr_cassettes/sso/create_connection_with_valid_source.yml +0 -63
  108. data/spec/support/fixtures/vcr_cassettes/sso/list_connections_with_before_param.yml +0 -73
@@ -2,39 +2,6 @@
2
2
  # typed: false
3
3
 
4
4
  describe WorkOS::Portal do
5
- describe '.create_organization' do
6
- context 'with valid payload' do
7
- it 'creates an organization' do
8
- VCR.use_cassette 'organization/create' do
9
- organization = described_class.create_organization(
10
- domains: ['example.com'],
11
- name: 'Test Organization',
12
- )
13
-
14
- expect(organization.id).to eq('org_01EHT88Z8J8795GZNQ4ZP1J81T')
15
- expect(organization.name).to eq('Test Organization')
16
- expect(organization.domains.first[:domain]).to eq('example.com')
17
- end
18
- end
19
- end
20
-
21
- context 'with an invalid payload' do
22
- it 'returns an error' do
23
- VCR.use_cassette 'organization/create_invalid' do
24
- expect do
25
- described_class.create_organization(
26
- domains: ['example.com'],
27
- name: 'Test Organization 2',
28
- )
29
- end.to raise_error(
30
- WorkOS::APIError,
31
- /An Organization with the domain example.com already exists/,
32
- )
33
- end
34
- end
35
- end
36
- end
37
-
38
5
  describe '.generate_link' do
39
6
  let(:organization) { 'org_01EHQMYV6MBK39QC5PZXHY59C3' }
40
7
 
@@ -100,84 +67,4 @@ describe WorkOS::Portal do
100
67
  end
101
68
  end
102
69
  end
103
-
104
- describe '.list_organizations' do
105
- context 'with no options' do
106
- it 'returns organizations and metadata' do
107
- expected_metadata = {
108
- 'after' => nil,
109
- 'before' => 'before-id',
110
- }
111
-
112
- VCR.use_cassette 'organization/list' do
113
- organizations = described_class.list_organizations
114
-
115
- expect(organizations.data.size).to eq(7)
116
- expect(organizations.list_metadata).to eq(expected_metadata)
117
- end
118
- end
119
- end
120
-
121
- context 'with the before option' do
122
- it 'forms the proper request to the API' do
123
- request_args = [
124
- '/organizations?before=before-id',
125
- 'Content-Type' => 'application/json'
126
- ]
127
-
128
- expected_request = Net::HTTP::Get.new(*request_args)
129
-
130
- expect(Net::HTTP::Get).to receive(:new).with(*request_args).
131
- and_return(expected_request)
132
-
133
- VCR.use_cassette 'organization/list', match_requests_on: [:path] do
134
- organizations = described_class.list_organizations(
135
- before: 'before-id',
136
- )
137
-
138
- expect(organizations.data.size).to eq(7)
139
- end
140
- end
141
- end
142
-
143
- context 'with the after option' do
144
- it 'forms the proper request to the API' do
145
- request_args = [
146
- '/organizations?after=after-id',
147
- 'Content-Type' => 'application/json'
148
- ]
149
-
150
- expected_request = Net::HTTP::Get.new(*request_args)
151
-
152
- expect(Net::HTTP::Get).to receive(:new).with(*request_args).
153
- and_return(expected_request)
154
-
155
- VCR.use_cassette 'organization/list', match_requests_on: [:path] do
156
- organizations = described_class.list_organizations(after: 'after-id')
157
-
158
- expect(organizations.data.size).to eq(7)
159
- end
160
- end
161
- end
162
-
163
- context 'with the limit option' do
164
- it 'forms the proper request to the API' do
165
- request_args = [
166
- '/organizations?limit=10',
167
- 'Content-Type' => 'application/json'
168
- ]
169
-
170
- expected_request = Net::HTTP::Get.new(*request_args)
171
-
172
- expect(Net::HTTP::Get).to receive(:new).with(*request_args).
173
- and_return(expected_request)
174
-
175
- VCR.use_cassette 'organization/list', match_requests_on: [:path] do
176
- organizations = described_class.list_organizations(limit: 10)
177
-
178
- expect(organizations.data.size).to eq(7)
179
- end
180
- end
181
- end
182
- end
183
70
  end
@@ -147,52 +147,40 @@ describe WorkOS::SSO do
147
147
  )
148
148
  end
149
149
  end
150
+ end
150
151
 
151
- context 'passing the project_id' do
152
- let(:args) do
153
- {
154
- domain: 'foo.com',
155
- project_id: 'workos-proj-123',
156
- redirect_uri: 'foo.com/auth/callback',
157
- state: {
158
- next_page: '/dashboard/edit',
159
- }.to_s,
160
- }
161
- end
162
- it 'raises a deprecation warning' do
163
- expect do
164
- described_class.authorization_url(**args)
165
- end.to output(
166
- "[DEPRECATION] `project_id` is deprecated.
167
- Please use `client_id` instead.\n",
168
- ).to_stderr
169
- end
170
-
171
- it 'returns a valid URL' do
172
- authorization_url = described_class.authorization_url(**args)
173
-
174
- expect(URI.parse(authorization_url)).to be_a URI
175
- end
176
-
177
- it 'returns the expected hostname' do
178
- authorization_url = described_class.authorization_url(**args)
179
-
180
- expect(URI.parse(authorization_url).host).to eq(WorkOS::API_HOSTNAME)
181
- end
152
+ describe '.get_profile' do
153
+ it 'returns a profile' do
154
+ VCR.use_cassette 'sso/profile' do
155
+ profile = described_class.get_profile(access_token: 'access_token')
182
156
 
183
- it 'returns the expected query string' do
184
- authorization_url = described_class.authorization_url(**args)
157
+ expectation = {
158
+ connection_id: 'conn_01E83FVYZHY7DM4S9503JHV0R5',
159
+ connection_type: 'GoogleOAuth',
160
+ email: 'bob.loblaw@workos.com',
161
+ first_name: 'Bob',
162
+ id: 'prof_01EEJTY9SZ1R350RB7B73SNBKF',
163
+ idp_id: '116485463307139932699',
164
+ last_name: 'Loblaw',
165
+ raw_attributes: {
166
+ email: 'bob.loblaw@workos.com',
167
+ family_name: 'Loblaw',
168
+ given_name: 'Bob',
169
+ hd: 'workos.com',
170
+ id: '116485463307139932699',
171
+ locale: 'en',
172
+ name: 'Bob Loblaw',
173
+ picture: 'https://lh3.googleusercontent.com/a-/AOh14GyO2hLlgZvteDQ3Ldi3_-RteZLya0hWH7247Cam=s96-c',
174
+ verified_email: true,
175
+ },
176
+ }
185
177
 
186
- expect(URI.parse(authorization_url).query).to eq(
187
- 'client_id=workos-proj-123&redirect_uri=foo.com%2Fauth%2Fcallback' \
188
- '&response_type=code&state=%7B%3Anext_page%3D%3E%22%2Fdashboard%2F' \
189
- 'edit%22%7D&domain=foo.com',
190
- )
178
+ expect(profile.to_json).to eq(expectation)
191
179
  end
192
180
  end
193
181
  end
194
182
 
195
- describe '.profile' do
183
+ describe '.profile_and_token' do
196
184
  let(:args) do
197
185
  {
198
186
  code: SecureRandom.hex(10),
@@ -225,15 +213,15 @@ describe WorkOS::SSO do
225
213
  end
226
214
 
227
215
  it 'includes the SDK Version header' do
228
- described_class.profile(**args)
216
+ described_class.profile_and_token(**args)
229
217
 
230
218
  expect(a_request(:post, 'https://api.workos.com/sso/token').
231
219
  with(headers: headers, body: request_body)).to have_been_made
232
220
  end
233
221
 
234
- it 'returns a WorkOS::Profile' do
235
- profile = described_class.profile(**args)
236
- expect(profile).to be_a(WorkOS::Profile)
222
+ it 'returns a WorkOS::ProfileAndToken' do
223
+ profile_and_token = described_class.profile_and_token(**args)
224
+ expect(profile_and_token).to be_a(WorkOS::ProfileAndToken)
237
225
 
238
226
  expectation = {
239
227
  connection_id: 'conn_01EMH8WAK20T42N2NBMNBCYHAG',
@@ -252,7 +240,8 @@ describe WorkOS::SSO do
252
240
  },
253
241
  }
254
242
 
255
- expect(profile.to_json).to eq(expectation)
243
+ expect(profile_and_token.access_token).to eq('01DVX6QBS3EG6FHY2ESAA5Q65X')
244
+ expect(profile_and_token.profile.to_json).to eq(expectation)
256
245
  end
257
246
  end
258
247
 
@@ -269,7 +258,7 @@ describe WorkOS::SSO do
269
258
 
270
259
  it 'raises an exception with request ID' do
271
260
  expect do
272
- described_class.profile(**args)
261
+ described_class.profile_and_token(**args)
273
262
  end.to raise_error(
274
263
  WorkOS::APIError,
275
264
  'some error message - request ID: request-id',
@@ -293,7 +282,7 @@ describe WorkOS::SSO do
293
282
 
294
283
  it 'raises an exception' do
295
284
  expect do
296
- described_class.profile(**args)
285
+ described_class.profile_and_token(**args)
297
286
  end.to raise_error(
298
287
  WorkOS::APIError,
299
288
  "The code '01DVX3C5Z367SFHR8QNDMK7V24'" \
@@ -303,114 +292,87 @@ describe WorkOS::SSO do
303
292
  end
304
293
  end
305
294
 
306
- describe '.create_connection' do
307
- context 'with a valid source' do
308
- it 'creates a connection' do
309
- VCR.use_cassette('sso/create_connection_with_valid_source') do
310
- connection = WorkOS::SSO.create_connection(
311
- source: 'draft_conn_01E6PK87QP6NQ29RRX0G100YGV',
312
- )
295
+ describe '.list_connections' do
296
+ context 'with no options' do
297
+ it 'returns connections and metadata' do
298
+ expected_metadata = {
299
+ 'after' => nil,
300
+ 'before' => 'before_id',
301
+ }
313
302
 
314
- expect(connection.id).to eq('conn_01E4F9T2YWZFD218DN04KVFDSY')
315
- expect(connection.connection_type).to eq('GoogleOAuth')
316
- expect(connection.name).to eq('Foo Corp')
317
- expect(connection.domains.first[:domain]).to eq('example.com')
318
- end
319
- end
320
- end
303
+ VCR.use_cassette 'sso/list_connections/with_no_options' do
304
+ connections = described_class.list_connections
321
305
 
322
- context 'with an invalid source' do
323
- it 'raises an error' do
324
- VCR.use_cassette('sso/create_connection_with_invalid_source') do
325
- expect do
326
- WorkOS::SSO.create_connection(source: 'invalid')
327
- end.to raise_error(
328
- WorkOS::APIError,
329
- 'Status 404, Not Found - request ID: ',
330
- )
306
+ expect(connections.data.size).to eq(3)
307
+ expect(connections.list_metadata).to eq(expected_metadata)
331
308
  end
332
309
  end
333
310
  end
334
- end
335
-
336
- describe '.promote_draft_connection' do
337
- let(:token) { 'draft_conn_id' }
338
- let(:client_id) { 'proj_0239u590h' }
339
-
340
- context 'with a valid request' do
341
- before do
342
- stub_request(
343
- :post,
344
- "https://api.workos.com/draft_connections/#{token}/activate",
345
- ).to_return(status: 200)
346
- end
347
- it 'returns true' do
348
- response = described_class.promote_draft_connection(
349
- token: token,
350
- )
351
-
352
- expect(response).to be(true)
353
- end
354
- end
355
311
 
356
- context 'with an invalid request' do
357
- before do
358
- stub_request(
359
- :post,
360
- "https://api.workos.com/draft_connections/#{token}/activate",
361
- ).to_return(status: 403)
362
- end
363
- it 'returns true' do
364
- response = described_class.promote_draft_connection(
365
- token: token,
366
- )
312
+ context 'with connection_type option' do
313
+ it 'forms the proper request to the API' do
314
+ request_args = [
315
+ '/connections?connection_type=OktaSAML',
316
+ 'Content-Type' => 'application/json'
317
+ ]
367
318
 
368
- expect(response).to be(false)
369
- end
370
- end
371
- end
319
+ expected_request = Net::HTTP::Get.new(*request_args)
372
320
 
373
- describe '.list_connections' do
374
- context 'with no options' do
375
- it 'returns connections' do
376
- VCR.use_cassette('sso/list_connections') do
377
- connections = WorkOS::SSO.list_connections
378
- expect(connections.size).to eq(1)
379
- end
380
- end
381
- end
321
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
322
+ and_return(expected_request)
382
323
 
383
- context 'with connection_type option' do
384
- it 'returns connections' do
385
- VCR.use_cassette('sso/list_connections_with_connection_type_param') do
386
- connections = WorkOS::SSO.list_connections(
324
+ VCR.use_cassette 'sso/list_connections/with_connection_type' do
325
+ connections = described_class.list_connections(
387
326
  connection_type: 'OktaSAML',
388
327
  )
389
- expect(connections.first['connection_type']).to eq('OktaSAML')
328
+
329
+ expect(connections.data.size).to eq(3)
330
+ expect(connections.data.first.connection_type).to eq('OktaSAML')
390
331
  end
391
332
  end
392
333
  end
393
334
 
394
335
  context 'with domain option' do
395
- it 'returns connections' do
396
- VCR.use_cassette('sso/list_connections_with_domain_param') do
397
- connections = WorkOS::SSO.list_connections(
336
+ it 'forms the proper request to the API' do
337
+ request_args = [
338
+ '/connections?domain=foo-corp.com',
339
+ 'Content-Type' => 'application/json'
340
+ ]
341
+
342
+ expected_request = Net::HTTP::Get.new(*request_args)
343
+
344
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
345
+ and_return(expected_request)
346
+
347
+ VCR.use_cassette 'sso/list_connections/with_domain' do
348
+ connections = described_class.list_connections(
398
349
  domain: 'foo-corp.com',
399
350
  )
400
- domains = connections.first['domains']
401
- expect(domains.first['domain']).to eq('foo-corp.com')
351
+
352
+ expect(connections.data.size).to eq(1)
402
353
  end
403
354
  end
404
355
  end
405
356
 
406
357
  context 'with organization_id option' do
407
- it 'returns connections' do
408
- VCR.use_cassette('sso/list_connections_with_organization_id_param') do
409
- connections = WorkOS::SSO.list_connections(
358
+ it 'forms the proper request to the API' do
359
+ request_args = [
360
+ '/connections?organization_id=org_01EGS4P7QR31EZ4YWD1Z1XA176',
361
+ 'Content-Type' => 'application/json'
362
+ ]
363
+
364
+ expected_request = Net::HTTP::Get.new(*request_args)
365
+
366
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
367
+ and_return(expected_request)
368
+
369
+ VCR.use_cassette 'sso/list_connections/with_organization_id' do
370
+ connections = described_class.list_connections(
410
371
  organization_id: 'org_01EGS4P7QR31EZ4YWD1Z1XA176',
411
372
  )
412
- expect(connections.size).to eq(1)
413
- expect(connections.first['organization_id']).to eq(
373
+
374
+ expect(connections.data.size).to eq(1)
375
+ expect(connections.data.first.organization_id).to eq(
414
376
  'org_01EGS4P7QR31EZ4YWD1Z1XA176',
415
377
  )
416
378
  end
@@ -418,34 +380,67 @@ describe WorkOS::SSO do
418
380
  end
419
381
 
420
382
  context 'with limit option' do
421
- it 'returns connections' do
422
- VCR.use_cassette('sso/list_connections_with_limit_param') do
423
- connections = WorkOS::SSO.list_connections(
424
- limit: 1,
383
+ it 'forms the proper request to the API' do
384
+ request_args = [
385
+ '/connections?limit=2',
386
+ 'Content-Type' => 'application/json'
387
+ ]
388
+
389
+ expected_request = Net::HTTP::Get.new(*request_args)
390
+
391
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
392
+ and_return(expected_request)
393
+
394
+ VCR.use_cassette 'sso/list_connections/with_limit' do
395
+ connections = described_class.list_connections(
396
+ limit: 2,
425
397
  )
426
- expect(connections.size).to eq(1)
398
+
399
+ expect(connections.data.size).to eq(2)
427
400
  end
428
401
  end
429
402
  end
430
403
 
431
404
  context 'with before option' do
432
- it 'returns connections' do
433
- VCR.use_cassette('sso/list_connections_with_before_param') do
434
- connections = WorkOS::SSO.list_connections(
405
+ it 'forms the proper request to the API' do
406
+ request_args = [
407
+ '/connections?before=conn_01EQKPMQAPV02H270HKVNS4CTA',
408
+ 'Content-Type' => 'application/json'
409
+ ]
410
+
411
+ expected_request = Net::HTTP::Get.new(*request_args)
412
+
413
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
414
+ and_return(expected_request)
415
+
416
+ VCR.use_cassette 'sso/list_connections/with_before' do
417
+ connections = described_class.list_connections(
435
418
  before: 'conn_01EQKPMQAPV02H270HKVNS4CTA',
436
419
  )
437
- expect(connections.size).to eq(1)
420
+
421
+ expect(connections.data.size).to eq(3)
438
422
  end
439
423
  end
440
424
  end
441
425
 
442
426
  context 'with after option' do
443
- it 'returns connections' do
444
- VCR.use_cassette('sso/list_connections_with_after_param') do
445
- connections = WorkOS::SSO.list_connections(
427
+ it 'forms the proper request to the API' do
428
+ request_args = [
429
+ '/connections?after=conn_01EQKPMQAPV02H270HKVNS4CTA',
430
+ 'Content-Type' => 'application/json'
431
+ ]
432
+
433
+ expected_request = Net::HTTP::Get.new(*request_args)
434
+
435
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
436
+ and_return(expected_request)
437
+
438
+ VCR.use_cassette 'sso/list_connections/with_after' do
439
+ connections = described_class.list_connections(
446
440
  after: 'conn_01EQKPMQAPV02H270HKVNS4CTA',
447
441
  )
448
- expect(connections.size).to eq(1)
442
+
443
+ expect(connections.data.size).to eq(3)
449
444
  end
450
445
  end
451
446
  end