workos 0.2.2 → 0.3.3

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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/.ruby-version +1 -1
  4. data/.semaphore/semaphore.yml +13 -6
  5. data/Gemfile.lock +6 -6
  6. data/README.md +1 -1
  7. data/lib/workos.rb +2 -0
  8. data/lib/workos/audit_trail.rb +0 -16
  9. data/lib/workos/client.rb +43 -4
  10. data/lib/workos/connection.rb +48 -0
  11. data/lib/workos/directory_sync.rb +128 -0
  12. data/lib/workos/profile.rb +6 -7
  13. data/lib/workos/sso.rb +48 -35
  14. data/lib/workos/types.rb +2 -2
  15. data/lib/workos/types/connection_struct.rb +15 -0
  16. data/lib/workos/types/profile_struct.rb +2 -3
  17. data/lib/workos/types/provider_enum.rb +0 -1
  18. data/lib/workos/version.rb +1 -1
  19. data/sorbet/rbi/hidden-definitions/errors.txt +1416 -321
  20. data/sorbet/rbi/hidden-definitions/hidden.rbi +2490 -597
  21. data/sorbet/rbi/sorbet-typed/lib/rainbow/all/rainbow.rbi +36 -14
  22. data/sorbet/rbi/todo.rbi +1 -6
  23. data/spec/lib/workos/directory_sync_spec.rb +139 -0
  24. data/spec/lib/workos/sso_spec.rb +50 -4
  25. data/spec/support/fixtures/vcr_cassettes/directory_sync/get_group.yml +62 -0
  26. data/spec/support/fixtures/vcr_cassettes/directory_sync/get_group_with_invalid_id.yml +62 -0
  27. data/spec/support/fixtures/vcr_cassettes/directory_sync/get_user.yml +62 -0
  28. data/spec/support/fixtures/vcr_cassettes/directory_sync/get_user_with_invalid_id.yml +62 -0
  29. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories.yml +62 -0
  30. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories_with_domain_param.yml +63 -0
  31. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups.yml +64 -0
  32. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_groups_with_directory_param.yml +62 -0
  33. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users.yml +64 -0
  34. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_users_with_directory_param.yml +62 -0
  35. data/spec/support/fixtures/vcr_cassettes/sso/create_connection_with_invalid_source.yml +58 -0
  36. data/spec/support/fixtures/vcr_cassettes/sso/create_connection_with_valid_source.yml +63 -0
  37. data/workos.gemspec +14 -11
  38. metadata +35 -5
@@ -57,7 +57,7 @@ module Rainbow
57
57
  sig { params(value: Numeric).returns(Integer) }
58
58
  def to_ansi_domain(value); end
59
59
 
60
- sig { params(ground: Symbol, values: Integer).returns(RGB) }
60
+ sig { params(ground: Symbol, values: Integer).returns(RGB) }
61
61
  def initialize(ground, *values); end
62
62
 
63
63
  sig { returns(T::Array[Integer]) }
@@ -94,9 +94,18 @@ module Rainbow
94
94
  sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(NullPresenter) }
95
95
  def color(*values); end
96
96
 
97
+ sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(NullPresenter) }
98
+ def foreground(*values); end
99
+
100
+ sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(NullPresenter) }
101
+ def fg(*values); end
102
+
97
103
  sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(NullPresenter) }
98
104
  def background(*values); end
99
105
 
106
+ sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(NullPresenter) }
107
+ def bg(*values); end
108
+
100
109
  sig { returns(NullPresenter) }
101
110
  def reset; end
102
111
 
@@ -148,12 +157,14 @@ module Rainbow
148
157
  sig { returns(NullPresenter) }
149
158
  def white; end
150
159
 
151
- alias foreground color
152
- alias fg color
153
- alias bg background
154
- alias bold bright
155
- alias dark faint
156
- alias strike cross_out
160
+ sig { returns(NullPresenter) }
161
+ def bold; end
162
+
163
+ sig { returns(NullPresenter) }
164
+ def dark; end
165
+
166
+ sig { returns(NullPresenter) }
167
+ def strike; end
157
168
  end
158
169
 
159
170
  class Presenter < String
@@ -162,9 +173,18 @@ module Rainbow
162
173
  sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(Presenter) }
163
174
  def color(*values); end
164
175
 
