Пример #1
0
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
Пример #2
0
def test_auto_login(auth_session: auth.AuthSession):
    assert not auth_session.is_authenticated
    auth_header = auth_session.authenticate()
    assert auth_header["Authorization"] == "Bearer AdminAccessToken"
    assert auth_session.is_authenticated

    # even after explicit logout
    auth_session.logout()
    assert not auth_session.is_authenticated
    auth_header = auth_session.authenticate()
    assert isinstance(auth_header, dict)
    assert auth_header["Authorization"] == "Bearer AdminAccessToken"
    assert auth_session.is_authenticated
Пример #3
0
def test_auto_login_with_transport_options(auth_session: auth.AuthSession):
    assert not auth_session.is_authenticated
    auth_header = auth_session.authenticate({"headers": {"foo": "bar"}})
    assert auth_header["Authorization"] == "Bearer AdminAccessToken"
    assert auth_session.is_authenticated