workos 2.3.0 → 2.5.1

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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/README.md +4 -1
  4. data/lib/workos/audit_trail.rb +0 -1
  5. data/lib/workos/client.rb +14 -5
  6. data/lib/workos/configuration.rb +17 -0
  7. data/lib/workos/directory_group.rb +5 -1
  8. data/lib/workos/directory_sync.rb +0 -1
  9. data/lib/workos/directory_user.rb +7 -1
  10. data/lib/workos/errors.rb +3 -0
  11. data/lib/workos/mfa.rb +22 -7
  12. data/lib/workos/organizations.rb +0 -1
  13. data/lib/workos/passwordless.rb +0 -1
  14. data/lib/workos/portal.rb +0 -1
  15. data/lib/workos/sso.rb +1 -2
  16. data/lib/workos/types/directory_group_struct.rb +1 -0
  17. data/lib/workos/types/directory_user_struct.rb +2 -0
  18. data/lib/workos/types/{verify_factor_struct.rb → verify_challenge_struct.rb} +3 -3
  19. data/lib/workos/types.rb +1 -1
  20. data/lib/workos/{verify_factor.rb → verify_challenge.rb} +5 -6
  21. data/lib/workos/version.rb +1 -1
  22. data/lib/workos.rb +17 -7
  23. data/spec/lib/workos/configuration_spec.rb +61 -0
  24. data/spec/lib/workos/directory_sync_spec.rb +4 -1
  25. data/spec/lib/workos/mfa_spec.rb +93 -74
  26. data/spec/lib/workos/sso_spec.rb +1 -1
  27. data/spec/spec_helper.rb +2 -2
  28. data/spec/support/fixtures/vcr_cassettes/directory_sync/get_group.yml +10 -12
  29. data/spec/support/fixtures/vcr_cassettes/directory_sync/get_user.yml +28 -31
  30. data/spec/support/fixtures/vcr_cassettes/mfa/challenge_factor_generic_valid.yml +2 -2
  31. data/spec/support/fixtures/vcr_cassettes/mfa/challenge_factor_sms_valid.yml +2 -2
  32. data/spec/support/fixtures/vcr_cassettes/mfa/challenge_factor_totp_valid.yml +2 -2
  33. data/spec/support/fixtures/vcr_cassettes/mfa/{verify_factor_generic_expired.yml → verify_challenge_generic_expired.yml} +2 -2
  34. data/spec/support/fixtures/vcr_cassettes/mfa/{verify_factor_generic_invalid.yml → verify_challenge_generic_invalid.yml} +2 -2
  35. data/spec/support/fixtures/vcr_cassettes/mfa/{verify_factor_generic_valid.yml → verify_challenge_generic_valid.yml} +2 -2
  36. data/spec/support/fixtures/vcr_cassettes/mfa/{verify_factor_generic_valid_is_false.yml → verify_challenge_generic_valid_is_false.yml} +2 -2
  37. data/spec/support/shared_examples/client_spec.rb +14 -0
  38. metadata +16 -16
  39. data/lib/workos/base.rb +0 -18
  40. data/spec/lib/workos/base_spec.rb +0 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7abb4f1d075ea976bbc8577247d36ff763a21dd1b18335daac39a8c80d6acea
4
- data.tar.gz: 4c8e6326e7b80773a292754a7030033773470dc12228571cad8b0198a3c8342b
3
+ metadata.gz: efe8fb9e00262c08d11cebcc39e65ad5728771bb1f132ea88302c78205134a3b
4
+ data.tar.gz: 1532164858cc02a9e46d9cb8ac0c10b0e5401812da204840cd3760342462bfb7
5
5
  SHA512:
6
- metadata.gz: 7d4c51f21848cb44e0f0326deab050040989811f829b4bbf1c317aca9d08e113c47bd4dbd822faac3f195d8695204fd3acb9a797638a0d9c4f951100964a53e7
7
- data.tar.gz: 2b25fd19c5008c27d03a9ab73f6dcb02ba2cd7f133d0726ce46ccadb4928e2805dca1f63dbefd9552ea7ee8ea9acf122a7641dabf48e5199f4f607dcb8754c46
6
+ metadata.gz: bd4c7ada118af7b5ee60d28db25844264bda9a8249b0b3d0a33c11696c77f57d020cfe6e7410d4661bb7c3832e0ec83af2acc0468b4dc4b21e633a5af12bec16
7
+ data.tar.gz: 8ecebf2811768a093ae87518124b4e1ff8bb3caefbc3ed1ff36ea0a81243030968bf204d535c63422e43718d811f13c682ad058c33e132977b283509457e30f3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workos (2.3.0)
4
+ workos (2.5.1)
5
5
  sorbet-runtime (~> 0.5)