176
+ sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(Presenter) }
177
+ def foreground(*values); end
178
+
179
+ sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(Presenter) }
180
+ def fg(*values); end
181
+
165
182
  sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(Presenter) }
166
183
  def background(*values); end
167
184
 
185
+ sig { params(values: T.any([Integer], [Integer, Integer, Integer])).returns(Presenter) }
186
+ def bg(*values); end
187
+
168
188
  sig { returns(Presenter) }
169
189
  def reset; end
170
190
 
@@ -216,12 +236,14 @@ module Rainbow
216
236
  sig { returns(Presenter) }
217
237
  def white; end
218
238
 
219
- alias foreground color
220
- alias fg color
221
- alias bg background
222
- alias bold bright
223
- alias dark faint
224
- alias strike cross_out
239
+ sig { returns(Presenter) }
240
+ def bold; end
241
+
242
+ sig { returns(Presenter) }
243
+ def dark; end
244
+
245
+ sig { returns(Presenter) }
246
+ def strike; end
225
247
  end
226
248
 
227
249
  class StringUtils
@@ -240,7 +262,7 @@ module Rainbow
240
262
 
241
263
  sig { params(enabled: T::Boolean).returns(Wrapper) }
242
264
  def initialize(enabled = true); end
243
-
265
+
244
266
  sig { params(string: String).returns(T.any(Rainbow::Presenter, Rainbow::NullPresenter)) }
245
267
  def wrap(string); end
246
268
  end
@@ -2,11 +2,6 @@
2
2
  # srb rbi todo
3
3
 
4
4
  # typed: strong
5
+ module T::CompatibilityPatches::RecorderExtensions; end
5
6
  module T::Private::Methods::MethodHooks; end
6
- module T::Private::Methods::MethodHooks; end
7
- module T::Private::Methods::MethodHooks; end
8
- module T::Private::Methods::SingletonMethodHooks; end
9
- module T::Private::Methods::SingletonMethodHooks; end
10
- module T::Private::Methods::SingletonMethodHooks; end
11
- module T::Private::Methods::SingletonMethodHooks; end
12
7
  module T::Private::Methods::SingletonMethodHooks; end
