def _get_app_logger(monkeypatch, mock_app_config):  # noqa: F811
    _patch_logger(monkeypatch)
    event_info = EventDescriptor(type=EventType.GET)
    mock_event.logger = app_logger()
    setup_app_logger(mock_event,
                     app_config=mock_app_config,
                     name='test_get_app_logger',
                     event_info=event_info)
    return mock_event.logger
def _get_app_logger(monkeypatch, mock_app_config):  # noqa: F811
    _patch_logger(monkeypatch)
    mock_event.logger = app_logger()
    settings = get_event_settings(mock_app_config.effective_settings,
                                  'mock_event')
    setup_app_logger(mock_event,
                     app_config=mock_app_config,
                     name='mock_event',
                     event_settings=settings)
    return mock_event.logger
示例#3
0
"""
Basic Auth: Decode
--------------------------------------------------------------------
Returns decoded auth info
"""
from hopeit.app.api import event_api
from hopeit.basic_auth import ContextUserInfo
from hopeit.app.context import EventContext
from hopeit.app.logger import app_logger

logger = app_logger()

__steps__ = ['decode']

__api__ = event_api(
    summary="Basic Auth: Decode",
    responses={
        200: (ContextUserInfo, "Information extracted from token")
    }
)


async def decode(payload: None, context: EventContext) -> ContextUserInfo:
    token_info = context.auth_info['payload']
    return ContextUserInfo(
        id=token_info['id'],
        user=token_info['user'],
        email=token_info['email']
    )