(event_loop, base_world)
| 28 | |
| 29 | @pytest.fixture |
| 30 | def simple_webapp(event_loop, base_world): |
| 31 | async def index(request): |
| 32 | return web.Response(status=200, text='hello!') |
| 33 | |
| 34 | @security.authentication_exempt |
| 35 | async def public(request): |
| 36 | return web.Response(status=200, text='public') |
| 37 | |
| 38 | async def private(request): |
| 39 | return web.Response(status=200, text='private') |
| 40 | |
| 41 | @security.authentication_exempt |
| 42 | async def login(request): |
| 43 | await auth_svc.login_user(request) # Note: auth_svc defined in context function |
| 44 | |
| 45 | app = web.Application() |
| 46 | app.router.add_get('/', index) |
| 47 | app.router.add_post('/login', login) |
| 48 | app.router.add_get('/public', public) |
| 49 | app.router.add_get('/private', private) |
| 50 | |
| 51 | auth_svc = AuthService() |
| 52 | |
| 53 | event_loop.run_until_complete( |
| 54 | auth_svc.apply( |
| 55 | app=app, |
| 56 | users=base_world.get_config('users') |
| 57 | ) |
| 58 | ) |
| 59 | event_loop.run_until_complete(auth_svc.set_login_handlers(auth_svc.get_services())) |
| 60 | |
| 61 | # The authentication_required middleware needs to run after the session middleware. |
| 62 | # AuthService.apply(...) adds session middleware to the app, so we can append the |
| 63 | # the auth middleware after. Not doing this will cause a 500 in regards to the |
| 64 | # session middleware not being set up correctly. |
| 65 | app.middlewares.append(security.authentication_required_middleware_factory(auth_svc)) |
| 66 | |
| 67 | return app |
| 68 | |
| 69 | |
| 70 | def test_function_is_authentication_exempt(): |
nothing calls this directly
no test coverage detected