From 845af5eef0ae32f54ee2b7fa32e35526298dc731 Mon Sep 17 00:00:00 2001 From: PraveenCuebook Date: Tue, 17 Aug 2021 19:33:14 +0530 Subject: [PATCH 1/2] CUEAPP #2437 Test case added for auth middleware --- api/users/tests/test_user_views.py | 12 +++++++++++- ui/src/components/Sidebar/Sidebar.js | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/api/users/tests/test_user_views.py b/api/users/tests/test_user_views.py index 5468bed..46a5edc 100644 --- a/api/users/tests/test_user_views.py +++ b/api/users/tests/test_user_views.py @@ -4,6 +4,7 @@ import json import pytest from unittest import mock +from django.test import Client from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode from django.utils.encoding import force_bytes @@ -38,4 +39,13 @@ def test_authenticate_post(setup_user, client): assert response.json()["success"] == True data = {"email": "random@cuebook.ai", "password": "random"} response = client.post(path, data=json.dumps(data), content_type="application/json") - assert response.json()["success"] == False \ No newline at end of file + assert response.json()["success"] == False + +@pytest.fixture() +def test_auth_middleware(client, mocker): + """ test middleware """ + c = Client() + res = c.post("/accounts/login", {"email": "admin@domain.com", "password": "admin"} , follow=True) + res.status_code == 200 + res = c.get("/accounts/login", follow=True) + assert res.status_code == 200 \ No newline at end of file diff --git a/ui/src/components/Sidebar/Sidebar.js b/ui/src/components/Sidebar/Sidebar.js index 5fa1a25..cab36ca 100644 --- a/ui/src/components/Sidebar/Sidebar.js +++ b/ui/src/components/Sidebar/Sidebar.js @@ -127,7 +127,7 @@ export default function Sidebar(props) {