def test__get_uid_gid(monkeypatch, env_uid, env_gid, cwd_uid, cwd_gid, expected): monkeypatch.setattr("doppelganger.util.get_id_from_env", _mock.create_autospec(_util.get_id_from_env)) monkeypatch.setattr( "doppelganger.util.get_uid_gid_from_filesystem", _mock.create_autospec(_util.get_uid_gid_from_filesystem), ) _util.get_id_from_env.side_effect = {"UID": env_uid, "GID": env_gid}.get _util.get_uid_gid_from_filesystem.return_value = (cwd_uid, cwd_gid) result = _util.get_uid_gid() assert result == expected
def main(): uid, gid = _util.get_uid_gid() ctx = _context.Context(_context.User(None, uid), _context.Group(None, gid)) # Run each hook. for hook in _hook.get_hooks(): hook.run(ctx) # Become whatever `ARGS` wants us to be. _os.execv( "/usr/bin/sudo", _util.sudo_args(uid, gid) + _sys.argv[1:], )