Add simple session management using redis
This commit is contained in:
@@ -3,6 +3,8 @@ import pytest
|
||||
import tornado.web
|
||||
import tornado.gen
|
||||
|
||||
MOCK_USER = {"user": {"id": "438567dd-25fa-4d83-a8cc-8aa8366cb24a"}}
|
||||
|
||||
|
||||
@pytest.mark.gen_test
|
||||
def test_redirects_when_not_logged_in(http_client, base_url):
|
||||
@@ -18,18 +20,16 @@ def test_redirects_when_not_logged_in(http_client, base_url):
|
||||
@pytest.mark.gen_test
|
||||
def test_login_with_valid_bearer_token(app, monkeypatch, http_client, base_url):
|
||||
@tornado.gen.coroutine
|
||||
def _validate_login_token(c, t):
|
||||
return True
|
||||
def _fetch_user_info(c, t):
|
||||
return MOCK_USER
|
||||
|
||||
monkeypatch.setattr(
|
||||
"atst.handlers.login.Login._validate_login_token", _validate_login_token
|
||||
)
|
||||
monkeypatch.setattr("atst.handlers.login.Login._fetch_user_info", _fetch_user_info)
|
||||
response = yield http_client.fetch(
|
||||
base_url + "/login?bearer-token=abc-123",
|
||||
follow_redirects=False,
|
||||
raise_error=False,
|
||||
)
|
||||
assert response.headers["Set-Cookie"].startswith("atst")
|
||||
assert response.headers["Set-Cookie"].startswith("atat")
|
||||
assert response.headers["Location"] == "/home"
|
||||
assert response.code == 302
|
||||
|
||||
@@ -39,7 +39,7 @@ def test_login_via_dev_endpoint(app, http_client, base_url):
|
||||
response = yield http_client.fetch(
|
||||
base_url + "/login-dev", raise_error=False, follow_redirects=False
|
||||
)
|
||||
assert response.headers["Set-Cookie"].startswith("atst")
|
||||
assert response.headers["Set-Cookie"].startswith("atat")
|
||||
assert response.code == 302
|
||||
assert response.headers["Location"] == "/home"
|
||||
|
||||
|
Reference in New Issue
Block a user