aiohttp-security/tests/test_no_identity.py

35 lines
1.0 KiB
Python
Raw Normal View History

from aiohttp import web
from aiohttp_security import remember, forget
2017-12-13 14:51:46 +00:00
async def test_remember(loop, test_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')
2016-09-27 14:57:11 +00:00
app = web.Application(loop=loop)
app.router.add_route('POST', '/', do_remember)
2017-12-13 14:51:46 +00:00
client = await test_client(app)
resp = await client.post('/')
assert 500 == resp.status
assert (('Security subsystem is not initialized, '
'call aiohttp_security.setup(...) first') ==
resp.reason)
2017-12-13 14:51:46 +00:00
async def test_forget(loop, test_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)
2016-09-27 14:57:11 +00:00
app = web.Application(loop=loop)
app.router.add_route('POST', '/', do_forget)
2017-12-13 14:51:46 +00:00
client = await test_client(app)
resp = await client.post('/')
assert 500 == resp.status
assert (('Security subsystem is not initialized, '
'call aiohttp_security.setup(...) first') ==
resp.reason)