Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit f4a926f

Browse files
committed
fix: actions
1 parent 44d23d3 commit f4a926f

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

actions/local_actions.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
from apiserver.define import DEFINE
1919
from apiserver.env import load_config
2020
from apiserver.lib.model.entities import SignedUp, UserNames
21-
from auth.core.model import IdInfo
2221
from auth.data.authentication import get_apake_setup
2322
from auth.data.keys import get_keys
2423
from auth.data.relational.opaque import get_setup
24+
from auth.data.relational.user import EmptyIdUserData
2525
from auth.define import refresh_exp, access_exp, id_exp
2626
from auth.token.build import create_tokens, finish_tokens
2727
from datacontext.context import DontReplaceContext
@@ -57,14 +57,14 @@ async def admin_access(local_dsrc):
5757
admin_id = "admin_test"
5858
scope = "member admin"
5959
utc_now = auth.core.util.utc_timestamp()
60-
id_info = IdInfo()
60+
id_userdata = EmptyIdUserData()
6161
access_token_data, id_token_data, access_scope, refresh_save = create_tokens(
6262
admin_id,
6363
scope,
6464
utc_now - 1,
6565
"test_nonce",
6666
utc_now,
67-
id_info,
67+
id_userdata,
6868
DEFINE.issuer,
6969
DEFINE.frontend_client_id,
7070
DEFINE.backend_client_id,
@@ -79,7 +79,7 @@ async def admin_access(local_dsrc):
7979
keys.symmetric,
8080
access_token_data,
8181
id_token_data,
82-
id_info,
82+
id_userdata,
8383
utc_now,
8484
keys.signing,
8585
access_exp,
@@ -97,7 +97,7 @@ async def test_get_admin_token(admin_access):
9797
@pytest.mark.asyncio
9898
async def test_generate_admin(local_dsrc):
9999
admin_password = "admin"
100-
setup = await get_apake_setup(local_dsrc.store)
100+
setup = await get_apake_setup(DontReplaceContext(), local_dsrc.store)
101101

102102
cl_req, cl_state = opq.register_client(admin_password)
103103
serv_resp = opq.register(setup, cl_req, util.usp_hex("0_admin"))

src/apiserver/app/routers/ranking.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@
1313
from apiserver.app.ops.header import Authorization
1414
from apiserver.app.response import RawJSONResponse
1515
from apiserver.app.routers.helper import require_admin, require_member
16-
from apiserver.lib.model.entities import UserPointsNames, UserPointsNamesList
16+
from apiserver.lib.model.entities import (
17+
UserPointsNames,
18+
UserPointsNamesList,
19+
UserEventsList,
20+
EventsList,
21+
)
1722
from apiserver.data import Source, get_conn
1823
from apiserver.data.api.classifications import events_in_class, get_event_user_points
1924
from apiserver.data.special import user_events_in_class
20-
from apiserver.lib.model.entities import UserPointsNamesList, UserEventsList, EventsList
2125

2226
router = APIRouter()
2327

@@ -92,6 +96,7 @@ async def sync_publish_classification(
9296
do_publish = publish == "publish"
9397
await sync_publish_ranking(dsrc, do_publish)
9498

99+
95100
@router.get("/admin/class/events/user/{user_id}/")
96101
async def get_user_events_in_class(
97102
user_id: str,

src/auth/data/relational/user.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from enum import StrEnum
2-
from typing import Any, Protocol, Self, Type
2+
from typing import Any, Protocol, Type
33

44
from sqlalchemy.ext.asyncio import AsyncConnection
55

@@ -28,7 +28,7 @@ async def update_password_file(
2828

2929
class IdUserData(Protocol):
3030
@classmethod
31-
def from_id_token(cls, id_token: dict[str, Any]) -> Self: ...
31+
def from_id_token(cls, id_token: dict[str, Any]) -> "IdUserData": ...
3232

3333
"""id_userdata_from_token"""
3434

@@ -47,15 +47,15 @@ async def get_id_userdata_by_id(
4747
def get_type(cls) -> Type[IdUserData]: ...
4848

4949

50-
# class IdUserDataOps(Protocol, Generic[IdUserDataT]):
51-
# @classmethod
52-
# async def get_id_userdata_by_id(cls, conn: AsyncConnection, user_id: str) -> IdUserDataT:
53-
# """Throws NoDataError if user does not exist."""
54-
# ...
50+
class EmptyIdUserData(IdUserData):
51+
def __init__(self) -> None:
52+
pass
5553

56-
# @classmethod
57-
# def id_info_from_id_userdata(cls, ud: IdUserDataT) -> dict[str, Any]: ...
54+
@classmethod
55+
def from_id_token(cls, id_token: dict[str, Any]) -> "EmptyIdUserData":
56+
return EmptyIdUserData()
5857

58+
"""id_userdata_from_token"""
5959

60-
# @classmethod
61-
# def id_userdata_from_token(cls, id_token: dict[str, Any]) -> IdUserDataT: ...
60+
def id_info(self) -> dict[str, Any]:
61+
return dict()

0 commit comments

Comments
 (0)