6
6
 
7
7
  GEM
@@ -60,7 +60,7 @@ GEM
60
60
  simplecov_json_formatter (0.1.2)
61
61
  sorbet (0.5.6388)
62
62
  sorbet-static (= 0.5.6388)
63
- sorbet-runtime (0.5.10090)
63
+ sorbet-runtime (0.5.10323)
64
64
  sorbet-static (0.5.6388-universal-darwin-14)
65
65
  sorbet-static (0.5.6388-universal-darwin-15)
66
66
  sorbet-static (0.5.6388-universal-darwin-16)
data/README.md CHANGED
@@ -35,7 +35,10 @@ Or, you may set the key yourself, such as in an initializer in your application
35
35
  ```ruby
36
36
  # /config/initializers/workos.rb
37
37
 
38
- WorkOS.key = '[your api key]'
38
+ WorkOS.configure do |config|
39
+ config.key = '[your api key]'
40
+ config.timeout = 120
41
+ end
39
42
  ```
40
43
 
41
44
  ## SDK Versioning
@@ -12,7 +12,6 @@ module WorkOS
12
12
  module AuditTrail
13
13
  class << self
14
14
  extend T::Sig
15
- include Base
16
15
  include Client
17
16
 
18
17
  # Create an Audit Trail event.
data/lib/workos/client.rb CHANGED
@@ -11,6 +11,9 @@ module WorkOS
11
11
  def client
12
12
  Net::HTTP.new(WorkOS::API_HOSTNAME, 443).tap do |http_client|
13
13
  http_client.use_ssl = true
14
+ http_client.open_timeout = WorkOS.config.timeout
15
+ http_client.read_timeout = WorkOS.config.timeout
16
+ http_client.write_timeout = WorkOS.config.timeout if RUBY_VERSION >= '2.6.0'
14
17
  end
15
18
  end
16
19
 
@@ -20,7 +23,13 @@ module WorkOS
20
23
  ).returns(::T.untyped)
21
24
  end
22
25
  def execute_request(request:)
23
- response = client.request(request)
26
+ begin
27
+ response = client.request(request)
28
+ rescue Net::OpenTimeout, Net::ReadTimeout, Net::WriteTimeout
29
+ raise TimeoutError.new(
30
+ message: 'API Timeout Error',
31
+ )
32
+ end
24
33
 
25
34
  http_status = response.code.to_i
26
35
  handle_error_response(response: response) if http_status >= 400
@@ -45,7 +54,7 @@ module WorkOS
45
54
  'Content-Type' => 'application/json',
46
55
  )
47
56
 
48
- request['Authorization'] = "Bearer #{access_token || WorkOS.key!}" if auth
57
+ request['Authorization'] = "Bearer #{access_token || WorkOS.config.key!}" if auth
49
58
  request['User-Agent'] = user_agent
50
59
  request
51
60
  end
@@ -61,7 +70,7 @@ module WorkOS
61
70
  def post_request(path:, auth: false, idempotency_key: nil, body: nil)
62
71
  request = Net::HTTP::Post.new(path, 'Content-Type' => 'application/json')
63
72
  request.body = body.to_json if body
64
- request['Authorization'] = "Bearer #{WorkOS.key!}" if auth
73
+ request['Authorization'] = "Bearer #{WorkOS.config.key!}" if auth
65
74
  request['Idempotency-Key'] = idempotency_key if idempotency_key
66
75
  request['User-Agent'] = user_agent
67
76
  request
@@ -83,7 +92,7 @@ module WorkOS
83
92
  'Content-Type' => 'application/json',
84
93
  )
85
94
 
86
- request['Authorization'] = "Bearer #{WorkOS.key!}" if auth
95
+ request['Authorization'] = "Bearer #{WorkOS.config.key!}" if auth
87
96
  request['User-Agent'] = user_agent
88
97
  request
89
98
  end
@@ -99,7 +108,7 @@ module WorkOS
99
108
  def put_request(path:, auth: false, idempotency_key: nil, body: nil)
100
109
  request = Net::HTTP::Put.new(path, 'Content-Type' => 'application/json')
101
110
  request.body = body.to_json if body