@@ -0,0 +1,139 @@
1
+ # frozen_string_literal: true
2
+ # typed: false
3
+
4
+ describe WorkOS::DirectorySync do
5
+ before(:all) do
6
+ WorkOS.key = 'key'
7
+ end
8
+
9
+ after(:all) do
10
+ WorkOS.key = nil
11
+ end
12
+
13
+ describe '.list_directories' do
14
+ context 'with no options' do
15
+ it 'returns directories' do
16
+ VCR.use_cassette('directory_sync/list_directories') do
17
+ directories = WorkOS::DirectorySync.list_directories
18
+ expect(directories.size).to eq(1)
19
+ end
20
+ end
21
+ end
22
+
23
+ context 'with domain option' do
24
+ it 'returns directories' do
25
+ VCR.use_cassette('directory_sync/list_directories_with_domain_param') do
26
+ directories = WorkOS::DirectorySync.list_directories(
27
+ domain: 'foo-corp.com',
28
+ )
29
+
30
+ expect(directories.first['domain']).to eq('foo-corp.com')
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ describe '.list_groups' do
37
+ context 'with no options' do
38
+ it 'returns groups' do
39
+ VCR.use_cassette('directory_sync/list_groups') do
40
+ expect do
41
+ WorkOS::DirectorySync.list_groups
42
+ end.to raise_error(
43
+ WorkOS::InvalidRequestError,
44
+ /Status 422, Validation failed/,
45
+ )
46
+ end
47
+ end
48
+ end
49
+
50
+ context 'with directory option' do
51
+ it 'returns groups' do
52
+ VCR.use_cassette('directory_sync/list_groups_with_directory_param') do
53
+ groups = WorkOS::DirectorySync.list_groups(
54
+ directory: 'directory_edp_01E64QQVQTCB0DECJ9CFNXEWDW',
55
+ )
56
+
57
+ expect(groups.size).to eq(2)
58
+ expect(groups.first['name']).to eq('Walrus')
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ describe '.list_users' do
65
+ context 'with no options' do
66
+ it 'returns users' do
67
+ VCR.use_cassette('directory_sync/list_users') do
68
+ expect do
69
+ WorkOS::DirectorySync.list_users
70
+ end.to raise_error(
71
+ WorkOS::InvalidRequestError,
72
+ /Status 422, Validation failed/,
73
+ )
74
+ end
75
+ end
76
+ end
77
+
78
+ context 'with directory option' do
79
+ it 'returns users' do
80
+ VCR.use_cassette('directory_sync/list_users_with_directory_param') do
81
+ users = WorkOS::DirectorySync.list_users(
82
+ directory: 'directory_edp_01E64QQVQTCB0DECJ9CFNXEWDW',
83
+ )
84
+
85
+ expect(users.size).to eq(1)
86
+ expect(users.first['last_name']).to eq('Tran')
87
+ end
88
+ end
89
+ end
90
+ end
91
+
92
+ describe '.get_group' do
93
+ context 'with valid id' do
94
+ it 'returns a group' do
95
+ VCR.use_cassette('directory_sync/get_group') do
96
+ group = WorkOS::DirectorySync.get_group(
97
+ 'directory_grp_01E64QTDNS0EGJ0FMCVY9BWGZT',
98
+ )
99
+
100
+ expect(group['name']).to eq('Walrus')
101
+ end
102
+ end
103
+ end
104
+
105
+ context 'with invalid id' do
106
+ it 'raises an error' do
107
+ VCR.use_cassette('directory_sync/get_group_with_invalid_id') do
108
+ expect do
109
+ WorkOS::DirectorySync.get_group('invalid')
110
+ end.to raise_error(WorkOS::APIError)
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ describe '.get_user' do
117
+ context 'with valid id' do
118
+ it 'returns a user' do
119
+ VCR.use_cassette('directory_sync/get_user') do
120
+ user = WorkOS::DirectorySync.get_user(
121
+ 'directory_usr_01E64QS50EAY48S0XJ1AA4WX4D',
122
+ )
123
+
124
+ expect(user['first_name']).to eq('Mark')
125
+ end
126
+ end
127
+ end
128
+
129
+ context 'with invalid id' do
130
+ it 'raises an error' do
131
+ VCR.use_cassette('directory_sync/get_user_with_invalid_id') do
132
+ expect do
133
+ WorkOS::DirectorySync.get_user('invalid')
134
+ end.to raise_error(WorkOS::APIError)
135
+ end
136
+ end
137
+ end
138
+ end
139
+ end
@@ -13,7 +13,7 @@ describe WorkOS::SSO do
13
13
  redirect_uri: 'foo.com/auth/callback',
14
14
  state: {
15
15
  next_page: '/dashboard/edit',
16
- },
16
+ }.to_s,
17
17
  }
18
18
  end
19
19
  it 'returns a valid URL' do
@@ -47,7 +47,7 @@ describe WorkOS::SSO do
47
47
  redirect_uri: 'foo.com/auth/callback',
48
48
  state: {
49
49
  next_page: '/dashboard/edit',
50
- },
50
+ }.to_s,
51
51
  }
52
52
  end
53
53
  it 'returns a valid URL' do
@@ -80,7 +80,7 @@ describe WorkOS::SSO do
80
80
  redirect_uri: 'foo.com/auth/callback',
81
81
  state: {
82
82
  next_page: '/dashboard/edit',
83
- },
83
+ }.to_s,
84
84
  }
85
85
  end
86
86
  it 'raises an error' do
@@ -101,7 +101,7 @@ describe WorkOS::SSO do
101
101
  redirect_uri: 'foo.com/auth/callback',
102
102
  state: {
103
103
  next_page: '/dashboard/edit',
104
- },
104
+ }.to_s,
105
105
  }
106
106
  end
107
107
  it 'raises an error' do
@@ -211,7 +211,53 @@ describe WorkOS::SSO do
211
211
  end
212
212
  end
213
213
 
