Skip to content

Commit f54ef36

Browse files
committed
TST: fix unit tests
1 parent c474afd commit f54ef36

4 files changed

Lines changed: 22 additions & 10 deletions

File tree

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import asyncio
2-
import enum
32
import hashlib
43
import secrets
54
import uuid as uuid_module
@@ -31,11 +30,6 @@
3130
from pydantic_settings import BaseSettings
3231

3332
from . import schemas
34-
from .authentication.authenticator_base import (
35-
ExternalAuthenticator,
36-
InternalAuthenticator,
37-
UserSessionState,
38-
)
3933
from .authorization._defaults import _DEFAULT_ANONYMOUS_PROVIDER_NAME
4034
from .core import json_or_msgpack
4135
from .database import orm
@@ -59,6 +53,7 @@ def utcnow():
5953
"UTC now with second resolution"
6054
return datetime.utcnow().replace(microsecond=0)
6155

56+
6257
class Token(BaseModel):
6358
access_token: str
6459
token_type: str
@@ -484,7 +479,9 @@ async def handle_credentials(
484479
api_access_manager=Depends(get_api_access_manager),
485480
):
486481
request.state.endpoint = "auth"
487-
user_session_state = await authenticator.authenticate(username=form_data.username, password=form_data.password)
482+
user_session_state = await authenticator.authenticate(
483+
username=form_data.username, password=form_data.password
484+
)
488485
username = user_session_state.user_name if user_session_state else None
489486

490487
err_msg = None

bluesky_httpserver/authentication/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
from .._authentication import (
2+
base_authentication_router,
3+
build_auth_code_route,
4+
build_handle_credentials_route,
5+
get_current_principal,
6+
get_current_principal_websocket,
7+
oauth2_scheme,
8+
)
19
from .authenticator_base import (
210
ExternalAuthenticator,
311
InternalAuthenticator,
@@ -8,4 +16,10 @@
816
"ExternalAuthenticator",
917
"InternalAuthenticator",
1018
"UserSessionState",
19+
"get_current_principal",
20+
"get_current_principal_websocket",
21+
"base_authentication_router",
22+
"build_auth_code_route",
23+
"build_handle_credentials_route",
24+
"oauth2_scheme",
1125
]

bluesky_httpserver/tests/test_authenticators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44

55
# fmt: off
6-
from ..authenticators import LDAPAuthenticator
6+
from ..authenticators import LDAPAuthenticator, UserSessionState
77

88

99
@pytest.mark.parametrize("ldap_server_address, ldap_server_port", [
@@ -35,8 +35,8 @@ def test_LDAPAuthenticator_01(use_tls, use_ssl, ldap_server_address, ldap_server
3535
)
3636

3737
async def testing():
38-
assert await authenticator.authenticate("user01", "password1") == "user01"
39-
assert await authenticator.authenticate("user02", "password2") == "user02"
38+
assert await authenticator.authenticate("user01", "password1") == UserSessionState("user01", {})
39+
assert await authenticator.authenticate("user02", "password2") == UserSessionState("user02", {})
4040
assert await authenticator.authenticate("user02a", "password2") is None
4141
assert await authenticator.authenticate("user02", "password2a") is None
4242

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
alembic
22
bluesky-queueserver
33
bluesky-queueserver-api
4+
cachetools
45
fastapi
56
ldap3
67
orjson

0 commit comments

Comments
 (0)