Example #1
0
def sudo(username=None, login=False):
    old_forced = env.sudo_forced
    old_user = env.sudo_user
    old_shell = env.shell

    env.sudo_forced = True
    env.sudo_user = username

    if login:
        with sudo():
            user_shell = user.shell(username)
        env.shell = "-i %s -i -c" % user_shell

    yield

    env.sudo_forced = old_forced
    env.sudo_user = old_user
    env.shell = old_shell
Example #2
0
def test_shell_abort_on_error(get, abort):
    get.expects_call().with_args("user").returns(None)
    abort.expects_call().with_args("User 'user' does not exists")
    assert not user.shell("user")
Example #3
0
def test_shell(get):
    get.expects_call().with_args("user").returns({"shell": "bar"})
    assert user.shell("user") == "bar"