sapling/eden/integration/userinfo_test.py
Adam Simpkins ea7460f2d3 apply the integration test case blacklist to some more tests
Summary:
Add a new IntegrationTestCase base class that checks the test blacklist during
`setUp()`, and update a few remaining test classes that did not derive from
`EdenTestCase` to derive from this.

Also drop the method name argument from the `skip_test_if_blacklisted()`
function, since we can get this from the existing test case argument.

Reviewed By: genevievehelsel

Differential Revision: D21340539

fbshipit-source-id: d4fc125f119d74ab923c2cc3c9070b86c582c87e
2020-05-04 11:46:09 -07:00

26 lines
878 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, testcase
from .lib.find_executables import FindExe
class UserInfoTest(testcase.IntegrationTestCase):
@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, "/usr/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)