Added missing documentation to the global variables and class and object properties.
This commit is contained in:
parent
bc888195ad
commit
877f02fe82
@ -29,8 +29,11 @@ from werkzeug.datastructures import WWWAuthenticate, Authorization
|
|||||||
from flask_digest_auth import DigestAuth, make_password_hash, Client
|
from flask_digest_auth import DigestAuth, make_password_hash, Client
|
||||||
|
|
||||||
_REALM: str = "testrealm@host.com"
|
_REALM: str = "testrealm@host.com"
|
||||||
|
"""The realm."""
|
||||||
_USERNAME: str = "Mufasa"
|
_USERNAME: str = "Mufasa"
|
||||||
|
"""The username."""
|
||||||
_PASSWORD: str = "Circle Of Life"
|
_PASSWORD: str = "Circle Of Life"
|
||||||
|
"""The password."""
|
||||||
|
|
||||||
|
|
||||||
class User:
|
class User:
|
||||||
@ -43,9 +46,11 @@ class User:
|
|||||||
:param password: The clear-text password.
|
:param password: The clear-text password.
|
||||||
"""
|
"""
|
||||||
self.username: str = username
|
self.username: str = username
|
||||||
self.password_hash: str = make_password_hash(
|
"""The username."""
|
||||||
_REALM, username, password)
|
self.password_hash: str = make_password_hash(_REALM, username, password)
|
||||||
|
"""The password hash."""
|
||||||
self.visits: int = 0
|
self.visits: int = 0
|
||||||
|
"""The number of visits."""
|
||||||
|
|
||||||
|
|
||||||
class AuthenticationTestCase(TestCase):
|
class AuthenticationTestCase(TestCase):
|
||||||
@ -68,6 +73,7 @@ class AuthenticationTestCase(TestCase):
|
|||||||
auth: DigestAuth = DigestAuth()
|
auth: DigestAuth = DigestAuth()
|
||||||
auth.init_app(app)
|
auth.init_app(app)
|
||||||
self.user: User = User(_USERNAME, _PASSWORD)
|
self.user: User = User(_USERNAME, _PASSWORD)
|
||||||
|
"""The user account."""
|
||||||
user_db: Dict[str, User] = {_USERNAME: self.user}
|
user_db: Dict[str, User] = {_USERNAME: self.user}
|
||||||
|
|
||||||
@auth.register_get_password
|
@auth.register_get_password
|
||||||
|
@ -29,8 +29,11 @@ from werkzeug.datastructures import WWWAuthenticate, Authorization
|
|||||||
from flask_digest_auth import DigestAuth, make_password_hash, Client
|
from flask_digest_auth import DigestAuth, make_password_hash, Client
|
||||||
|
|
||||||
_REALM: str = "testrealm@host.com"
|
_REALM: str = "testrealm@host.com"
|
||||||
|
"""The realm."""
|
||||||
_USERNAME: str = "Mufasa"
|
_USERNAME: str = "Mufasa"
|
||||||
|
"""The username."""
|
||||||
_PASSWORD: str = "Circle Of Life"
|
_PASSWORD: str = "Circle Of Life"
|
||||||
|
"""The password."""
|
||||||
|
|
||||||
|
|
||||||
class User:
|
class User:
|
||||||
@ -43,11 +46,15 @@ class User:
|
|||||||
:param password: The clear-text password.
|
:param password: The clear-text password.
|
||||||
"""
|
"""
|
||||||
self.username: str = username
|
self.username: str = username
|
||||||
self.password_hash: str = make_password_hash(
|
"""The username."""
|
||||||
_REALM, username, password)
|
self.password_hash: str = make_password_hash(_REALM, username, password)
|
||||||
|
"""The password hash."""
|
||||||
self.visits: int = 0
|
self.visits: int = 0
|
||||||
|
"""The number of visits."""
|
||||||
self.is_active: bool = True
|
self.is_active: bool = True
|
||||||
|
"""True if the account is active, or False otherwise."""
|
||||||
self.is_anonymous: bool = False
|
self.is_anonymous: bool = False
|
||||||
|
"""True if the account is anonymous, or False otherwise."""
|
||||||
|
|
||||||
def get_id(self) -> str:
|
def get_id(self) -> str:
|
||||||
"""Returns the username.
|
"""Returns the username.
|
||||||
@ -86,6 +93,7 @@ class FlaskLoginTestCase(TestCase):
|
|||||||
app.test_client_class = Client
|
app.test_client_class = Client
|
||||||
|
|
||||||
self.has_flask_login: bool = True
|
self.has_flask_login: bool = True
|
||||||
|
"""Whether the Flask-Login package is installed."""
|
||||||
try:
|
try:
|
||||||
import flask_login
|
import flask_login
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
@ -99,6 +107,7 @@ class FlaskLoginTestCase(TestCase):
|
|||||||
auth.init_app(app)
|
auth.init_app(app)
|
||||||
|
|
||||||
self.user: User = User(_USERNAME, _PASSWORD)
|
self.user: User = User(_USERNAME, _PASSWORD)
|
||||||
|
"""The user account."""
|
||||||
user_db: Dict[str, User] = {_USERNAME: self.user}
|
user_db: Dict[str, User] = {_USERNAME: self.user}
|
||||||
|
|
||||||
@auth.register_get_password
|
@auth.register_get_password
|
||||||
|
Loading…
Reference in New Issue
Block a user