mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 00:14:35 +03:00
fbdb46f5cb
Reviewed By: chadaustin Differential Revision: D17872966 fbshipit-source-id: cd60a364a2146f0dadbeca693b1d4a5d7c97ff63
26 lines
853 B
Python
26 lines
853 B
Python
#!/usr/bin/env python3
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2.
|
|
|
|
import os
|
|
import subprocess
|
|
import unittest
|
|
|
|
from .lib import edenclient
|
|
from .lib.find_executables import FindExe
|
|
|
|
|
|
class UserInfoTest(unittest.TestCase):
|
|
@unittest.skipIf(not edenclient.can_run_sudo(), "unable to run sudo")
|
|
def test_drop_privs(self):
|
|
expected_user = os.environ["USER"]
|
|
|
|
cmd = ["/usr/bin/sudo", FindExe.DROP_PRIVS, "/bin/env"]
|
|
out = subprocess.check_output(cmd)
|
|
lines = out.splitlines()
|
|
self.assertIn(f"USER={expected_user}".encode("utf-8"), lines)
|
|
self.assertIn(f"USERNAME={expected_user}".encode("utf-8"), lines)
|
|
self.assertIn(f"LOGNAME={expected_user}".encode("utf-8"), lines)
|