ninjalog_uploader.py: use cipd to check authenticated account

Googlers authenticate with CIPD now to use reclient.

This is for
https://crrev.com/c/5035266/20#message-6bcb2d14f6758d0ba82d5cff99d699985c934707

Change-Id: Ie78675e6f7a8b47f7cafd85141f87139d1472f1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5058275
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
changes/75/5058275/6
Takuto Ikuta 2 years ago committed by LUCI CQ
parent 9e5fc28b6b
commit b5393e57bb

@ -51,10 +51,10 @@ ALLOWLISTED_CONFIGS = (
def IsGoogler():
"""Check whether this user is Googler or not."""
p = subprocess.run(
"goma_auth info",
"cipd auth-info",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
text=True,
shell=True,
)
if p.returncode != 0:
@ -63,8 +63,9 @@ def IsGoogler():
if len(lines) == 0:
return False
l = lines[0]
# |l| will be like 'Login as <user>@google.com' for googler using goma.
return l.startswith("Login as ") and l.endswith("@google.com")
# |l| will be like 'Logged in as <user>@google.com.' for googler using
# reclient.
return l.startswith("Logged in as ") and l.endswith("@google.com.")
def ParseGNArgs(gn_args):

@ -19,8 +19,7 @@ class NinjalogUploaderTest(unittest.TestCase):
def test_IsGoogler(self):
with unittest.mock.patch('subprocess.run') as run_mock:
run_mock.return_value.returncode = 0
run_mock.return_value.stdout = ('Login as foo@google.com\n'
'goma is ready to use')
run_mock.return_value.stdout = 'Logged in as foo@google.com.\n'
self.assertTrue(ninjalog_uploader.IsGoogler())
with unittest.mock.patch('subprocess.run') as run_mock:
@ -34,7 +33,7 @@ class NinjalogUploaderTest(unittest.TestCase):
with unittest.mock.patch('subprocess.run') as run_mock:
run_mock.return_value.returncode = 0
run_mock.return_value.stdout = 'Login as foo@example.com\n'
run_mock.return_value.stdout = 'Logged in as foo@example.com.\n'
self.assertFalse(ninjalog_uploader.IsGoogler())
def test_parse_gn_args(self):

Loading…
Cancel
Save