2015-08-05 10:32:49 +00:00
|
|
|
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):
|
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
|
|
|
|
2018-09-06 10:06:55 +00:00
|
|
|
app = web.Application()
|
2015-11-19 12:17:34 +00:00
|
|
|
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('/')
|
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
|
|
|
|
|
|
|
|
2018-09-06 10:06:55 +00:00
|
|
|
async def test_forget(loop, aiohttp_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
|
|
|
|
2018-09-06 10:06:55 +00:00
|
|
|
app = web.Application()
|
2015-11-19 12:17:34 +00:00
|
|
|
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('/')
|
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)
|