Replaced importing the "typing" module as "t" with importing the individual names in the "typing" module. We do not have as many names to import. This is also to be consistent with the practices of most major and standard packages and examples.
This commit is contained in:
@ -18,8 +18,8 @@
|
||||
"""The test case for the HTTP digest authentication algorithm.
|
||||
|
||||
"""
|
||||
import typing as t
|
||||
import unittest
|
||||
from typing import Optional, Literal
|
||||
|
||||
from flask_digest_auth import make_password_hash, calc_response
|
||||
|
||||
@ -39,11 +39,11 @@ class AlgorithmTestCase(unittest.TestCase):
|
||||
method: str = "GET"
|
||||
uri: str = "/dir/index.html"
|
||||
nonce: str = "dcd98b7102dd2f0e8b11d0f600bfb0c093"
|
||||
qop: t.Optional[t.Literal["auth", "auth-int"]] = "auth"
|
||||
algorithm: t.Optional[t.Literal["MD5", "MD5-sess"]] = None
|
||||
cnonce: t.Optional[str] = "0a4f113b"
|
||||
nc: t.Optional[str] = "00000001"
|
||||
body: t.Optional[bytes] = None
|
||||
qop: Optional[Literal["auth", "auth-int"]] = "auth"
|
||||
algorithm: Optional[Literal["MD5", "MD5-sess"]] = None
|
||||
cnonce: Optional[str] = "0a4f113b"
|
||||
nc: Optional[str] = "00000001"
|
||||
body: Optional[bytes] = None
|
||||
|
||||
password_hash: str = make_password_hash(realm, username, password)
|
||||
response: str = calc_response(method, uri, password_hash, nonce, qop,
|
||||
|
@ -18,8 +18,8 @@
|
||||
"""The test case for the HTTP digest authentication.
|
||||
|
||||
"""
|
||||
import typing as t
|
||||
from secrets import token_urlsafe
|
||||
from typing import Any, Optional, Dict
|
||||
|
||||
from flask import Response, Flask, g, redirect, request
|
||||
from flask_testing import TestCase
|
||||
@ -66,10 +66,10 @@ class AuthenticationTestCase(TestCase):
|
||||
auth: DigestAuth = DigestAuth()
|
||||
auth.init_app(app)
|
||||
self.user: User = User(_USERNAME, _PASSWORD)
|
||||
user_db: t.Dict[str, User] = {_USERNAME: self.user}
|
||||
user_db: Dict[str, User] = {_USERNAME: self.user}
|
||||
|
||||
@auth.register_get_password
|
||||
def get_password_hash(username: str) -> t.Optional[str]:
|
||||
def get_password_hash(username: str) -> Optional[str]:
|
||||
"""Returns the password hash of a user.
|
||||
|
||||
:param username: The username.
|
||||
@ -79,7 +79,7 @@ class AuthenticationTestCase(TestCase):
|
||||
else None
|
||||
|
||||
@auth.register_get_user
|
||||
def get_user(username: str) -> t.Optional[t.Any]:
|
||||
def get_user(username: str) -> Optional[Any]:
|
||||
"""Returns a user.
|
||||
|
||||
:param username: The username.
|
||||
|
@ -18,8 +18,8 @@
|
||||
"""The test case for the Flask-Login integration.
|
||||
|
||||
"""
|
||||
import typing as t
|
||||
from secrets import token_urlsafe
|
||||
from typing import Optional, Dict
|
||||
|
||||
from flask import Response, Flask, g, redirect, request
|
||||
from flask_testing import TestCase
|
||||
@ -97,10 +97,10 @@ class FlaskLoginTestCase(TestCase):
|
||||
auth.init_app(app)
|
||||
|
||||
self.user: User = User(_USERNAME, _PASSWORD)
|
||||
user_db: t.Dict[str, User] = {_USERNAME: self.user}
|
||||
user_db: Dict[str, User] = {_USERNAME: self.user}
|
||||
|
||||
@auth.register_get_password
|
||||
def get_password_hash(username: str) -> t.Optional[str]:
|
||||
def get_password_hash(username: str) -> Optional[str]:
|
||||
"""Returns the password hash of a user.
|
||||
|
||||
:param username: The username.
|
||||
@ -119,7 +119,7 @@ class FlaskLoginTestCase(TestCase):
|
||||
user.visits = user.visits + 1
|
||||
|
||||
@login_manager.user_loader
|
||||
def load_user(user_id: str) -> t.Optional[User]:
|
||||
def load_user(user_id: str) -> Optional[User]:
|
||||
"""Loads a user.
|
||||
|
||||
:param user_id: The username.
|
||||
|
Reference in New Issue
Block a user