aiohttp-security/tests/test_no_identity.py

35 lines
1.0 KiB
Python
Raw Permalink Normal View History

from aiohttp import web
from aiohttp_security import remember, forget
2018-09-06 10:06:55 +00:00
async def test_remember(loop, aiohttp_client):
2017-12-13 14:51:46 +00:00
async def do_remember(request):
response = web.Response()
2017-12-13 14:51:46 +00:00
await remember(request, response, 'Andrew')
2018-09-06 10:06:55 +00:00
app = web.Application()
app.router.add_route('POST', '/', do_remember)
2018-09-06 10:06:55 +00:00
client = await aiohttp_client(app)
2017-12-13 14:51:46 +00:00
resp = await client.post('/')
assert 500 == resp.status
assert (('Security subsystem is not initialized, '
'call aiohttp_security.setup(...) first') ==
resp.reason)
2018-09-06 10:06:55 +00:00
async def test_forget(loop, aiohttp_client):
2017-12-13 14:51:46 +00:00
async def do_forget(request):
response = web.Response()
2017-12-13 14:51:46 +00:00
await forget(request, response)
2018-09-06 10:06:55 +00:00
app = web.Application()
app.router.add_route('POST', '/', do_forget)
2018-09-06 10:06:55 +00:00
client = await aiohttp_client(app)
2017-12-13 14:51:46 +00:00
resp = await client.post('/')
assert 500 == resp.status
assert (('Security subsystem is not initialized, '
'call aiohttp_security.setup(...) first') ==
resp.reason)