✅ Add tests for OAuth2AuthorizationCodeBearer with auto_error=False#15859
Open
Eikentech wants to merge 2 commits into
Open
✅ Add tests for OAuth2AuthorizationCodeBearer with auto_error=False#15859Eikentech wants to merge 2 commits into
OAuth2AuthorizationCodeBearer with auto_error=False#15859Eikentech wants to merge 2 commits into
Conversation
OAuth2AuthorizationCodeBearer with auto_error=False
Member
|
@Eikentech, could you please review the PR description and make it shorter? |
Author
|
@YuriiMotov , I have updated the PR description, pls check. Thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds the missing optional-mode test (mirroring the existing
test_security_oauth2_password_bearer_optional.py) and removes the now-unnecessary# pragma: nocover.The fix
tests/test_security_oauth2_authorization_code_bearer_optional.py—auto_error=False, covering:Authorizationheader → returnsNone(handler returns the "create an account" message),Bearertoken → returns the token,Bearerscheme → returnsNone,# pragma: nocoveron thereturn Noneline, since the branch is now genuinely covered.Notes
This is a coverage-consistency fix, not a behaviour change —
fastapi/security/oauth2.pyruntime behaviour isunchanged; the PR only adds the missing test for an already-documented branch and drops the coverage-exclusion
pragma it was hidden behind.