102
- request['Authorization'] = "Bearer #{WorkOS.key!}" if auth
111
+ request['Authorization'] = "Bearer #{WorkOS.config.key!}" if auth
103
112
  request['Idempotency-Key'] = idempotency_key if idempotency_key
104
113
  request['User-Agent'] = user_agent
105
114
  request
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ # typed: true
3
+
4
+ module WorkOS
5
+ # Configuration class sets config initializer
6
+ class Configuration
7
+ attr_accessor :timeout, :key
8
+
9
+ def initialize
10
+ @timeout = 60
11
+ end
12
+
13
+ def key!
14
+ key or raise '`WorkOS.config.key` not set'
15
+ end
16
+ end
17
+ end
@@ -9,7 +9,8 @@ module WorkOS
9
9
  include HashProvider
10
10
  extend T::Sig
11
11
 
12
- attr_accessor :id, :directory_id, :idp_id, :name, :created_at, :updated_at, :raw_attributes
12
+ attr_accessor :id, :directory_id, :idp_id, :name, :created_at, :updated_at,
13
+ :raw_attributes, :organization_id
13
14
 
14
15
  # rubocop:disable Metrics/AbcSize
15
16
  sig { params(json: String).void }
@@ -18,6 +19,7 @@ module WorkOS
18
19
 
19
20
  @id = T.let(raw.id, String)
20
21
  @directory_id = T.let(raw.directory_id, String)
22
+ @organization_id = raw.organization_id
21
23
  @idp_id = T.let(raw.idp_id, String)
22
24
  @name = T.let(raw.name, String)
23
25
  @created_at = T.let(raw.created_at, String)
