workos 0.9.2 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -1
  3. data/.ruby-version +1 -1
  4. data/.semaphore/semaphore.yml +8 -2
  5. data/Gemfile.lock +49 -36
  6. data/README.md +15 -15
  7. data/docs/WorkOS/SSO.html +235 -235
  8. data/docs/file.README.html +20 -20
  9. data/lib/workos.rb +3 -0
  10. data/lib/workos/client.rb +25 -4
  11. data/lib/workos/connection.rb +8 -1
  12. data/lib/workos/directory.rb +53 -0
  13. data/lib/workos/directory_group.rb +44 -0
  14. data/lib/workos/directory_sync.rb +63 -7
  15. data/lib/workos/directory_user.rb +60 -0
  16. data/lib/workos/passwordless.rb +0 -2
  17. data/lib/workos/portal.rb +1 -7
  18. data/lib/workos/profile.rb +3 -4
  19. data/lib/workos/sso.rb +150 -17
  20. data/lib/workos/types.rb +3 -0
  21. data/lib/workos/types/connection_struct.rb +2 -0
  22. data/lib/workos/types/directory_group_struct.rb +13 -0
  23. data/lib/workos/types/directory_struct.rb +16 -0
  24. data/lib/workos/types/directory_user_struct.rb +18 -0
  25. data/lib/workos/types/intent_enum.rb +1 -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/audit_trail_spec.rb +0 -8
  60. data/spec/lib/workos/directory_sync_spec.rb +347 -40
  61. data/spec/lib/workos/passwordless_spec.rb +0 -8
  62. data/spec/lib/workos/portal_spec.rb +18 -11
  63. data/spec/lib/workos/sso_spec.rb +299 -29
  64. data/spec/spec_helper.rb +2 -1
  65. data/spec/support/fixtures/vcr_cassettes/audit_trail/get_events.yml +2 -2
  66. data/spec/support/fixtures/vcr_cassettes/directory_sync/delete_directory.yml +72 -0
  67. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories/with_after.yml +72 -0
  68. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories/with_before.yml +72 -0
  69. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_directories_with_domain_param.yml → list_directories/with_domain.yml} +19 -9
  70. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories/with_limit.yml +74 -0
  71. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_directories.yml → list_directories/with_no_options.yml} +1 -1
  72. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_users_with_directory_param.yml → list_directories/with_search.yml} +22 -11
  73. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_after.yml +76 -0
  74. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_before.yml +74 -0
  75. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_directory.yml +78 -0
  76. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_limit.yml +74 -0
  77. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_groups.yml → list_groups/with_no_options.yml} +16 -6
  78. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_user.yml +72 -0
  79. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_after.yml +86 -0
  80. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_before.yml +75 -0
  81. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_directory.yml +93 -0
  82. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_group.yml +76 -0
  83. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_limit.yml +75 -0
  84. data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_users.yml → list_users/with_no_options.yml} +16 -6
  85. data/spec/support/fixtures/vcr_cassettes/portal/generate_link_dsync.yml +72 -0
  86. data/spec/support/fixtures/vcr_cassettes/portal/{generate_link.yml → generate_link_sso.yml} +1 -1
  87. data/spec/support/fixtures/vcr_cassettes/sso/create_connection_with_valid_source.yml +3 -3
  88. data/spec/support/fixtures/vcr_cassettes/sso/delete_connection_with_invalid_id.yml +72 -0
  89. data/spec/support/fixtures/vcr_cassettes/sso/delete_connection_with_valid_id.yml +70 -0
  90. data/spec/support/fixtures/vcr_cassettes/{directory_sync/list_groups_with_directory_param.yml → sso/get_connection_with_invalid_id.yml} +21 -11
  91. data/spec/support/fixtures/vcr_cassettes/sso/get_connection_with_valid_id.yml +74 -0
  92. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_after.yml +73 -0
  93. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_before.yml +73 -0
  94. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_connection_type.yml +73 -0
  95. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_domain.yml +72 -0
  96. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_limit.yml +74 -0
  97. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_no_options.yml +73 -0
  98. data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_organization_id.yml +72 -0
  99. data/workos.gemspec +2 -0
  100. metadata +109 -28
  101. data/sorbet/rbi/hidden-definitions/errors.txt +0 -24896
  102. data/sorbet/rbi/hidden-definitions/hidden.rbi +0 -38411
  103. data/sorbet/rbi/sorbet-typed/lib/bundler/all/bundler.rbi +0 -8684
  104. data/sorbet/rbi/sorbet-typed/lib/ruby/all/gem.rbi +0 -4222
  105. data/sorbet/rbi/sorbet-typed/lib/ruby/all/open3.rbi +0 -111
  106. data/sorbet/rbi/sorbet-typed/lib/ruby/all/resolv.rbi +0 -543
