workos 0.10.3 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.semaphore/semaphore.yml +8 -2
- data/Gemfile.lock +49 -36
- data/lib/workos.rb +3 -0
- data/lib/workos/client.rb +3 -3
- data/lib/workos/connection.rb +8 -1
- data/lib/workos/directory.rb +53 -0
- data/lib/workos/directory_group.rb +44 -0
- data/lib/workos/directory_sync.rb +63 -7
- data/lib/workos/directory_user.rb +60 -0
- data/lib/workos/profile.rb +1 -2
- data/lib/workos/sso.rb +10 -2
- data/lib/workos/types.rb +3 -0
- data/lib/workos/types/connection_struct.rb +2 -0
- data/lib/workos/types/directory_group_struct.rb +13 -0
- data/lib/workos/types/directory_struct.rb +16 -0
- data/lib/workos/types/directory_user_struct.rb +18 -0
- data/lib/workos/version.rb +1 -1
- data/sorbet/rbi/gems/addressable.rbi +199 -0
- data/sorbet/rbi/gems/ast.rbi +49 -0
- data/sorbet/rbi/gems/codecov.rbi +37 -0
- data/sorbet/rbi/gems/crack.rbi +62 -0
- data/sorbet/rbi/gems/docile.rbi +36 -0
- data/sorbet/rbi/gems/hashdiff.rbi +66 -0
- data/sorbet/rbi/gems/parallel.rbi +83 -0
- data/sorbet/rbi/gems/parser.rbi +1429 -0
- data/sorbet/rbi/gems/public_suffix.rbi +104 -0
- data/sorbet/rbi/gems/rainbow.rbi +118 -0
- data/sorbet/rbi/gems/rake.rbi +644 -0
- data/sorbet/rbi/gems/regexp_parser.rbi +926 -0
- data/sorbet/rbi/gems/rexml.rbi +628 -0
- data/sorbet/rbi/gems/rspec-core.rbi +1898 -0
- data/sorbet/rbi/gems/rspec-expectations.rbi +1127 -0
- data/sorbet/rbi/gems/rspec-mocks.rbi +1099 -0
- data/sorbet/rbi/gems/rspec-support.rbi +280 -0
- data/sorbet/rbi/gems/rspec.rbi +15 -0
- data/sorbet/rbi/gems/rubocop-ast.rbi +1355 -0
- data/sorbet/rbi/gems/rubocop.rbi +7253 -0
- data/sorbet/rbi/gems/ruby-progressbar.rbi +304 -0
- data/sorbet/rbi/gems/simplecov-html.rbi +35 -0
- data/sorbet/rbi/gems/simplecov.rbi +406 -0
- data/sorbet/rbi/gems/unicode-display_width.rbi +17 -0
- data/sorbet/rbi/gems/vcr.rbi +572 -0
- data/sorbet/rbi/gems/webmock.rbi +556 -0
- data/sorbet/rbi/gems/yard.rbi +1165 -0
- data/sorbet/rbi/sorbet-typed/lib/rake/all/rake.rbi +645 -0
- data/sorbet/rbi/sorbet-typed/lib/rspec-core/all/rspec-core.rbi +1891 -0
- data/sorbet/rbi/sorbet-typed/lib/rubocop/~>0.85/rubocop.rbi +2072 -0
- data/sorbet/rbi/sorbet-typed/lib/yard/all/yard.rbi +1214 -0
- data/sorbet/rbi/todo.rbi +1 -3
- data/spec/lib/workos/directory_sync_spec.rb +347 -32
- data/spec/lib/workos/sso_spec.rb +106 -31
- data/spec/spec_helper.rb +1 -1
- data/spec/support/fixtures/vcr_cassettes/directory_sync/delete_directory.yml +72 -0
- data/spec/support/fixtures/vcr_cassettes/{sso/list_connections.yml → directory_sync/list_directories/with_after.yml} +7 -7
- data/spec/support/fixtures/vcr_cassettes/{sso/list_connections_with_limit_param.yml → directory_sync/list_directories/with_before.yml} +8 -8
- data/spec/support/fixtures/vcr_cassettes/{sso/list_connections_with_connection_type_param.yml → directory_sync/list_directories/with_domain.yml} +11 -10
- data/spec/support/fixtures/vcr_cassettes/{sso/list_connections_with_after_param.yml → directory_sync/list_directories/with_limit.yml} +12 -10
- data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_directories.yml → list_directories/with_no_options.yml} +1 -1
- data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories/with_search.yml +73 -0
- data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_after.yml +76 -0
- data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_before.yml +74 -0
- data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_directory.yml +78 -0
- data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_limit.yml +74 -0
- data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_groups.yml → list_groups/with_no_options.yml} +16 -6
- data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups/with_user.yml +72 -0
- data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_after.yml +86 -0
- data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_before.yml +75 -0
- data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_directory.yml +93 -0
- data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_group.yml +76 -0
- data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users/with_limit.yml +75 -0
- data/spec/support/fixtures/vcr_cassettes/directory_sync/{list_users.yml → list_users/with_no_options.yml} +16 -6
- data/spec/support/fixtures/vcr_cassettes/sso/create_connection_with_valid_source.yml +3 -3
- data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_after.yml +73 -0
- data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_before.yml +73 -0
- data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_connection_type.yml +73 -0
- data/spec/support/fixtures/vcr_cassettes/sso/{list_connections_with_domain_param.yml → list_connections/with_domain.yml} +6 -6
- data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_limit.yml +74 -0
- data/spec/support/fixtures/vcr_cassettes/sso/list_connections/with_no_options.yml +73 -0
- data/spec/support/fixtures/vcr_cassettes/sso/{list_connections_with_organization_id_param.yml → list_connections/with_organization_id.yml} +6 -6
- data/workos.gemspec +2 -0
- metadata +97 -40
- data/sorbet/rbi/hidden-definitions/errors.txt +0 -24896
- data/sorbet/rbi/hidden-definitions/hidden.rbi +0 -38411
- data/sorbet/rbi/sorbet-typed/lib/bundler/all/bundler.rbi +0 -8684
- data/sorbet/rbi/sorbet-typed/lib/ruby/all/gem.rbi +0 -4222
- data/sorbet/rbi/sorbet-typed/lib/ruby/all/open3.rbi +0 -111
- data/sorbet/rbi/sorbet-typed/lib/ruby/all/resolv.rbi +0 -543
- data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories_with_domain_param.yml +0 -63
- data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups_with_directory_param.yml +0 -62
- data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users_with_directory_param.yml +0 -62
- data/spec/support/fixtures/vcr_cassettes/sso/list_connections_with_before_param.yml +0 -73
data/sorbet/rbi/todo.rbi
CHANGED
@@ -4,22 +4,137 @@
|
|
4
4
|
describe WorkOS::DirectorySync do
|
5
5
|
describe '.list_directories' do
|
6
6
|
context 'with no options' do
|
7
|
-
it 'returns directories' do
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
it 'returns directories and metadata' do
|
8
|
+
expected_metadata = {
|
9
|
+
'after' => nil,
|
10
|
+
'before' => 'before-id',
|
11
|
+
}
|
12
|
+
|
13
|
+
VCR.use_cassette 'directory_sync/list_directories/with_no_options' do
|
14
|
+
directories = described_class.list_directories
|
15
|
+
|
16
|
+
expect(directories.data.size).to eq(3)
|
17
|
+
expect(directories.list_metadata).to eq(expected_metadata)
|
11
18
|
end
|
12
19
|
end
|
13
20
|
end
|
14
21
|
|
15
22
|
context 'with domain option' do
|
16
|
-
it '
|
17
|
-
|
18
|
-
directories
|
23
|
+
it 'forms the proper request to the API' do
|
24
|
+
request_args = [
|
25
|
+
'/directories?domain=foo-corp.com',
|
26
|
+
'Content-Type' => 'application/json'
|
27
|
+
]
|
28
|
+
|
29
|
+
expected_request = Net::HTTP::Get.new(*request_args)
|
30
|
+
|
31
|
+
expect(Net::HTTP::Get).to receive(:new).with(*request_args).
|
32
|
+
and_return(expected_request)
|
33
|
+
|
34
|
+
VCR.use_cassette 'directory_sync/list_directories/with_domain' do
|
35
|
+
directories = described_class.list_directories(
|
19
36
|
domain: 'foo-corp.com',
|
20
37
|
)
|
21
38
|
|
22
|
-
expect(directories.
|
39
|
+
expect(directories.data.size).to eq(1)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'with search option' do
|
45
|
+
it 'forms the proper request to the API' do
|
46
|
+
request_args = [
|
47
|
+
'/directories?search=Foo',
|
48
|
+
'Content-Type' => 'application/json'
|
49
|
+
]
|
50
|
+
|
51
|
+
expected_request = Net::HTTP::Get.new(*request_args)
|
52
|
+
|
53
|
+
expect(Net::HTTP::Get).to receive(:new).with(*request_args).
|
54
|
+
and_return(expected_request)
|
55
|
+
|
56
|
+
VCR.use_cassette 'directory_sync/list_directories/with_search' do
|
57
|
+
directories = described_class.list_directories(
|
58
|
+
search: 'Foo',
|
59
|
+
)
|
60
|
+
|
61
|
+
expect(directories.data.size).to eq(1)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'with the before option' do
|
67
|
+
it 'forms the proper request to the API' do
|
68
|
+
request_args = [
|
69
|
+
'/directories?before=before-id',
|
70
|
+
'Content-Type' => 'application/json'
|
71
|
+
]
|
72
|
+
|
73
|
+
expected_request = Net::HTTP::Get.new(*request_args)
|
74
|
+
|
75
|
+
expect(Net::HTTP::Get).to receive(:new).with(*request_args).
|
76
|
+
and_return(expected_request)
|
77
|
+
|
78
|
+
VCR.use_cassette 'directory_sync/list_directories/with_before' do
|
79
|
+
directories = described_class.list_directories(
|
80
|
+
before: 'before-id',
|
81
|
+
)
|
82
|
+
|
83
|
+
expect(directories.data.size).to eq(3)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'with the after option' do
|
89
|
+
it 'forms the proper request to the API' do
|
90
|
+
request_args = [
|
91
|
+
'/directories?after=after-id',
|
92
|
+
'Content-Type' => 'application/json'
|
93
|
+
]
|
94
|
+
|
95
|
+
expected_request = Net::HTTP::Get.new(*request_args)
|
96
|
+
|
97
|
+
expect(Net::HTTP::Get).to receive(:new).with(*request_args).
|
98
|
+
and_return(expected_request)
|
99
|
+
|
100
|
+
VCR.use_cassette 'directory_sync/list_directories/with_after' do
|
101
|
+
directories = described_class.list_directories(after: 'after-id')
|
102
|
+
|
103
|
+
expect(directories.data.size).to eq(3)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'with the limit option' do
|
109
|
+
it 'forms the proper request to the API' do
|
110
|
+
request_args = [
|
111
|
+
'/directories?limit=2',
|
112
|
+
'Content-Type' => 'application/json'
|
113
|
+
]
|
114
|
+
|
115
|
+
expected_request = Net::HTTP::Get.new(*request_args)
|
116
|
+
|
117
|
+
expect(Net::HTTP::Get).to receive(:new).with(*request_args).
|
118
|
+
and_return(expected_request)
|
119
|
+
|
120
|
+
VCR.use_cassette 'directory_sync/list_directories/with_limit' do
|
121
|
+
directories = described_class.list_directories(limit: 2)
|
122
|
+
|
123
|
+
expect(directories.data.size).to eq(2)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe '.delete_directory' do
|
130
|
+
context 'with valid id' do
|
131
|
+
it 'deletes a directory' do
|
132
|
+
VCR.use_cassette('directory_sync/delete_directory') do
|
133
|
+
response = WorkOS::DirectorySync.delete_directory(
|
134
|
+
'directory_01F2T098SKN5PCTVSJ7CWP70N5',
|
135
|
+
)
|
136
|
+
|
137
|
+
expect(response).to be(true)
|
23
138
|
end
|
24
139
|
end
|
25
140
|
end
|
@@ -27,27 +142,127 @@ describe WorkOS::DirectorySync do
|
|
27
142
|
|
28
143
|
describe '.list_groups' do
|
29
144
|
context 'with no options' do
|
30
|
-
it '
|
31
|
-
VCR.use_cassette('directory_sync/list_groups') do
|
145
|
+
it 'raises an error' do
|
146
|
+
VCR.use_cassette('directory_sync/list_groups/with_no_options') do
|
32
147
|
expect do
|
33
148
|
WorkOS::DirectorySync.list_groups
|
34
|
-
end.to raise_error(
|
35
|
-
WorkOS::InvalidRequestError,
|
36
|
-
/Status 422, Validation failed/,
|
37
|
-
)
|
149
|
+
end.to raise_error(WorkOS::InvalidRequestError)
|
38
150
|
end
|
39
151
|
end
|
40
152
|
end
|
41
153
|
|
42
154
|
context 'with directory option' do
|
43
|
-
it '
|
44
|
-
|
45
|
-
|
46
|
-
|
155
|
+
it 'forms the proper request to the API' do
|
156
|
+
request_args = [
|
157
|
+
'/directory_groups?directory=directory_01EK2YEMVTWGX27STRDR0N3MP9',
|
158
|
+
'Content-Type' => 'application/json'
|
159
|
+
]
|
160
|
+
|
161
|
+
expected_request = Net::HTTP::Get.new(*request_args)
|
162
|
+
|
163
|
+
expect(Net::HTTP::Get).to receive(:new).with(*request_args).
|
164
|
+
and_return(expected_request)
|
165
|
+
|
166
|
+
VCR.use_cassette 'directory_sync/list_groups/with_directory' do
|
167
|
+
groups = described_class.list_groups(
|
168
|
+
directory: 'directory_01EK2YEMVTWGX27STRDR0N3MP9',
|
169
|
+
)
|
170
|
+
|
171
|
+
expect(groups.data.size).to eq(10)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context 'with user option' do
|
177
|
+
it 'forms the proper request to the API' do
|
178
|
+
request_args = [
|
179
|
+
'/directory_groups?user=directory_user_01EK2YFBC3R10MPB4W49G5QDXG',
|
180
|
+
'Content-Type' => 'application/json'
|
181
|
+
]
|
182
|
+
|
183
|
+
expected_request = Net::HTTP::Get.new(*request_args)
|
184
|
+
|
185
|
+
expect(Net::HTTP::Get).to receive(:new).with(*request_args).
|
186
|
+
and_return(expected_request)
|
187
|
+
|
188
|
+
VCR.use_cassette 'directory_sync/list_groups/with_user' do
|
189
|
+
groups = described_class.list_groups(
|
190
|
+
user: 'directory_user_01EK2YFBC3R10MPB4W49G5QDXG',
|
47
191
|
)
|
48
192
|
|
49
|
-
expect(groups.size).to eq(
|
50
|
-
|
193
|
+
expect(groups.data.size).to eq(3)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
context 'with the before option' do
|
199
|
+
it 'forms the proper request to the API' do
|
200
|
+
request_args = [
|
201
|
+
'/directory_groups?before=before-id&' \
|
202
|
+
'directory=directory_01EK2YEMVTWGX27STRDR0N3MP9',
|
203
|
+
'Content-Type' => 'application/json'
|
204
|
+
]
|
205
|
+
|
206
|
+
expected_request = Net::HTTP::Get.new(*request_args)
|
207
|
+
|
208
|
+
expect(Net::HTTP::Get).to receive(:new).with(*request_args).
|
209
|
+
and_return(expected_request)
|
210
|
+
|
211
|
+
VCR.use_cassette 'directory_sync/list_groups/with_before' do
|
212
|
+
groups = described_class.list_groups(
|
213
|
+
before: 'before-id',
|
214
|
+
directory: 'directory_01EK2YEMVTWGX27STRDR0N3MP9',
|
215
|
+
)
|
216
|
+
|
217
|
+
expect(groups.data.size).to eq(2)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
context 'with the after option' do
|
223
|
+
it 'forms the proper request to the API' do
|
224
|
+
request_args = [
|
225
|
+
'/directory_groups?after=after-id&' \
|
226
|
+
'directory=directory_01EK2YEMVTWGX27STRDR0N3MP9',
|
227
|
+
'Content-Type' => 'application/json'
|
228
|
+
]
|
229
|
+
|
230
|
+
expected_request = Net::HTTP::Get.new(*request_args)
|
231
|
+
|
232
|
+
expect(Net::HTTP::Get).to receive(:new).with(*request_args).
|
233
|
+
and_return(expected_request)
|
234
|
+
|
235
|
+
VCR.use_cassette 'directory_sync/list_groups/with_after' do
|
236
|
+
groups = described_class.list_groups(
|
237
|
+
after: 'after-id',
|
238
|
+
directory: 'directory_01EK2YEMVTWGX27STRDR0N3MP9',
|
239
|
+
)
|
240
|
+
|
241
|
+
expect(groups.data.size).to eq(10)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
context 'with the limit option' do
|
247
|
+
it 'forms the proper request to the API' do
|
248
|
+
request_args = [
|
249
|
+
'/directory_groups?limit=2&' \
|
250
|
+
'directory=directory_01EK2YEMVTWGX27STRDR0N3MP9',
|
251
|
+
'Content-Type' => 'application/json'
|
252
|
+
]
|
253
|
+
|
254
|
+
expected_request = Net::HTTP::Get.new(*request_args)
|
255
|
+
|
256
|
+
expect(Net::HTTP::Get).to receive(:new).with(*request_args).
|
257
|
+
and_return(expected_request)
|
258
|
+
|
259
|
+
VCR.use_cassette 'directory_sync/list_groups/with_limit' do
|
260
|
+
groups = described_class.list_groups(
|
261
|
+
limit: 2,
|
262
|
+
directory: 'directory_01EK2YEMVTWGX27STRDR0N3MP9',
|
263
|
+
)
|
264
|
+
|
265
|
+
expect(groups.data.size).to eq(2)
|
51
266
|
end
|
52
267
|
end
|
53
268
|
end
|
@@ -55,27 +270,127 @@ describe WorkOS::DirectorySync do
|
|
55
270
|
|
56
271
|
describe '.list_users' do
|
57
272
|
context 'with no options' do
|
58
|
-
it '
|
59
|
-
VCR.use_cassette('directory_sync/list_users') do
|
273
|
+
it 'raises an error' do
|
274
|
+
VCR.use_cassette('directory_sync/list_users/with_no_options') do
|
60
275
|
expect do
|
61
276
|
WorkOS::DirectorySync.list_users
|
62
|
-
end.to raise_error(
|
63
|
-
WorkOS::InvalidRequestError,
|
64
|
-
/Status 422, Validation failed/,
|
65
|
-
)
|
277
|
+
end.to raise_error(WorkOS::InvalidRequestError)
|
66
278
|
end
|
67
279
|
end
|
68
280
|
end
|
69
281
|
|
70
282
|
context 'with directory option' do
|
71
|
-
it '
|
72
|
-
|
73
|
-
|
74
|
-
|
283
|
+
it 'forms the proper request to the API' do
|
284
|
+
request_args = [
|
285
|
+
'/directory_users?directory=directory_01EK2YEMVTWGX27STRDR0N3MP9',
|
286
|
+
'Content-Type' => 'application/json'
|
287
|
+
]
|
288
|
+
|
289
|
+
expected_request = Net::HTTP::Get.new(*request_args)
|
290
|
+
|
291
|
+
expect(Net::HTTP::Get).to receive(:new).with(*request_args).
|
292
|
+
and_return(expected_request)
|
293
|
+
|
294
|
+
VCR.use_cassette 'directory_sync/list_users/with_directory' do
|
295
|
+
users = described_class.list_users(
|
296
|
+
directory: 'directory_01EK2YEMVTWGX27STRDR0N3MP9',
|
297
|
+
)
|
298
|
+
|
299
|
+
expect(users.data.size).to eq(10)
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
context 'with group option' do
|
305
|
+
it 'forms the proper request to the API' do
|
306
|
+
request_args = [
|
307
|
+
'/directory_users?group=directory_group_01EQ7V7C6Y4RPMCH3KNB9853FF',
|
308
|
+
'Content-Type' => 'application/json'
|
309
|
+
]
|
310
|
+
|
311
|
+
expected_request = Net::HTTP::Get.new(*request_args)
|
312
|
+
|
313
|
+
expect(Net::HTTP::Get).to receive(:new).with(*request_args).
|
314
|
+
and_return(expected_request)
|
315
|
+
|
316
|
+
VCR.use_cassette 'directory_sync/list_users/with_group' do
|
317
|
+
users = described_class.list_users(
|
318
|
+
group: 'directory_group_01EQ7V7C6Y4RPMCH3KNB9853FF',
|
319
|
+
)
|
320
|
+
|
321
|
+
expect(users.data.size).to eq(2)
|
322
|
+
end
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
context 'with the before option' do
|
327
|
+
it 'forms the proper request to the API' do
|
328
|
+
request_args = [
|
329
|
+
'/directory_users?before=before-id&'\
|
330
|
+
'directory=directory_01EK2YEMVTWGX27STRDR0N3MP9',
|
331
|
+
'Content-Type' => 'application/json'
|
332
|
+
]
|
333
|
+
|
334
|
+
expected_request = Net::HTTP::Get.new(*request_args)
|
335
|
+
|
336
|
+
expect(Net::HTTP::Get).to receive(:new).with(*request_args).
|
337
|
+
and_return(expected_request)
|
338
|
+
|
339
|
+
VCR.use_cassette 'directory_sync/list_users/with_before' do
|
340
|
+
users = described_class.list_users(
|
341
|
+
before: 'before-id',
|
342
|
+
directory: 'directory_01EK2YEMVTWGX27STRDR0N3MP9',
|
343
|
+
)
|
344
|
+
|
345
|
+
expect(users.data.size).to eq(2)
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
context 'with the after option' do
|
351
|
+
it 'forms the proper request to the API' do
|
352
|
+
request_args = [
|
353
|
+
'/directory_users?after=after-id&' \
|
354
|
+
'directory=directory_01EK2YEMVTWGX27STRDR0N3MP9',
|
355
|
+
'Content-Type' => 'application/json'
|
356
|
+
]
|
357
|
+
|
358
|
+
expected_request = Net::HTTP::Get.new(*request_args)
|
359
|
+
|
360
|
+
expect(Net::HTTP::Get).to receive(:new).with(*request_args).
|
361
|
+
and_return(expected_request)
|
362
|
+
|
363
|
+
VCR.use_cassette 'directory_sync/list_users/with_after' do
|
364
|
+
users = described_class.list_users(
|
365
|
+
after: 'after-id',
|
366
|
+
directory: 'directory_01EK2YEMVTWGX27STRDR0N3MP9',
|
367
|
+
)
|
368
|
+
|
369
|
+
expect(users.data.size).to eq(10)
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
context 'with the limit option' do
|
375
|
+
it 'forms the proper request to the API' do
|
376
|
+
request_args = [
|
377
|
+
'/directory_users?limit=2&' \
|
378
|
+
'directory=directory_01EK2YEMVTWGX27STRDR0N3MP9',
|
379
|
+
'Content-Type' => 'application/json'
|
380
|
+
]
|
381
|
+
|
382
|
+
expected_request = Net::HTTP::Get.new(*request_args)
|
383
|
+
|
384
|
+
expect(Net::HTTP::Get).to receive(:new).with(*request_args).
|
385
|
+
and_return(expected_request)
|
386
|
+
|
387
|
+
VCR.use_cassette 'directory_sync/list_users/with_limit' do
|
388
|
+
users = described_class.list_users(
|
389
|
+
limit: 2,
|
390
|
+
directory: 'directory_01EK2YEMVTWGX27STRDR0N3MP9',
|
75
391
|
)
|
76
392
|
|
77
|
-
expect(users.size).to eq(
|
78
|
-
expect(users.first['last_name']).to eq('Tran')
|
393
|
+
expect(users.data.size).to eq(2)
|
79
394
|
end
|
80
395
|
end
|
81
396
|
end
|
data/spec/lib/workos/sso_spec.rb
CHANGED
@@ -315,6 +315,8 @@ describe WorkOS::SSO do
|
|
315
315
|
expect(connection.connection_type).to eq('GoogleOAuth')
|
316
316
|
expect(connection.name).to eq('Foo Corp')
|
317
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')
|
318
320
|
end
|
319
321
|
end
|
320
322
|
end
|
@@ -372,45 +374,85 @@ describe WorkOS::SSO do
|
|
372
374
|
|
373
375
|
describe '.list_connections' do
|
374
376
|
context 'with no options' do
|
375
|
-
it 'returns connections' do
|
376
|
-
|
377
|
-
|
378
|
-
|
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)
|
379
388
|
end
|
380
389
|
end
|
381
390
|
end
|
382
391
|
|
383
392
|
context 'with connection_type option' do
|
384
|
-
it '
|
385
|
-
|
386
|
-
connections
|
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(
|
387
406
|
connection_type: 'OktaSAML',
|
388
407
|
)
|
389
|
-
|
408
|
+
|
409
|
+
expect(connections.data.size).to eq(3)
|
410
|
+
expect(connections.data.first.connection_type).to eq('OktaSAML')
|
390
411
|
end
|
391
412
|
end
|
392
413
|
end
|
393
414
|
|
394
415
|
context 'with domain option' do
|
395
|
-
it '
|
396
|
-
|
397
|
-
connections
|
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(
|
398
429
|
domain: 'foo-corp.com',
|
399
430
|
)
|
400
|
-
|
401
|
-
expect(
|
431
|
+
|
432
|
+
expect(connections.data.size).to eq(1)
|
402
433
|
end
|
403
434
|
end
|
404
435
|
end
|
405
436
|
|
406
437
|
context 'with organization_id option' do
|
407
|
-
it '
|
408
|
-
|
409
|
-
connections
|
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(
|
410
451
|
organization_id: 'org_01EGS4P7QR31EZ4YWD1Z1XA176',
|
411
452
|
)
|
412
|
-
|
413
|
-
expect(connections.
|
453
|
+
|
454
|
+
expect(connections.data.size).to eq(1)
|
455
|
+
expect(connections.data.first.organization_id).to eq(
|
414
456
|
'org_01EGS4P7QR31EZ4YWD1Z1XA176',
|
415
457
|
)
|
416
458
|
end
|
@@ -418,34 +460,67 @@ describe WorkOS::SSO do
|
|
418
460
|
end
|
419
461
|
|
420
462
|
context 'with limit option' do
|
421
|
-
it '
|
422
|
-
|
423
|
-
connections
|
424
|
-
|
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,
|
425
477
|
)
|
426
|
-
|
478
|
+
|
479
|
+
expect(connections.data.size).to eq(2)
|
427
480
|
end
|
428
481
|
end
|
429
482
|
end
|
430
483
|
|
431
484
|
context 'with before option' do
|
432
|
-
it '
|
433
|
-
|
434
|
-
connections
|
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(
|
435
498
|
before: 'conn_01EQKPMQAPV02H270HKVNS4CTA',
|
436
499
|
)
|
437
|
-
|
500
|
+
|
501
|
+
expect(connections.data.size).to eq(3)
|
438
502
|
end
|
439
503
|
end
|
440
504
|
end
|
441
505
|
|
442
506
|
context 'with after option' do
|
443
|
-
it '
|
444
|
-
|
445
|
-
connections
|
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(
|
446
520
|
after: 'conn_01EQKPMQAPV02H270HKVNS4CTA',
|
447
521
|
)
|
448
|
-
|
522
|
+
|
523
|
+
expect(connections.data.size).to eq(3)
|
449
524
|
end
|
450
525
|
end
|
451
526
|
end
|