2015-08-05 10:32:49 +00:00
|
|
|
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):
|
2015-08-05 10:32:49 +00:00
|
|
|
|
2017-12-13 14:51:46 +00:00
|
|
|
async def do_remember(request):
|
2015-11-19 12:17:34 +00:00
|
|
|
response = web.Response()
|
2017-12-13 14:51:46 +00:00
|
|
|
await remember(request, response, 'Andrew')
|
2015-08-05 10:32:49 +00:00
|
|
|
|
2016-09-27 14:57:11 +00:00
|
|
|
app = web.Application(loop=loop)
|
2015-11-19 12:17:34 +00:00
|
|
|
app.router.add_route('POST', '/', do_remember)
|
2017-12-13 14:51:46 +00:00
|
|
|
client = await test_client(app)
|
|
|
|
resp = await client.post('/')
|
2015-11-19 12:17:34 +00:00
|
|
|
assert 500 == resp.status
|
|
|
|
assert (('Security subsystem is not initialized, '
|
|
|
|
'call aiohttp_security.setup(...) first') ==
|
|
|
|
resp.reason)
|
2015-08-05 10:32:49 +00:00
|
|
|
|
|
|
|
|
2017-12-13 14:51:46 +00:00
|
|
|
async def test_forget(loop, test_client):
|
2015-08-05 10:32:49 +00:00
|
|
|
|
2017-12-13 14:51:46 +00:00
|
|
|
async def do_forget(request):
|
2015-11-19 12:17:34 +00:00
|
|
|
response = web.Response()
|
2017-12-13 14:51:46 +00:00
|
|
|
await forget(request, response)
|
2015-11-19 12:17:34 +00:00
|
|
|
|
2016-09-27 14:57:11 +00:00
|
|
|
app = web.Application(loop=loop)
|
2015-11-19 12:17:34 +00:00
|
|
|
app.router.add_route('POST', '/', do_forget)
|
2017-12-13 14:51:46 +00:00
|
|
|
client = await test_client(app)
|
|
|
|
resp = await client.post('/')
|
2015-11-19 12:17:34 +00:00
|
|
|
assert 500 == resp.status
|
|
|
|
assert (('Security subsystem is not initialized, '
|
|
|
|
'call aiohttp_security.setup(...) first') ==
|
|
|
|
resp.reason)
|