[git-cl] Skip EnsureAuthenticated check for sso:// schemes

Bug: 40276698
Change-Id: I40414607a75287adcacee2ff47f8ba8db4c285c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5325207
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
changes/07/5325207/3
Aravind Vasudevan 1 year ago committed by LUCI CQ
parent d972b831c3
commit af26c1dfaa

@ -2286,9 +2286,15 @@ class Changelist(object):
if remote_url is None:
logging.warning('invalid remote')
return
if urllib.parse.urlparse(remote_url).scheme not in ['https', 'sso']:
parsed_url = urllib.parse.urlparse(remote_url)
if parsed_url.scheme == 'sso':
# Skip checking authentication for projects with sso:// scheme.
return
if parsed_url.scheme != 'https':
logging.warning(
'Ignoring branch %(branch)s with non-https/sso remote '
'Ignoring branch %(branch)s with non-https remote '
'%(remote)s', {
'branch': self.branch,
'remote': self.GetRemoteUrl()

@ -2548,6 +2548,19 @@ class TestGitCl(unittest.TestCase):
cl = self._test_gerrit_ensure_authenticated_common(auth={})
self.assertIsNone(cl.EnsureAuthenticated(force=False))
def test_gerrit_ensure_authenticated_sso(self):
self.mockGit.config['remote.origin.url'] = 'sso://repo'
mock.patch(
'git_cl.gerrit_util.CookiesAuthenticator',
CookiesAuthenticatorMockFactory(hosts_with_creds={})).start()
cl = git_cl.Changelist()
cl.branch = 'main'
cl.branchref = 'refs/heads/main'
cl.lookedup_issue = True
self.assertIsNone(cl.EnsureAuthenticated(force=False))
def test_gerrit_ensure_authenticated_bearer_token(self):
cl = self._test_gerrit_ensure_authenticated_common(
auth={
@ -2559,11 +2572,11 @@ class TestGitCl(unittest.TestCase):
'chromium.googlesource.com')
self.assertTrue('Bearer' in header)
def test_gerrit_ensure_authenticated_non_https(self):
def test_gerrit_ensure_authenticated_non_https_sso(self):
self.mockGit.config['remote.origin.url'] = 'custom-scheme://repo'
self.calls = [
(('logging.warning',
'Ignoring branch %(branch)s with non-https/sso remote '
'Ignoring branch %(branch)s with non-https remote '
'%(remote)s', {
'branch': 'main',
'remote': 'custom-scheme://repo'

Loading…
Cancel
Save