|
160 | 160 | end |
161 | 161 |
|
162 | 162 | Given /^the current account has SSO (?:configured|stubbed) for "([^\"]*)"$/ do |domain| |
163 | | - allow(WorkOS::SSO).to receive(:authorization_url).and_wrap_original do |*, domain_hint:, login_hint:, **| |
164 | | - "https://api.workos.test/sso/authorize?domain_hint=#{domain_hint}&login_hint=#{login_hint}" |
| 163 | + allow(WorkOS::SSO).to receive(:authorization_url).and_wrap_original do |*, domain_hint:, login_hint:, state:, **| |
| 164 | + dec = Keygen::EE::SSO.decrypt_state(state, secret_key: @account.secret_key) |
| 165 | + enc = Base64.urlsafe_encode64(dec.to_json, padding: false) |
| 166 | + |
| 167 | + "https://api.workos.test/sso/authorize?domain_hint=#{domain_hint}&login_hint=#{login_hint}&state=#{enc}" |
165 | 168 | end |
166 | 169 |
|
167 | 170 | @account.update!( |
|
171 | 174 | end |
172 | 175 |
|
173 | 176 | Given /^the account "([^\"]*)" has SSO (?:configured|stubbed) for "([^\"]*)"$/ do |id, domain| |
174 | | - allow(WorkOS::SSO).to receive(:authorization_url).and_wrap_original do |*, domain_hint:, login_hint:, **| |
175 | | - "https://api.workos.test/sso/authorize?domain_hint=#{domain_hint}&login_hint=#{login_hint}" |
176 | | - end |
177 | | - |
178 | 177 | account = FindByAliasService.call(Account, id:, aliases: :slug) |
179 | 178 |
|
| 179 | + allow(WorkOS::SSO).to receive(:authorization_url).and_wrap_original do |*, domain_hint:, login_hint:, state:, **| |
| 180 | + dec = Keygen::EE::SSO.decrypt_state(state, secret_key: account.secret_key) |
| 181 | + enc = Base64.urlsafe_encode64(dec.to_json, padding: false) |
| 182 | + |
| 183 | + "https://api.workos.test/sso/authorize?domain_hint=#{domain_hint}&login_hint=#{login_hint}&state=#{enc}" |
| 184 | + end |
| 185 | + |
180 | 186 | account.update!( |
181 | 187 | sso_organization_id: account.sso_organization_id.presence || "test_org_#{SecureRandom.hex}", |
182 | 188 | sso_organization_domains: account.sso_organization_domains.presence || [domain], |
|
0 commit comments