Skip to content

Fix the OAuth2 PKCE registration test now that verify defaults to the CA bundle. - #10722

Closed
dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:fix/issue-10721-oauth2-ca-test
Closed

dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:fix/issue-10721-oauth2-ca-test

Conversation

@dpage

@dpage dpage commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Oauth2LoginMockTestCase (the PKCE case) still asserted that client_kwargs['verify'] defaults to True, but since #10699 OAuth2Authentication uses get_ca_file() or True, so the test failed whenever certifi's bundle was found. The code is correct; the test was stale.

The test now patches pgadmin.authenticate.oauth2.get_ca_file and checks both branches: a bundle path is passed through as verify, and None falls back to True.

Test plan

  • regression/runtests.py --pkg browser.tests.test_oauth2_with_mocking passes locally (31 tests, PostgreSQL 18)
  • pycodestyle clean

Closes #10721

Summary by CodeRabbit

  • Tests
    • Expanded OAuth authentication test coverage to verify certificate handling with and without a configured CA bundle.
    • Retained checks for PKCE, response type, and scope settings.

… CA bundle. pgadmin-org#10721

Since pgadmin-org#10699, OAuth2Authentication replaces a default verify of True
with get_ca_file() or True, so the test's assertion that verify is True
failed whenever certifi's bundle was found. Patch get_ca_file() and
check both the bundle path and the fallback to True.

Closes pgadmin-org#10721
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The PKCE registration test now checks OAuth client verification with a configured CA bundle and when no CA bundle is available. It retains the existing PKCE method, response type, and scope assertions.

Changes

OAuth2 PKCE test

Layer / File(s) Summary
PKCE verification assertions
web/pgadmin/browser/tests/test_oauth2_with_mocking.py
The test checks that client_kwargs['verify'] matches the CA bundle path when configured and is True when no CA bundle is available. It retains the PKCE method, response type, and scope assertions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other · Severity of issue fixed: Low

Possibly related PRs

Suggested reviewers: albundy83, asheshv

Merge Risk: Minimal · up to 437e7

The test now covers both CA-bundle outcomes. No merge-blocking issue was identified.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the change in the test: it fixes the OAuth2 PKCE registration test so it matches the new default where verify uses the CA bundle. The raw summary says the test now checks both a config…
Linked Issues check Passed Issue #10721 requires that the PKCE registration test in web/pgadmin/browser/tests/test_oauth2_with_mocking.py patch pgadmin.authenticate.oauth2.get_ca_file and check both outcomes. The diff at head d…
Out of Scope Changes check Passed The whole-PR diff against the merge base 4e23e81 changes only web/pgadmin/browser/tests/test_oauth2_with_mocking.py, as reported in the raw summary (+28/-16). The edit…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Title check

Explanation

The title names the change in the test: it fixes the OAuth2 PKCE registration test so it matches the new default where verify uses the CA bundle. The raw summary says the test now checks both a configured CA bundle and no bundle, with verify set to the CA path or True. The title is specific to the main change and does not list files. It is a concise, single sentence.

Full details: Linked Issues check

Explanation

Issue #10721 requires that the PKCE registration test in web/pgadmin/browser/tests/test_oauth2_with_mocking.py patch pgadmin.authenticate.oauth2.get_ca_file and check both outcomes. The diff at head does this in _test_oauth2_authentication_with_pkce. A loop runs two cases: ('/path/to/ca-bundle.pem', '/path/to/ca-bundle.pem') and (None, True). Each case patches get_ca_file in the oauth2 module namespace, then asserts client_kwargs['verify'] equals the expected value. The existing assertions for code_challenge_method S256, response_type code, and scope 'openid email profile' remain. The reviewed head implementation in web/pgadmin/authenticate/oauth2.py sets verify = get_ca_file() or True when OAUTH2_SSL_CERT_VERIFICATION is True. It calls get_ca_file through the module-level import, so the patch takes effect. The test therefore matches the current code behavior that #10721 describes as intended. The PR description reports a local run of the test module (31 tests), but I did not execute the tests. This assessment rests on source reading.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base 4e23e81 changes only web/pgadmin/browser/tests/test_oauth2_with_mocking.py, as reported in the raw summary (+28/-16). The edits stay within the PKCE registration test method: a docstring note on the default verify value, the patch of get_ca_file, the two-case loop, and line re-wrapping of the assertions and the OAuth2Authentication import. All of these support the objective in #10721. No production code, configuration, or unrelated tests changed. I did not see a separate file list for the whole PR, so this result relies on the diff and the raw summary.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 4e23e81 and 437e728.

Files selected for processing: 1
  • web/pgadmin/browser/tests/test_oauth2_with_mocking.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

dpage added a commit that referenced this pull request Nov 4, 2026
@dpage

dpage commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged as 7815c9d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Oauth2LoginMockTestCase fails since OAuth2 started verifying against the CA bundle

1 participant