@@ -2,14 +2,6 @@
2
2
  # typed: false
3
3
 
4
4
  describe WorkOS::Passwordless do
5
- before(:all) do
6
- WorkOS.key = 'key'
7
- end
8
-
9
- after(:all) do
10
- WorkOS.key = nil
11
- end
12
-
13
5
  describe '.create_session' do
14
6
  context 'with valid options payload' do
15
7
  let(:valid_options) do
@@ -2,14 +2,6 @@
2
2
  # typed: false
3
3
 
4
4
  describe WorkOS::Portal do
5
- before :all do
6
- WorkOS.key = 'test'
7
- end
8
-
9
- after :all do
10
- WorkOS.key = nil
11
- end
12
-
13
5
  describe '.create_organization' do
14
6
  context 'with valid payload' do
15
7
  it 'creates an organization' do
@@ -47,9 +39,9 @@ describe WorkOS::Portal do
47
39
  let(:organization) { 'org_01EHQMYV6MBK39QC5PZXHY59C3' }
48
40
 
49
41
  describe 'with a valid organization' do
50
- describe 'with the minimal params' do
42
+ context 'with the sso intent' do
51
43
  it 'returns an Admin Portal link' do
52
- VCR.use_cassette 'portal/generate_link' do
44
+ VCR.use_cassette 'portal/generate_link_sso' do
53
45
  portal_link = described_class.generate_link(
54
46
  intent: 'sso',
55
47
  organization: organization,
@@ -61,6 +53,21 @@ describe WorkOS::Portal do
61
53
  end
62
54
  end
63
55
  end
56
+
57
+ describe 'with the dsync intent' do
58
+ it 'returns an Admin Portal link' do
59
+ VCR.use_cassette 'portal/generate_link_dsync' do
60
+ portal_link = described_class.generate_link(
61
+ intent: 'dsync',
62
+ organization: organization,
63
+ )
64
+
65
+ expect(portal_link).to eq(
66
+ 'https://id.workos.com/portal/launch?secret=secret',
67
+ )
68
+ end
69
+ end
70
+ end
64
71
  end
65
72
 
66
73
  describe 'with an invalid organization' do
@@ -88,7 +95,7 @@ describe WorkOS::Portal do
88
95
  )
89
96
  end.to raise_error(
90
97
  ArgumentError,
91
- 'bogus-intent is not a valid value. `intent` must be in ["sso"]',
98
+ /bogus-intent is not a valid value/,
92
99
  )
93
100
  end
94
101
  end
@@ -9,7 +9,7 @@ describe WorkOS::SSO do
9
9
  let(:args) do
