Skip to content

Commit 54ed68e

Browse files
committed
Merge branch 'clewellyn-nava/BB2-4266/C4DIC-endpoint' of https://github.com/CMSgov/bluebutton-web-server into clewellyn-nava/BB2-4266/C4DIC-endpoint
2 parents b253c0f + b47050a commit 54ed68e

File tree

8 files changed

+170
-133
lines changed

8 files changed

+170
-133
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"),

apps/fhir/bluebutton/management/commands/migrate_fhir_id_to_v2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ def migrate_fhir_id_to_v2(apps=None, schema_editor=None) -> None:
1818

1919
apps_mod = apps if apps is not None else global_apps
2020
Crosswalk = apps_mod.get_model('bluebutton', 'Crosswalk')
21-
for crosswalk in Crosswalk.objects.all():
21+
for crosswalk in Crosswalk.objects.iterator(chunk_size=1000):
2222
if getattr(crosswalk, '_fhir_id', None):
2323
crosswalk.fhir_id_v2 = getattr(crosswalk, '_fhir_id') # type: ignore[attr-defined]
2424
crosswalk.save()
2525

2626
ArchivedCrosswalk = apps_mod.get_model('bluebutton', 'ArchivedCrosswalk')
27-
for archived in ArchivedCrosswalk.objects.all():
27+
for archived in ArchivedCrosswalk.objects.iterator(chunk_size=1000):
2828
if getattr(archived, '_fhir_id', None):
2929
archived.fhir_id_v2 = getattr(archived, '_fhir_id') # type: ignore[attr-defined]
3030
archived.save()
@@ -35,13 +35,13 @@ def reverse_migrate_v2_to_fhir_id(apps=None, schema_editor=None) -> None:
3535

3636
apps_mod = apps if apps is not None else global_apps
3737
Crosswalk = apps_mod.get_model('bluebutton', 'Crosswalk')
38-
for crosswalk in Crosswalk.objects.all():
38+
for crosswalk in Crosswalk.objects.iterator(chunk_size=1000):
3939
if getattr(crosswalk, 'fhir_id_v2', None):
4040
crosswalk._fhir_id = getattr(crosswalk, 'fhir_id_v2') # type: ignore[attr-defined]
4141
crosswalk.save()
4242

4343
ArchivedCrosswalk = apps_mod.get_model('bluebutton', 'ArchivedCrosswalk')
44-
for archived in ArchivedCrosswalk.objects.all():
44+
for archived in ArchivedCrosswalk.objects.iterator(chunk_size=1000):
4545
if getattr(archived, 'fhir_id_v2', None):
4646
archived._fhir_id = getattr(archived, 'fhir_id_v2') # type: ignore[attr-defined]
4747
archived.save()

apps/fhir/bluebutton/migrations/0009_migrate_fhir_id_to_v2.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Generated by Django 4.2.24 on 2025-09-23 13:25
22

33
from django.db import migrations, models
4-
from apps.fhir.bluebutton.management.commands.migrate_fhir_id_to_v2 import (
5-
migrate_fhir_id_to_v2,
6-
reverse_migrate_v2_to_fhir_id,
7-
)
84

95
# TODO - Migration is Unapplied
106
# This migration needs to be run after deployment of bluebutton 0008 and when all
@@ -18,8 +14,7 @@ class Migration(migrations.Migration):
1814
]
1915

2016
operations = [
21-
migrations.RunPython(migrate_fhir_id_to_v2, reverse_migrate_v2_to_fhir_id),
22-
migrations.AddConstraint( # After migration happens, add constraint that a fhir_id must be present
17+
migrations.AddConstraint( # After migrate_fhir_id_to_v2 is run, add constraint that a fhir_id_v2 or v3 must be present
2318
model_name='crosswalk',
2419
constraint=models.CheckConstraint(
2520
check=models.Q(fhir_id_v2__isnull=False) | models.Q(fhir_id_v3__isnull=False),

0 commit comments

Comments
 (0)