Compare commits
No commits in common. "7e7111584448d41aaa101440655dc96967910ccb" and "0dfdf70c45d907c12f94422b18fe4f036baf97e0" have entirely different histories.
7e71115844
...
0dfdf70c45
@ -63,9 +63,9 @@ class AuthenticationTestCase(TestCase):
|
||||
|
||||
auth: DigestAuth = DigestAuth(realm=_REALM)
|
||||
auth.init_app(app)
|
||||
self.user: User = User(
|
||||
_USERNAME, make_password_hash(_REALM, _USERNAME, _PASSWORD))
|
||||
user_db: t.Dict[str, User] = {_USERNAME: self.user}
|
||||
user_db: t.Dict[str, User] \
|
||||
= {_USERNAME: User(
|
||||
_USERNAME, make_password_hash(_REALM, _USERNAME, _PASSWORD))}
|
||||
|
||||
@auth.register_get_password
|
||||
def get_password_hash(username: str) -> t.Optional[str]:
|
||||
@ -141,7 +141,7 @@ class AuthenticationTestCase(TestCase):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.data.decode("UTF-8"),
|
||||
f"Hello, {_USERNAME}! #2")
|
||||
self.assertEqual(self.user.visits, 1)
|
||||
self.assertEqual(g.user.visits, 1)
|
||||
|
||||
def test_stale_opaque(self) -> None:
|
||||
"""Tests the stale and opaque value.
|
||||
@ -218,4 +218,4 @@ class AuthenticationTestCase(TestCase):
|
||||
|
||||
response = self.client.get(admin_uri)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(self.user.visits, 2)
|
||||
self.assertEqual(g.user.visits, 2)
|
||||
|
@ -21,6 +21,7 @@
|
||||
import typing as t
|
||||
from secrets import token_urlsafe
|
||||
|
||||
import flask_login
|
||||
from flask import Response, Flask, g, redirect, request
|
||||
from flask_testing import TestCase
|
||||
from werkzeug.datastructures import WWWAuthenticate, Authorization
|
||||
@ -85,9 +86,9 @@ class FlaskLoginTestCase(TestCase):
|
||||
auth: DigestAuth = DigestAuth(realm=_REALM)
|
||||
auth.init_app(app)
|
||||
|
||||
self.user: User = User(
|
||||
_USERNAME, make_password_hash(_REALM, _USERNAME, _PASSWORD))
|
||||
user_db: t.Dict[str, User] = {_USERNAME: self.user}
|
||||
user_db: t.Dict[str, User] \
|
||||
= {_USERNAME: User(
|
||||
_USERNAME, make_password_hash(_REALM, _USERNAME, _PASSWORD))}
|
||||
|
||||
@auth.register_get_password
|
||||
def get_password_hash(username: str) -> t.Optional[str]:
|
||||
@ -153,7 +154,7 @@ class FlaskLoginTestCase(TestCase):
|
||||
:return: None.
|
||||
"""
|
||||
if not self.has_flask_login:
|
||||
self.skipTest("Skipped without Flask-Login.")
|
||||
self.skipTest("Skipped testing Flask-Login integration without it.")
|
||||
|
||||
response: Response = self.client.get(self.app.url_for("admin-1"))
|
||||
self.assertEqual(response.status_code, 401)
|
||||
@ -166,7 +167,7 @@ class FlaskLoginTestCase(TestCase):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.data.decode("UTF-8"),
|
||||
f"Hello, {_USERNAME}! #2")
|
||||
self.assertEqual(self.user.visits, 1)
|
||||
self.assertEqual(flask_login.current_user.visits, 1)
|
||||
|
||||
def test_stale_opaque(self) -> None:
|
||||
"""Tests the stale and opaque value.
|
||||
@ -174,7 +175,7 @@ class FlaskLoginTestCase(TestCase):
|
||||
:return: None.
|
||||
"""
|
||||
if not self.has_flask_login:
|
||||
self.skipTest("Skipped without Flask-Login.")
|
||||
self.skipTest("Skipped testing Flask-Login integration without it.")
|
||||
|
||||
admin_uri: str = self.app.url_for("admin-1")
|
||||
response: Response
|
||||
@ -221,9 +222,6 @@ class FlaskLoginTestCase(TestCase):
|
||||
|
||||
:return: None.
|
||||
"""
|
||||
if not self.has_flask_login:
|
||||
self.skipTest("Skipped without Flask-Login.")
|
||||
|
||||
admin_uri: str = self.app.url_for("admin-1")
|
||||
logout_uri: str = self.app.url_for("logout")
|
||||
response: Response
|
||||
@ -255,4 +253,4 @@ class FlaskLoginTestCase(TestCase):
|
||||
|
||||
response = self.client.get(admin_uri)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(self.user.visits, 2)
|
||||
self.assertEqual(flask_login.current_user.visits, 2)
|
||||
|
Loading…
x
Reference in New Issue
Block a user