10
10
  {
11
11
  domain: 'foo.com',
12
- project_id: 'workos-proj-123',
12
+ client_id: 'workos-proj-123',
13
13
  redirect_uri: 'foo.com/auth/callback',
14
14
  state: {
15
15
  next_page: '/dashboard/edit',
@@ -43,7 +43,7 @@ describe WorkOS::SSO do
43
43
  let(:args) do
44
44
  {
45
45
  provider: 'GoogleOAuth',
46
- project_id: 'workos-proj-123',
46
+ client_id: 'workos-proj-123',
47
47
  redirect_uri: 'foo.com/auth/callback',
48
48
  state: {
49
49
  next_page: '/dashboard/edit',
@@ -73,10 +73,44 @@ describe WorkOS::SSO do
73
73
  end
74
74
  end
75
75
 
76
- context 'with neither domain or provider' do
76
+ context 'with a connection' do
77
77
  let(:args) do
78
78
  {
79
- project_id: 'workos-proj-123',
79
+ connection: 'connection_123',
80
+ client_id: 'workos-proj-123',
81
+ redirect_uri: 'foo.com/auth/callback',
82
+ state: {
83
+ next_page: '/dashboard/edit',
84
+ }.to_s,
85
+ }
86
+ end
87
+ it 'returns a valid URL' do
88
+ authorization_url = described_class.authorization_url(**args)
89
+
90
+ expect(URI.parse(authorization_url)).to be_a URI
91
+ end
92
+
93
+ it 'returns the expected hostname' do
94
+ authorization_url = described_class.authorization_url(**args)
95
+
96
+ expect(URI.parse(authorization_url).host).to eq(WorkOS::API_HOSTNAME)
97
+ end
98
+
99
+ it 'returns the expected query string' do
100
+ authorization_url = described_class.authorization_url(**args)
101
+
102
+ expect(URI.parse(authorization_url).query).to eq(
103
+ 'client_id=workos-proj-123&redirect_uri=foo.com%2Fauth%2Fcallback' \
104
+ '&response_type=code&state=%7B%3Anext_page%3D%3E%22%2Fdashboard%2F' \
105
+ 'edit%22%7D&connection=connection_123',
106
+ )
107
+ end
108
+ end
109
+
110
+ context 'with neither connection, domain, or provider' do
111
+ let(:args) do
112
+ {
113
+ client_id: 'workos-proj-123',
80
114
  redirect_uri: 'foo.com/auth/callback',
81
115
  state: {
82
116
  next_page: '/dashboard/edit',
@@ -88,7 +122,7 @@ describe WorkOS::SSO do
88
122
  described_class.authorization_url(**args)
89
123
  end.to raise_error(
90
124
  ArgumentError,
91
- 'Either domain or provider is required.',
125
+ 'Either connection, domain, or provider is required.',
92
126
  )
93
127
  end
94
128
  end
@@ -97,7 +131,7 @@ describe WorkOS::SSO do
97
131
  let(:args) do
98
132
  {
99
133
  provider: 'Okta',
100
- project_id: 'workos-proj-123',
134
+ client_id: 'workos-proj-123',
101
135
  redirect_uri: 'foo.com/auth/callback',
102
136
  state: {
103
137
  next_page: '/dashboard/edit',
@@ -113,23 +147,62 @@ describe WorkOS::SSO do
113
147
  )
114
148
  end
115
149
  end
116
- end
117
150
 
118
- describe '.profile' do
119
- before do
120
- WorkOS.key = 'api-key'
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
182
+
183
+ it 'returns the expected query string' do
184
+ authorization_url = described_class.authorization_url(**args)
185
+
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
+ )
191
+ end
121
192
  end
193
+ end
122
194
 
195
+ describe '.profile' do
123
196
  let(:args) do
124
197
  {
125
198
  code: SecureRandom.hex(10),
126
- project_id: 'workos-proj-123',
199
+ client_id: 'workos-proj-123',
127
200
  }
128
201
  end
129
202
 
130
203
  let(:request_body) do
131
204
  {
132
- client_id: args[:project_id],
205
+ client_id: args[:client_id],
133
206
  client_secret: WorkOS.key,
134
207
  code: args[:code],
135
208
  grant_type: 'authorization_code',
@@ -231,14 +304,6 @@ describe WorkOS::SSO do
231
304
  end
232
305
 
233
306
  describe '.create_connection' do
234
- before(:all) do
235
- WorkOS.key = 'key'
236
- end
237
-
238
- after(:all) do
239
- WorkOS.key = nil
240
- end
241
-
242
307
  context 'with a valid source' do
243
308
  it 'creates a connection' do
244
309
  VCR.use_cassette('sso/create_connection_with_valid_source') do
@@ -250,6 +315,8 @@ describe WorkOS::SSO do
250
315
  expect(connection.connection_type).to eq('GoogleOAuth')
251
316
  expect(connection.name).to eq('Foo Corp')
252
317
  expect(connection.domains.first[:domain]).to eq('example.com')
318
+ expect(connection.organization_id).to eq('12345')
319
+ expect(connection.status).to eq('linked')
253
320
  end
254
321
  end
255
322
  end
@@ -269,16 +336,8 @@ describe WorkOS::SSO do
269
336
  end
270
337
 
271
338
  describe '.promote_draft_connection' do
272
- before(:all) do
273
- WorkOS.key = 'key'
274
- end
275
-
276
- after(:all) do
277
- WorkOS.key = nil
278
- end
279
-
280
339
  let(:token) { 'draft_conn_id' }
281
- let(:project_id) { 'proj_0239u590h' }
340
+ let(:client_id) { 'proj_0239u590h' }
282
341
 
283
342
  context 'with a valid request' do
284
343
  before do
@@ -312,4 +371,215 @@ describe WorkOS::SSO do
312
371
  end
313
372
  end
314
373
  end
374
+
375
+ describe '.list_connections' do
376
+ context 'with no options' do
377
+ it 'returns connections and metadata' do
378
+ expected_metadata = {
379
+ 'after' => nil,
380
+ 'before' => 'before_id',
381
+ }
382
+
383
+ VCR.use_cassette 'sso/list_connections/with_no_options' do
384
+ connections = described_class.list_connections
385
+
386
+ expect(connections.data.size).to eq(3)
387
+ expect(connections.list_metadata).to eq(expected_metadata)
388
+ end
389
+ end
390
+ end
391
+
392
+ context 'with connection_type option' do
393
+ it 'forms the proper request to the API' do
394
+ request_args = [
395
+ '/connections?connection_type=OktaSAML',
396
+ 'Content-Type' => 'application/json'
397
+ ]
398
+
399
+ expected_request = Net::HTTP::Get.new(*request_args)
400
+
401
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
402
+ and_return(expected_request)
403
+
404
+ VCR.use_cassette 'sso/list_connections/with_connection_type' do
405
+ connections = described_class.list_connections(
406
+ connection_type: 'OktaSAML',
407
+ )
408
+
409
+ expect(connections.data.size).to eq(3)
410
+ expect(connections.data.first.connection_type).to eq('OktaSAML')
411
+ end
412
+ end
413
+ end
414
+
415
+ context 'with domain option' do
416
+ it 'forms the proper request to the API' do
417
+ request_args = [
418
+ '/connections?domain=foo-corp.com',
419
+ 'Content-Type' => 'application/json'
420
+ ]
421
+
422
+ expected_request = Net::HTTP::Get.new(*request_args)
423
+
424
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
425
+ and_return(expected_request)
426
+
427
+ VCR.use_cassette 'sso/list_connections/with_domain' do
428
+ connections = described_class.list_connections(
429
+ domain: 'foo-corp.com',
430
+ )
431
+
432
+ expect(connections.data.size).to eq(1)
433
+ end
434
+ end
435
+ end
436
+
437
+ context 'with organization_id option' do
438
+ it 'forms the proper request to the API' do
439
+ request_args = [
440
+ '/connections?organization_id=org_01EGS4P7QR31EZ4YWD1Z1XA176',
441
+ 'Content-Type' => 'application/json'
442
+ ]
443
+
444
+ expected_request = Net::HTTP::Get.new(*request_args)
445
+
446
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
447
+ and_return(expected_request)
448
+
449
+ VCR.use_cassette 'sso/list_connections/with_organization_id' do
450
+ connections = described_class.list_connections(
451
+ organization_id: 'org_01EGS4P7QR31EZ4YWD1Z1XA176',
452
+ )
453
+
454
+ expect(connections.data.size).to eq(1)
455
+ expect(connections.data.first.organization_id).to eq(
456
+ 'org_01EGS4P7QR31EZ4YWD1Z1XA176',
457
+ )
458
+ end
459
+ end
460
+ end
461
+
462
+ context 'with limit option' do
463
+ it 'forms the proper request to the API' do
464
+ request_args = [
465
+ '/connections?limit=2',
466
+ 'Content-Type' => 'application/json'
467
+ ]
468
+
469
+ expected_request = Net::HTTP::Get.new(*request_args)
470
+
471
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
472
+ and_return(expected_request)
473
+
474
+ VCR.use_cassette 'sso/list_connections/with_limit' do
475
+ connections = described_class.list_connections(
476
+ limit: 2,
477
+ )
478
+
479
+ expect(connections.data.size).to eq(2)
480
+ end
481
+ end
482
+ end
483
+
484
+ context 'with before option' do
485
+ it 'forms the proper request to the API' do
486
+ request_args = [
487
+ '/connections?before=conn_01EQKPMQAPV02H270HKVNS4CTA',
488
+ 'Content-Type' => 'application/json'
489
+ ]
490
+
491
+ expected_request = Net::HTTP::Get.new(*request_args)
492
+
493
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
494
+ and_return(expected_request)
495
+
496
+ VCR.use_cassette 'sso/list_connections/with_before' do
497
+ connections = described_class.list_connections(
498
+ before: 'conn_01EQKPMQAPV02H270HKVNS4CTA',
499
+ )
500
+
501
+ expect(connections.data.size).to eq(3)
502
+ end
503
+ end
504
+ end
505
+
506
+ context 'with after option' do
507
+ it 'forms the proper request to the API' do
508
+ request_args = [
509
+ '/connections?after=conn_01EQKPMQAPV02H270HKVNS4CTA',
510
+ 'Content-Type' => 'application/json'
511
+ ]
512
+
513
+ expected_request = Net::HTTP::Get.new(*request_args)
514
+
515
+ expect(Net::HTTP::Get).to receive(:new).with(*request_args).
516
+ and_return(expected_request)
517
+
518
+ VCR.use_cassette 'sso/list_connections/with_after' do
519
+ connections = described_class.list_connections(
520
+ after: 'conn_01EQKPMQAPV02H270HKVNS4CTA',
521
+ )
522
+
523
+ expect(connections.data.size).to eq(3)
524
+ end
525
+ end
526
+ end
527
+ end
528
+
529
+ describe '.get_connection' do
530
+ context 'with a valid id' do
531
+ it 'gets the connection details' do
532
+ VCR.use_cassette('sso/get_connection_with_valid_id') do
533
+ connection = WorkOS::SSO.get_connection(
534
+ id: 'conn_01EX00NB050H354WKGC7990AR2',
535
+ )
536
+
537
+ expect(connection.id).to eq('conn_01EX00NB050H354WKGC7990AR2')
538
+ expect(connection.connection_type).to eq('OktaSAML')
539
+ expect(connection.name).to eq('Foo Corp')
540
+ expect(connection.domains.first[:domain]).to eq('foo-corp.com')
541
+ end
542
+ end
543
+ end
544
+
545
+ context 'with an invalid id' do
546
+ it 'raises an error' do
547
+ VCR.use_cassette('sso/get_connection_with_invalid_id') do
548
+ expect do
549
+ WorkOS::SSO.get_connection(id: 'invalid')
550
+ end.to raise_error(
551
+ WorkOS::APIError,
552
+ 'Status 404, Not Found - request ID: ',
553
+ )
554
+ end
555
+ end
556
+ end
557
+ end
558
+
559
+ describe '.delete_connection' do
560
+ context 'with a valid id' do
561
+ it 'returns true' do
562
+ VCR.use_cassette('sso/delete_connection_with_valid_id') do
563
+ response = WorkOS::SSO.delete_connection(
564
+ id: 'conn_01EX55FRVN1V2PCA9YWTMZQMMQ',
565
+ )
566
+
567
+ expect(response).to be(true)
568
+ end
569
+ end
570
+ end
571
+
572
+ context 'with an invalid id' do
573
+ it 'returns false' do
574
+ VCR.use_cassette('sso/delete_connection_with_invalid_id') do
575
+ expect do
576
+ WorkOS::SSO.delete_connection(id: 'invalid')
577
+ end.to raise_error(
578
+ WorkOS::APIError,
579
+ 'Status 404, Not Found - request ID: ',
580
+ )
581
+ end
582
+ end
583
+ end
584
+ end
315
585
  end