From e9c79d0ca59e3123144232e116cb3604d5ff073a Mon Sep 17 00:00:00 2001 From: na-stewart Date: Sun, 23 Jun 2024 11:46:07 -0400 Subject: [PATCH] Test revision --- README.md | 14 ++++++++------ sanic_security/test/server.py | 4 ++-- sanic_security/test/tests.py | 2 ++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f94e88a..b3c8702 100644 --- a/README.md +++ b/README.md @@ -165,9 +165,9 @@ Phone can be null or empty. @app.post("api/security/register") async def on_register(request): account = await register(request) - two_step_session = await request_two_step_verification(request, account) + two_step_session = await request_two_step_verification(request, account) await email_code( - account.email, two_step_session.code # Code = 197251 + account.email, two_step_session.code # Code = 197251 ) # Custom method for emailing verification code. response = json( "Registration successful! Email verification required.", @@ -204,9 +204,11 @@ You can use a username as well as an email for login if `ALLOW_LOGIN_WITH_USERNA @app.post("api/security/login") async def on_login(request): authentication_session = await login(request, require_second_factor=True) - two_step_session = await request_two_step_verification(request, authentication_session.bearer) + two_step_session = await request_two_step_verification( + request, authentication_session.bearer + ) await email_code( - authentication_session.bearer.email, two_step_session.code # Code = 197251 + authentication_session.bearer.email, two_step_session.code # Code = 197251 ) # Custom method for emailing verification code. response = json( "Login successful! Two-factor authentication required.", @@ -322,8 +324,8 @@ downloading a .ttf font and defining the file's path in the configuration. ```python @app.get("api/security/captcha") async def on_captcha_img_request(request): - captcha_session = await request_captcha(request) - response = captcha_session.get_image() # Captcha: 192731 + captcha_session = await request_captcha(request) + response = captcha_session.get_image() # Captcha: 192731 captcha_session.encode(response) return response ``` diff --git a/sanic_security/test/server.py b/sanic_security/test/server.py index 6fa7a10..a3435fc 100644 --- a/sanic_security/test/server.py +++ b/sanic_security/test/server.py @@ -110,7 +110,7 @@ async def on_login(request): ) two_step_session.encode(response) else: - response = json("Login successful!", authentication_session.bearer.json) + response = json("Login successful!", authentication_session.json) authentication_session.encode(response) return response @@ -148,7 +148,7 @@ async def on_logout(request): Logout of currently logged in account. """ authentication_session = await logout(request) - response = json("Logout successful!", authentication_session.bearer.json) + response = json("Logout successful!", authentication_session.json) return response diff --git a/sanic_security/test/tests.py b/sanic_security/test/tests.py index b660dc8..32a5a11 100644 --- a/sanic_security/test/tests.py +++ b/sanic_security/test/tests.py @@ -306,6 +306,8 @@ def test_anonymous_login(self): "http://127.0.0.1:8000/api/test/auth", ) assert authenticate_response.status_code == 200, authenticate_response.text + logout_response = self.client.post("http://127.0.0.1:8000/api/test/auth/logout") + assert logout_response.status_code == 200, logout_response.text class VerificationTest(TestCase):