def test_is_sudo(auth_session: auth.AuthSession):
    assert auth_session.is_sudo is None
    auth_session.authenticate()  # auto-login admin
    assert auth_session.is_sudo is None
    auth_session.login_user(5)
    assert auth_session.is_sudo == 5
    auth_session.logout()
    assert auth_session.is_sudo is None
def test_user_login_auto_logs_in_admin(auth_session: auth.AuthSession):
    assert not auth_session.is_admin_authenticated
    assert not auth_session.is_user_authenticated
    auth_session.login_user(5)
    assert auth_session.is_admin_authenticated
    assert auth_session.is_user_authenticated
    auth_header = auth_session.authenticate()
    assert auth_header["Authorization"] == "token UserAccessToken"
示例#3
0
def test_login_sudo_login_sudo(auth_session: auth.AuthSession):
    auth_session.login_user(5)
    with pytest.raises(error.SDKError):
        auth_session.login_user(10)
示例#4
0
def test_sudo_logout_leaves_logged_in(auth_session: auth.AuthSession):
    auth_session.login_user(5)
    auth_session.logout()
    assert not auth_session.is_sudo_authenticated
    assert auth_session.is_authenticated
def test_login_user_login_user(auth_session: auth.AuthSession):
    auth_session.login_user(5)
    with pytest.raises(error.SDKError):  # type: ignore
        auth_session.login_user(10)