Skip to content

Commit 98efee3

Browse files
hsbtclaude
andcommitted
Assert webauthn request auth instead of last request
test_with_webauthn_enabled_failure checked the Authorization header on @stub_fetcher.last_request, but the webauthn flow runs a real polling thread that issues its own request concurrently. On Rubies without a GIL the poll request can land last, so last_request was not the webauthn_verification request and the assertion saw a nil header. Look up the webauthn_verification request explicitly and assert on its Authorization header, which the main thread always records. This is the invariant the test means to check and it is no longer order dependent, so the TruffleRuby pend that papered over the same race can go too. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7bc41a2 commit 98efee3

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

test/rubygems/test_gem_commands_owner_command.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,6 @@ def test_with_webauthn_enabled_success
399399
end
400400

401401
def test_with_webauthn_enabled_failure
402-
pend "Flaky on TruffleRuby" if RUBY_ENGINE == "truffleruby"
403402
response_success = "Owner added successfully."
404403
server = Gem::MockTCPServer.new
405404
error = Gem::WebauthnVerificationError.new("Something went wrong")
@@ -417,7 +416,8 @@ def test_with_webauthn_enabled_failure
417416
end
418417
end
419418

420-
assert_match @stub_fetcher.last_request["Authorization"], Gem.configuration.rubygems_api_key
419+
webauthn_verification_request = @stub_fetcher.requests.find {|req| req.path == "/api/v1/webauthn_verification" }
420+
assert_match webauthn_verification_request["Authorization"], Gem.configuration.rubygems_api_key
421421
assert_match "You have enabled multi-factor authentication. Please visit the following URL " \
422422
"to authenticate via security device. If you can't verify using WebAuthn but have OTP enabled, " \
423423
"you can re-run the gem signin command with the `--otp [your_code]` option.", @stub_ui.output

0 commit comments

Comments
 (0)