Files
chromium_depot_tools/tests
Jiewei Qian e2bb3cd558 tests: refactor CookiesAuthenticator mock
This CL refactors _test_gerrit_ensure_authenticated_common by splitting
it into:

- The actual mock and common code path
- Test case specific setup (e.g. scm.GIT.SetConfig)

In addition, fixes a few issues with the existing code:

- _Authenticator.get() is now mocked correctly, so a CookiesAuthenticator
  is returned in relevant tests. Previously it returned the "production"
  ChainedAuthenticator, which could call other authenticators (such as
  GitCredsAuthenticator based on the runtime environment)
- Adds mock patch cleanup functions. Previously, cleanup functions
  aren't registered, so the mock leaks and got overwritten by other test
  cases.
- Rewrite 'Bearer' in Authorization header check to be more robust.
  Previously, the test case raise a KeyError exception when the
  Authorization header isn't set at all in request headers.

This is a preparation CL for implementing ensure_authenticated() method
in ChainedAuthenticator and GitCredsAuthenticator in future CLs.

Bug: 348024314
Change-Id: I28a7fabbc6cf2dc33dccc1339b89d20a22dc12ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7082265
Commit-Queue: Jiewei Qian <qjw@chromium.org>
Reviewed-by: Scott Lee <ddoman@chromium.org>
2025-10-27 15:45:01 -07:00
..
2025-09-16 00:15:47 -07:00
2023-09-05 20:24:16 +00:00
2024-03-26 14:24:43 +00:00
2025-04-01 15:18:44 -07:00
2024-08-19 19:53:47 +00:00
2025-09-03 19:03:18 -07:00
2023-09-25 17:13:00 +00:00
2025-09-03 19:03:18 -07:00