@@ -32,6 +34,7 @@ module WorkOS
32
34
  {
33
35
  id: id,
34
36
  directory_id: directory_id,
37
+ organization_id: organization_id,
35
38
  idp_id: idp_id,
36
39
  name: name,
37
40
  created_at: created_at,
@@ -53,6 +56,7 @@ module WorkOS
53
56
  WorkOS::Types::DirectoryGroupStruct.new(
54
57
  id: hash[:id],
55
58
  directory_id: hash[:directory_id],
59
+ organization_id: hash[:organization_id],
56
60
  idp_id: hash[:idp_id],
57
61
  name: hash[:name],
58
62
  created_at: hash[:created_at],
@@ -12,7 +12,6 @@ module WorkOS
12
12
  module DirectorySync
13
13
  class << self
14
14
  extend T::Sig
15
- include Base
16
15
  include Client
17
16
 
18
17
  # Retrieve directories.
@@ -10,7 +10,7 @@ module WorkOS
10
10
  extend T::Sig
11
11
 
12
12
  attr_accessor :id, :idp_id, :emails, :first_name, :last_name, :username, :state,
13
- :groups, :custom_attributes, :raw_attributes
13
+ :groups, :custom_attributes, :raw_attributes, :directory_id, :organization_id
14
14
 
15
15
  # rubocop:disable Metrics/AbcSize
16
16
  sig { params(json: String).void }
@@ -18,6 +18,8 @@ module WorkOS
18
18
  raw = parse_json(json)
19
19
 
20
20
  @id = T.let(raw.id, String)
21
+ @directory_id = T.let(raw.directory_id, String)
22
+ @organization_id = raw.organization_id
21
23
  @idp_id = T.let(raw.idp_id, String)
22
24
  @emails = T.let(raw.emails, Array)
23
25
  @first_name = raw.first_name
@@ -35,6 +37,8 @@ module WorkOS
35
37
  def to_json(*)
36
38
  {
37
39
  id: id,
40
+ directory_id: directory_id,
41
+ organization_id: organization_id,
38
42
  idp_id: idp_id,
39
43
  emails: emails,
40
44
  first_name: first_name,
@@ -64,6 +68,8 @@ module WorkOS
64
68
 
65
69
  WorkOS::Types::DirectoryUserStruct.new(
66
70
  id: hash[:id],
71
+ directory_id: hash[:directory_id],
72
+ organization_id: hash[:organization_id],
67
73
  idp_id: hash[:idp_id],
68
74
  emails: hash[:emails],
69
75
  first_name: hash[:first_name],
data/lib/workos/errors.rb CHANGED
@@ -61,4 +61,7 @@ module WorkOS
61
61
  # SignatureVerificationError is raised when the signature verification for a
62
62
  # webhook fails
63
63
  class SignatureVerificationError < WorkOSError; end
64
+
65
+ # TimeoutError is raised when the HTTP request to the API times out
66
+ class TimeoutError < WorkOSError; end
64
67
  end
data/lib/workos/mfa.rb CHANGED
@@ -11,7 +11,6 @@ module WorkOS
11
11
  module MFA
12
12
  class << self
13
13
  extend T::Sig
14
- include Base
15
14
  include Client
16
15
  sig { params(id: String).returns(T::Boolean) }
17
16
  def delete_factor(id:)
@@ -122,9 +121,8 @@ module WorkOS
122
121
  auth: true,
123
122
  body: {
124
123
  sms_template: sms_template,
125
- authentication_factor_id: authentication_factor_id,
126
124
  },
127
- path: '/auth/factors/challenge',
125
+ path: "/auth/factors/#{authentication_factor_id}/challenge",
128
126
  )
129
127
 
130
128
  response = execute_request(request: request)
@@ -135,30 +133,47 @@ module WorkOS
135
133
  params(
136
134
  authentication_challenge_id: T.nilable(String),
137
135
  code: T.nilable(String),
138
- ).returns(WorkOS::VerifyFactor)
136
+ ).returns(WorkOS::VerifyChallenge)
139
137
  end
140
138
  def verify_factor(
141
139
  authentication_challenge_id: nil,
142
140
  code: nil
143
141
  )
142
+ warn '[DEPRECATION] `verify_factor` is deprecated. Please use `verify_challenge` instead.'
143
+
144
+ verify_challenge(
145
+ authentication_challenge_id: authentication_challenge_id,
146
+ code: code,
147
+ )
148
+ end
149
+
150
+ sig do
151
+ params(
152
+ authentication_challenge_id: T.nilable(String),
153
+ code: T.nilable(String),
154
+ ).returns(WorkOS::VerifyChallenge)
155
+ end
156
+ def verify_challenge(
157
+ authentication_challenge_id: nil,
158
+ code: nil
159
+ )
144
160
 
145
161
  if authentication_challenge_id.nil? || code.nil?
146
162
  raise ArgumentError, "Incomplete arguments: 'authentication_challenge_id' and 'code' are required arguments"
147
163
  end
148
164
 
149
165
  options = {
150
- "authentication_challenge_id": authentication_challenge_id,
151
166
  "code": code,
152
167
  }
153
168
 
154
169
  response = execute_request(
155
170
  request: post_request(
156
- path: '/auth/factors/verify',
171
+ path: "/auth/challenges/#{authentication_challenge_id}/verify",
157
172
  auth: true,
158
173
  body: options,
159
174
  ),
160
175
  )
161
- WorkOS::VerifyFactor.new(response.body)
176
+ WorkOS::VerifyChallenge.new(response.body)
162
177
  end
163
178
  end
164
179
  end
@@ -8,7 +8,6 @@ module WorkOS
8
8
  module Organizations
9
9
  class << self
10
10
  extend T::Sig
11
- include Base
12
11
  include Client
13
12
 
14
13
  # Retrieve a list of organizations that have connections configured
@@ -12,7 +12,6 @@ module WorkOS
12
12
  module Passwordless
13
13
  class << self
14
14
  extend T::Sig
15
- include Base
16
15
  include Client
17
16
 
18
17
  # Create a Passwordless Session.
data/lib/workos/portal.rb CHANGED
@@ -9,7 +9,6 @@ module WorkOS
9
9
  module Portal
10
10
  class << self
11
11
  extend T::Sig
12
- include Base
13
12
  include Client
14
13
 
15
14
  GENERATE_LINK_INTENTS = WorkOS::Types::Intent.values.map(&:serialize).
data/lib/workos/sso.rb CHANGED
@@ -13,7 +13,6 @@ module WorkOS
13
13
  module SSO
14
14
  class << self
15
15
  extend T::Sig
16
- include Base
17
16
  include Client
18
17
 
19
18
  PROVIDERS = WorkOS::Types::Provider.values.map(&:serialize).freeze
@@ -142,7 +141,7 @@ module WorkOS
142
141
  def profile_and_token(code:, client_id: nil)
143
142
  body = {
144
143
  client_id: client_id,
145
- client_secret: WorkOS.key!,
144
+ client_secret: WorkOS.config.key!,
146
145
  grant_type: 'authorization_code',
147
146
  code: code,
148
147
  }
@@ -8,6 +8,7 @@ module WorkOS
8
8
  class DirectoryGroupStruct < T::Struct
9
9
  const :id, String
10
10
  const :directory_id, String
11
+ const :organization_id, T.nilable(String)
11
12
  const :idp_id, String
12
13
  const :name, String
13
14
  const :created_at, String
@@ -7,6 +7,8 @@ module WorkOS
7
7
  # for the DirectoryUser class
8
8
  class DirectoryUserStruct < T::Struct
9
9
  const :id, String
10
+ const :directory_id, String
11
+ const :organization_id, T.nilable(String)
10
12
  const :idp_id, String
11
13
  const :emails, T::Array[T.untyped]
12
14
  const :first_name, T.nilable(String)
@@ -3,9 +3,9 @@
3
3
 
4
4
  module WorkOS
5
5
  module Types
6
- # This VerifyFactorStruct acts as a typed interface
7
- # for the Factor class
8
- class VerifyFactorStruct < T::Struct
6
+ # This VerifyChallengeStruct acts as a typed interface
7
+ # for the VerifyChallenge class
8
+ class VerifyChallengeStruct < T::Struct
9
9
  const :challenge, T.nilable(T::Hash[Symbol, Object])
10
10
  const :valid, T::Boolean
11
11
  end
data/lib/workos/types.rb CHANGED
@@ -18,6 +18,6 @@ module WorkOS
18
18
  require_relative 'types/webhook_struct'
19
19
  require_relative 'types/factor_struct'
20
20
  require_relative 'types/challenge_struct'
21
- require_relative 'types/verify_factor_struct'
21
+ require_relative 'types/verify_challenge_struct'
22
22
  end
23
23
  end
@@ -2,10 +2,9 @@
2
2
  # typed: false
3
3
 
4
4
  module WorkOS
5
- # The VerifyFactor class provides a lightweight wrapper around
6
- # a WorkOS DirectoryUser resource. This class is not meant to be instantiated
7
- # in DirectoryUser space, and is instantiated internally but exposed.
8
- class VerifyFactor
5
+ # The VerifyChallenge class provides a lightweight wrapper around
6
+ # a WorkOS Authentication Challenge resource.
7
+ class VerifyChallenge
9
8
  include HashProvider
10
9
  extend T::Sig
11
10
 
@@ -27,11 +26,11 @@ module WorkOS
27
26
 
28
27
  private
29
28
 
30
- sig { params(json_string: String).returns(WorkOS::Types::VerifyFactorStruct) }
29
+ sig { params(json_string: String).returns(WorkOS::Types::VerifyChallengeStruct) }
31
30
  def parse_json(json_string)
32
31
  hash = JSON.parse(json_string, symbolize_names: true)
33
32
 
34
- WorkOS::Types::VerifyFactorStruct.new(
33
+ WorkOS::Types::VerifyChallengeStruct.new(
35
34
  challenge: hash[:challenge],
36
35
  valid: hash[:valid],
37
36
  )
@@ -2,5 +2,5 @@
2
2
  # typed: strong
3
3
 
4
4
  module WorkOS
5
- VERSION = '2.3.0'
5
+ VERSION = '2.5.1'
6
6
  end
data/lib/workos.rb CHANGED
@@ -5,6 +5,7 @@ require 'workos/version'
5
5
  require 'sorbet-runtime'
6
6
  require 'json'
7
7
  require 'workos/hash_provider'
8
+ require 'workos/configuration'
8
9
 
9
10
  # Use the WorkOS module to authenticate your
10
11
  # requests to the WorkOS API. The gem will read
@@ -16,20 +17,28 @@ module WorkOS
16
17
  API_HOSTNAME = ENV['WORKOS_API_HOSTNAME'] || 'api.workos.com'
17
18
 
18
19
  def self.key=(value)
19
- Base.key = value
20
+ warn '`WorkOS.key=` is deprecated. Use `WorkOS.configure` instead.'
21
+
22
+ config.key = value
20
23
  end
21
24
 
22
25
  def self.key
23
- Base.key
26
+ warn '`WorkOS.key` is deprecated. Use `WorkOS.configure` instead.'
27
+
28
+ config.key
29
+ end
30
+
31
+ def self.config
32
+ @config ||= Configuration.new
24
33
  end
25
34
 
26
- def self.key!
27
- key || raise('WorkOS.key not set')
35
+ def self.configure
36
+ yield(config)
28
37
  end
29
38
 
30
39
  autoload :Types, 'workos/types'
31
- autoload :Base, 'workos/base'
32
40
  autoload :Client, 'workos/client'
41
+ autoload :Configuration, 'workos/configuration'
33
42
  autoload :AuditTrail, 'workos/audit_trail'
34
43
  autoload :Connection, 'workos/connection'
35
44
  autoload :DirectorySync, 'workos/directory_sync'
@@ -48,7 +57,7 @@ module WorkOS
48
57
  autoload :MFA, 'workos/mfa'
49
58
  autoload :Factor, 'workos/factor'
50
59
  autoload :Challenge, 'workos/challenge'
51
- autoload :VerifyFactor, 'workos/verify_factor'
60
+ autoload :VerifyChallenge, 'workos/verify_challenge'
52
61
  autoload :DeprecatedHashWrapper, 'workos/deprecated_hash_wrapper'
53
62
 
54
63
 
@@ -57,9 +66,10 @@ module WorkOS
57
66
  autoload :AuthenticationError, 'workos/errors'
58
67
  autoload :InvalidRequestError, 'workos/errors'
59
68
  autoload :SignatureVerificationError, 'workos/errors'
69
+ autoload :TimeoutError, 'workos/errors'
60
70
 
61
71
  # Remove WORKOS_KEY at some point in the future. Keeping it here now for
62
72
  # backwards compatibility.
63
73
  key = ENV['WORKOS_API_KEY'] || ENV['WORKOS_KEY']
64
- WorkOS.key = key unless key.nil?
74
+ config.key = key unless key.nil?
65
75
  end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+ # typed: false
3
+
4
+ describe WorkOS do
5
+ describe '.configure' do
6
+ context 'with key and no timeout' do
7
+ before do
8
+ WorkOS.configure do |config|
9
+ config.key = 'example_api_key'
10
+ end
11
+ end
12
+
13
+ it 'sets the key and default timeout configuration' do
14
+ expect(WorkOS.config.key).to eq('example_api_key')
15
+ expect(WorkOS.config.timeout).to eq(60)
16
+ end
17
+ end
18
+
19
+ context 'with key and timeout' do
20
+ before do
21
+ WorkOS.configure do |config|
22
+ config.key = 'example_api_key'
23
+ config.timeout = 120
24
+ end
25
+ end
26
+
27
+ it 'sets the key and timeout configuration' do
28
+ expect(WorkOS.config.key).to eq('example_api_key')
29
+ expect(WorkOS.config.timeout).to eq(120)
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ describe WorkOS::Configuration do
36
+ describe '.key!' do
37
+ context 'with key set' do
38
+ before do
39
+ WorkOS.config.key = 'example_api_key'
40
+ end
41
+
42
+ it 'returns the key' do
43
+ expect(WorkOS.config.key!).to eq('example_api_key')
44
+ end
45
+ end
46
+
47
+ context 'with key not set' do
48
+ before do
49
+ WorkOS.config.key = nil
50
+ end
51
+
52
+ it 'throws an error' do
53
+ expect do
54
+ WorkOS.config.key!
55
+ end.to raise_error(
56
+ '`WorkOS.config.key` not set',
57
+ )
58
+ end
59
+ end
60
+ end
61
+ end
@@ -442,11 +442,12 @@ describe WorkOS::DirectorySync do
442
442
  )
443
443
 
444
444
  expect(group['directory_id']).to eq('directory_01G2Z8ADK5NPMVTWF48MVVE4HT')
445
+ expect(group['organization_id']).to eq('org_01EGS4P7QR31EZ4YWD1Z1XA176')
445
446
  expect(group['idp_id']).to eq('01jlao4614two3d')
446
447
  expect(group['name']).to eq('Sales')
447
448
  expect(group.name).to eq('Sales')
448
449
  expect(group['created_at']).to eq('2022-05-13T17:45:31.732Z')
449
- expect(group['updated_at']).to eq('2022-06-07T17:45:35.739Z')
450
+ expect(group['updated_at']).to eq('2022-07-13T17:45:42.618Z')
450
451
  end
451
452
  end
452
453
  end
@@ -471,6 +472,8 @@ describe WorkOS::DirectorySync do
471
472
  )
472
473
 
473
474
  expect(user['first_name']).to eq('Logan')
475
+ expect(user.directory_id).to eq('directory_01FAZYMST676QMTFN1DDJZZX87')
476
+ expect(user.organization_id).to eq('org_01FAZWCWR03DVWA83NCJYKKD54')
474
477
  expect(user.first_name).to eq('Logan')
475
478
  end
476
479
  end