Skip to content

Commit 374e1b1

Browse files
stiwarisemanticbitsShivam Tiwari
andauthored
BB2-3379: Created separate waffle switch for lougout flow (#1432)
Co-authored-by: Shivam Tiwari <[email protected]>
1 parent 1fcc60e commit 374e1b1

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

apps/accounts/tests/test_login.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def test_invalid_login(self):
7878
self.assertEqual(response.status_code, 200)
7979
self.assertContains(response, 'Login')
8080

81+
@override_switch('logout', active=True)
8182
@override_switch('show_testclient_link', active=True)
8283
@override_switch('login', active=True)
8384
def test_logout(self):
@@ -88,6 +89,15 @@ def test_logout(self):
8889
self.assertEqual(response.status_code, 200)
8990
self.assertContains(response, 'Login')
9091

92+
@override_switch('logout', active=False)
93+
@override_switch('login', active=True)
94+
def test_logout_switch_off(self):
95+
"""
96+
Logout endpoint disabled when logout switch is off
97+
"""
98+
response = self.client.get(reverse('logout'), follow=True)
99+
self.assertEqual(response.status_code, 404)
100+
91101
@override_switch('show_testclient_link', active=True)
92102
@override_switch('login', active=True)
93103
def test_valid_login_email(self):

apps/accounts/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
urlpatterns = [
1717
path("api/profile", my_profile, name="my_profile"),
18-
path("logout", waffle_switch("login")(LogoutView.as_view()), name="logout"),
18+
path("logout", waffle_switch("logout")(LogoutView.as_view()), name="logout"),
1919
path(
2020
"create",
2121
waffle_switch("signup")(create_account),

apps/accounts/v2/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
urlpatterns = [
1717
path("api/profile", my_profile, name="my_profile_v2"),
18-
path("logout", waffle_switch("login")(LogoutView.as_view()), name="logout_v2"),
18+
path("logout", waffle_switch("logout")(LogoutView.as_view()), name="logout_v2"),
1919
path(
2020
"create",
2121
waffle_switch("signup")(create_account),

apps/core/management/commands/create_test_feature_switches.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
("enable_testclient", True, "This enables the test client."),
1010
("expire_grant_endpoint", True, "This enables the /v<1/2>/o/expire_authenticated_user/<patient_id>/ endpoint."),
1111
("login", True, "This enables login related URLs and code. See apps/accounts/urls.py file for more info."),
12+
("logout", True, "This enables logout related URLs and code. See apps/accounts/urls.py file for more info."),
1213
("outreach_email", True, "This enables developer outreach emails. Not active in prod."),
1314
("require_pkce", True, "This enforces the presence of the PKCE parameters code_challenge and code_challenge_method when authorizing"),
1415
("require_state", True, "This enforces the presence of the state parameter when authorizing"),

0 commit comments

Comments
 (0)