214
+ describe '.create_connection' do
215
+ before(:all) do
216
+ WorkOS.key = 'key'
217
+ end
218
+
219
+ after(:all) do
220
+ WorkOS.key = nil
221
+ end
222
+
223
+ context 'with a valid source' do
224
+ it 'creates a connection' do
225
+ VCR.use_cassette('sso/create_connection_with_valid_source') do
226
+ connection = WorkOS::SSO.create_connection(
227
+ source: 'draft_conn_01E6PK87QP6NQ29RRX0G100YGV',
228
+ )
229
+
230
+ expect(connection.id).to eq('conn_01E4F9T2YWZFD218DN04KVFDSY')
231
+ expect(connection.connection_type).to eq('GoogleOAuth')
232
+ expect(connection.name).to eq('Foo Corp')
233
+ expect(connection.domains.first[:domain]).to eq('example.com')
234
+ end
235
+ end
236
+ end
237
+
238
+ context 'with an invalid source' do
239
+ it 'raises an error' do
240
+ VCR.use_cassette('sso/create_connection_with_invalid_source') do
241
+ expect do
242
+ WorkOS::SSO.create_connection(source: 'invalid')
243
+ end.to raise_error(
244
+ WorkOS::APIError,
245
+ 'Status 404, Not Found - request ID: ',
246
+ )
247
+ end
248
+ end
249
+ end
250
+ end
251
+
214
252
  describe '.promote_draft_connection' do
253
+ before(:all) do
254
+ WorkOS.key = 'key'
255
+ end
256
+
257
+ after(:all) do
258
+ WorkOS.key = nil
259
+ end
260
+
215
261
  let(:token) { 'draft_conn_id' }
216
262
  let(:project_id) { 'proj_0239u590h' }
217
263
 
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.workos.com/directory_groups/directory_grp_01E64QTDNS0EGJ0FMCVY9BWGZT
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ User-Agent:
17
+ - WorkOS; ruby/2.7.1; x86_64-darwin19; v0.2.3
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - Cowboy
27
+ Connection:
28
+ - keep-alive
29
+ Vary:
30
+ - Origin, Accept-Encoding
31
+ Access-Control-Allow-Credentials:
32
+ - 'true'
33
+ X-Dns-Prefetch-Control:
34
+ - 'off'
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ Strict-Transport-Security:
38
+ - max-age=15552000; includeSubDomains
39
+ X-Download-Options:
40
+ - noopen
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Xss-Protection:
44
+ - 1; mode=block
45
+ X-Request-Id:
46
+ - 4fb94ab3-ecff-4cea-b0b7-d4d1b3ffad3a
47
+ Content-Type:
48
+ - application/json; charset=utf-8
49
+ Content-Length:
50
+ - '65'
51
+ Etag:
52
+ - W/"41-QrnAKhorJuUwAsR1OyMpfB8q1Kc"
53
+ Date:
54
+ - Thu, 30 Apr 2020 04:47:49 GMT
55
+ Via:
56
+ - 1.1 vegur
57
+ body:
58
+ encoding: UTF-8
59
+ string: '{"id":"directory_grp_01E64QTDNS0EGJ0FMCVY9BWGZT","name":"Walrus"}'
60
+ http_version:
61
+ recorded_at: Thu, 30 Apr 2020 04:47:49 GMT
62
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.workos.com/directory_groups/invalid
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ User-Agent:
17
+ - WorkOS; ruby/2.7.1; x86_64-darwin19; v0.2.3
18
+ Authorization:
19
+ - Bearer <API_KEY>
20
+ response:
21
+ status:
22
+ code: 404
23
+ message: Not Found
24
+ headers:
25
+ Server:
26
+ - Cowboy
27
+ Connection:
28
+ - keep-alive
29
+ Vary:
30
+ - Origin, Accept-Encoding
31
+ Access-Control-Allow-Credentials:
32
+ - 'true'
33
+ X-Dns-Prefetch-Control:
34
+ - 'off'
35
+ X-Frame-Options:
36
+ - SAMEORIGIN
37
+ Strict-Transport-Security:
38
+ - max-age=15552000; includeSubDomains
39
+ X-Download-Options:
40
+ - noopen
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Xss-Protection:
44
+ - 1; mode=block
45
+ X-Request-Id:
46
+ - bbf92391-32bd-4d77-bbdc-0e77983d04d4
47
+ Content-Type:
48
+ - application/json; charset=utf-8
49
+ Content-Length:
50
+ - '23'
51
+ Etag:
52
+ - W/"17-SuRA/yvUWUo8rK6x7dKURLeBo+0"
53
+ Date:
54
+ - Thu, 30 Apr 2020 04:48:28 GMT
55
+ Via:
56
+ - 1.1 vegur
57
+ body:
58
+ encoding: UTF-8
59
+ string: '{"message":"Not Found"}'
60
+ http_version:
61
+ recorded_at: Thu, 30 Apr 2020 04:48:28 GMT
62
+ recorded_with: VCR 5.0.0