summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJenny Shen <jenny.shen@shopify.com>2023-02-15 10:46:47 -0500
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-04-12 11:57:11 +0900
commitb6e860ba1bae04a1ce269a40ef4731fe52855a16 (patch)
treeef6d68938a3aea831387063efd9b5301856dbeb2 /test
parent774d1f1a0067e16a3dfdd0aed4bae66143de2140 (diff)
downloadruby-b6e860ba1bae04a1ce269a40ef4731fe52855a16.tar.gz
Add wait for webauthn otp when fetching otp
Co-authored-by: Jacques Chester <jacques.chester@shopify.com>
Diffstat (limited to 'test')
-rw-r--r--test/rubygems/test_gem_gemcutter_utilities.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/test/rubygems/test_gem_gemcutter_utilities.rb b/test/rubygems/test_gem_gemcutter_utilities.rb
index 7e10405110..aa876e6ca8 100644
--- a/test/rubygems/test_gem_gemcutter_utilities.rb
+++ b/test/rubygems/test_gem_gemcutter_utilities.rb
@@ -231,10 +231,10 @@ class TestGemGemcutterUtilities < Gem::TestCase
assert_equal "111111", @fetcher.last_request["OTP"]
end
- def test_sign_in_with_webauthn_otp
+ def test_sign_in_with_webauthn_enabled
webauthn_verification_url = "rubygems.org/api/v1/webauthn_verification/odow34b93t6aPCdY"
response_fail = "You have enabled multifactor authentication"
- api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903"
+ api_key = "a5fdbb6ba150cbb83aad2bb2fede64cf040453903"
util_sign_in(proc do
@call_count ||= 0
@@ -243,9 +243,12 @@ class TestGemGemcutterUtilities < Gem::TestCase
else
HTTPResponseFactory.create(body: api_key, code: 200, msg: "OK")
end
- end, nil, [], "111111\n", webauthn_verification_url)
+ end, nil, [], "", webauthn_verification_url)
- assert_match "You have enabled multi-factor authentication. Please enter OTP code from your security device by visiting #{webauthn_verification_url}", @sign_in_ui.output
+ url_with_port = "#{webauthn_verification_url}?port=5678"
+ assert_match "You have enabled multi-factor authentication. Please visit #{url_with_port} to authenticate via security device.", @sign_in_ui.output
+ assert_match "You are verified with a security device. You may close the browser window.", @sign_in_ui.output
+ assert_equal "Uvh6T57tkWuUnWYo", @fetcher.last_request["OTP"]
end
def util_sign_in(response, host = nil, args = [], extra_input = "", webauthn_url = nil)