Skip to content

Commit f76cb48

Browse files
Merge branch 'master' into clewellyn-nava/BB2-4203/settings-design
2 parents e6267dc + 24d4590 commit f76cb48

File tree

13 files changed

+104
-81
lines changed

13 files changed

+104
-81
lines changed

COMMUNITY.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,17 @@ Total number of contributors: <!--CONTRIBUTOR COUNT START--> <!--CONTRIBUTOR COU
108108
</a>
109109
</td>
110110
<td align="center">
111-
<a href="https://github.com/loganbertram">
112-
<img src="https://avatars.githubusercontent.com/u/11063141?v=4" width="100;" alt="loganbertram"/>
111+
<a href="https://github.com/jimmyfagan">
112+
<img src="https://avatars.githubusercontent.com/u/90421499?v=4" width="100;" alt="jimmyfagan"/>
113113
<br />
114-
<sub><b>Logan Bertram</b></sub>
114+
<sub><b>jimmyfagan</b></sub>
115115
</a>
116116
</td>
117117
<td align="center">
118-
<a href="https://github.com/jimmyfagan">
119-
<img src="https://avatars.githubusercontent.com/u/90421499?v=4" width="100;" alt="jimmyfagan"/>
118+
<a href="https://github.com/loganbertram">
119+
<img src="https://avatars.githubusercontent.com/u/11063141?v=4" width="100;" alt="loganbertram"/>
120120
<br />
121-
<sub><b>jimmyfagan</b></sub>
121+
<sub><b>Logan Bertram</b></sub>
122122
</a>
123123
</td>
124124
<td align="center">
@@ -196,17 +196,17 @@ Total number of contributors: <!--CONTRIBUTOR COUNT START--> <!--CONTRIBUTOR COU
196196
</a>
197197
</td>
198198
<td align="center">
199-
<a href="https://github.com/micahtaylor">
200-
<img src="https://avatars.githubusercontent.com/u/671894?v=4" width="100;" alt="micahtaylor"/>
199+
<a href="https://github.com/clewellyn-nava">
200+
<img src="https://avatars.githubusercontent.com/u/224594471?v=4" width="100;" alt="clewellyn-nava"/>
201201
<br />
202-
<sub><b>Micah Taylor</b></sub>
202+
<sub><b>Connor Lewellyn</b></sub>
203203
</a>
204204
</td>
205205
<td align="center">
206-
<a href="https://github.com/clewellyn-nava">
207-
<img src="https://avatars.githubusercontent.com/u/224594471?v=4" width="100;" alt="clewellyn-nava"/>
206+
<a href="https://github.com/micahtaylor">
207+
<img src="https://avatars.githubusercontent.com/u/671894?v=4" width="100;" alt="micahtaylor"/>
208208
<br />
209-
<sub><b>Connor Lewellyn</b></sub>
209+
<sub><b>Micah Taylor</b></sub>
210210
</a>
211211
</td>
212212
<td align="center">

apps/integration_tests/selenium_cases.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,6 @@ class Action(Enum):
157157
EN_US = "en_us"
158158
ES_ES = "es_es"
159159

160-
# API versions
161-
API_V2 = "v2"
162-
163160
# v2 SMART APP scope constants
164161
X_PATH_FOR_USER_SCOPES = "//*[@id='main-content']/div/div/div/pre"
165162
COVERAGE_SCOPE = "patient/Coverage.rs"

apps/integration_tests/selenium_spanish_tests.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from .selenium_generic import SeleniumGenericTests
2-
from .selenium_cases import (
3-
API_V2,
4-
SPANISH_TESTS
5-
)
2+
from .selenium_cases import SPANISH_TESTS
3+
from apps.constants import Versions
64

75
USE_NEW_PERM_SCREEN = "true"
86

@@ -20,7 +18,7 @@ class TestPermissionScreenSpanish(SeleniumGenericTests):
2018
def test_toggle_language_and_date_format(self):
2119
step = [0]
2220
test_name = "toggle_language"
23-
api_ver = API_V2
21+
api_ver = Versions.V2
2422
self._print_testcase_banner(test_name, api_ver, step[0], self.use_mslsx, True)
2523
if not self.use_mslsx:
2624
self._play(SPANISH_TESTS[test_name], step, api_ver=api_ver)
@@ -37,7 +35,7 @@ def test_toggle_language_and_date_format(self):
3735
def test_authorize_lang_param(self):
3836
step = [0]
3937
test_name = "authorize_lang_param"
40-
api_ver = API_V2
38+
api_ver = Versions.V2
4139
self._print_testcase_banner(test_name, api_ver, step[0], self.use_mslsx, True)
4240
if not self.use_mslsx:
4341
self._play(SPANISH_TESTS[test_name], step, api_ver=api_ver)
@@ -54,7 +52,7 @@ def test_authorize_lang_param(self):
5452
def test_authorize_lang_spanish_button(self):
5553
step = [0]
5654
test_name = "authorize_lang_spanish_button"
57-
api_ver = API_V2
55+
api_ver = Versions.V2
5856
self._print_testcase_banner(test_name, api_ver, step[0], self.use_mslsx, True)
5957
if USE_NEW_PERM_SCREEN == "true":
6058
# the validation of expire date etc. only applicable to new perm screen

apps/integration_tests/selenium_tests.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import os
22
from .selenium_generic import SeleniumGenericTests
3-
from .selenium_cases import (
4-
API_V2,
5-
TESTS,
6-
)
3+
from .selenium_cases import TESTS
4+
from apps.constants import Versions
75

86

97
USE_NEW_PERM_SCREEN = os.environ['USE_NEW_PERM_SCREEN']
@@ -17,7 +15,7 @@ class TestBlueButtonAPI(SeleniumGenericTests):
1715
def test_auth_grant_pkce_fhir_calls_v2(self):
1816
step = [0]
1917
test_name = "auth_grant_pkce_fhir_calls"
20-
api_ver = API_V2
18+
api_ver = Versions.V2
2119
self._print_testcase_banner(test_name, api_ver, step[0], self.use_mslsx, True)
2220
self._play(TESTS[test_name], step, api_ver=api_ver)
2321
self._testclient_home()
@@ -26,7 +24,7 @@ def test_auth_grant_pkce_fhir_calls_v2(self):
2624
def test_auth_deny_fhir_calls_v2(self):
2725
step = [0]
2826
test_name = "auth_deny_fhir_calls"
29-
api_ver = API_V2
27+
api_ver = Versions.V2
3028
self._print_testcase_banner(test_name, api_ver, step[0], self.use_mslsx, True)
3129
self._play(TESTS[test_name], step, api_ver=api_ver)
3230
self._print_testcase_banner(test_name, api_ver, step[0], self.use_mslsx, False)
@@ -37,7 +35,7 @@ def test_auth_grant_w_no_demo_v2(self):
3735
test_name = "auth_grant_w_no_demo_new_perm_screen"
3836
else:
3937
test_name = "auth_grant_w_no_demo"
40-
api_ver = API_V2
38+
api_ver = Versions.V2
4139
self._print_testcase_banner(test_name, api_ver, step[0], self.use_mslsx, True)
4240
self._play(TESTS[test_name], step, api_ver=api_ver)
4341
self._testclient_home()
@@ -51,7 +49,7 @@ def test_auth_grant_w_no_demo_v2(self):
5149
def test_authorize_lang_english_button(self):
5250
step = [0]
5351
test_name = "authorize_lang_english_button"
54-
api_ver = API_V2
52+
api_ver = Versions.V2
5553
self._print_testcase_banner(test_name, api_ver, step[0], self.use_mslsx, True)
5654
if USE_NEW_PERM_SCREEN == "true":
5755
# the validation of expire date etc. only applicable to new perm screen
@@ -68,7 +66,7 @@ def test_authorize_lang_english_button(self):
6866
def test_v2_authorization_and_scopes(self):
6967
step = [0]
7068
test_name = "authorize_get_v2_scopes"
71-
api_ver = API_V2
69+
api_ver = Versions.V2
7270
self._print_testcase_banner(test_name, api_ver, step[0], self.use_mslsx, True)
7371

7472
self._play(TESTS[test_name], step, api_ver=api_ver)

apps/testclient/tests.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from apps.constants import Versions, VersionNotMatched
99
from apps.testclient.utils import (_ormap, _deepfind)
1010
from apps.testclient.constants import EndpointUrl
11+
from apps.testclient.views import FhirDataParams, _build_pagination_uri
12+
from django.http import HttpRequest
1113

1214

1315
class TestclientHelpers(TestCase):
@@ -54,6 +56,40 @@ def test_httpification(self):
5456
self.assertEqual(_start_url_with_http_or_https("httpsx://localhost:8000"), "https://httpsx://localhost:8000")
5557

5658

59+
class TestPaginationURIs(TestCase):
60+
def test_build_pagination_no_id(self):
61+
uri_base = "https://notaurl.gov"
62+
params = FhirDataParams("explanation-of-benefit", "some-resource-uri", 2, None)
63+
req = HttpRequest()
64+
# Set up no GET properties.
65+
setattr(req, "GET", {})
66+
try:
67+
_build_pagination_uri(uri_base, params, req)
68+
except ValueError:
69+
# Because no 'patient' or 'beneficiary' was found in the GET params,
70+
# _build_pagination_uri will fail.
71+
pass
72+
73+
def test_build_pagination_with_id(self):
74+
uri_base = "https://notaurl.gov"
75+
params = FhirDataParams("explanation-of-benefit", "some-resource-uri", 2, None)
76+
req = HttpRequest()
77+
for id_type in ['patient', 'beneficiary']:
78+
with self.subTest(id_type=id_type):
79+
# Set up pagination GET properties
80+
setattr(req, "GET", {
81+
"_count": 42,
82+
f"{id_type}": "-123456",
83+
})
84+
85+
result = _build_pagination_uri(uri_base, params, req)
86+
self.assertIn(uri_base, result)
87+
self.assertIn(f"{id_type}=-123456", result)
88+
# We should have no navi elements
89+
self.assertIn("_count", result)
90+
self.assertIn("startIndex", result)
91+
92+
5793
class BlueButtonClientApiUserInfoTest(TestCase):
5894
"""
5995
Test the BlueButton API UserInfo Endpoint
@@ -76,7 +112,7 @@ def versionedSetUp(self, version=Versions.NOT_AN_API_VERSION):
76112
self.patient = settings.DEFAULT_SAMPLE_FHIR_ID_V3
77113
self.username = settings.DEFAULT_SAMPLE_FHIR_ID_V3
78114
case _:
79-
raise VersionNotMatched(f"Failed to set up tests with a valid version number; given {version}")
115+
raise VersionNotMatched(f"Failed to set up tests with a valid version number; given {version}") # noqa: E702
80116

81117
# TODO V3: This may need to be parameterized based on the version number.
82118
self.another_patient = "20140000000001"
@@ -125,7 +161,7 @@ def versionedSetUp(self, version=Versions.NOT_AN_API_VERSION):
125161
case Versions.V3:
126162
self.patient = settings.DEFAULT_SAMPLE_FHIR_ID_V3
127163
case _:
128-
raise VersionNotMatched(f"Failed to set a patient id for version; given {version}")
164+
raise VersionNotMatched(f"Failed to set a patient id for version; given {version}") # noqa: E702
129165

130166
self.another_patient = "20140000000001"
131167

apps/testclient/utils.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ def _start_url_with_http_or_https(host: str) -> str:
2929
# This is also fine
3030
pass
3131
else:
32-
host = f'https://{host}'
32+
host = f'https://{host}' # noqa: E231
3333

3434
return host
3535

3636

37-
def testclient_http_response_setup(include_client_secret: bool = True, version: str = Versions.NOT_AN_API_VERSION) -> OrderedDict:
37+
def testclient_http_response_setup(include_client_secret: bool = True, version: int = Versions.NOT_AN_API_VERSION) -> OrderedDict:
3838
"""Prepare testclient response environment
3939
4040
When navigating through the testclient, we need to update the Django session
@@ -52,7 +52,6 @@ def testclient_http_response_setup(include_client_secret: bool = True, version:
5252
response = OrderedDict()
5353

5454
response['api_ver'] = version
55-
version_as_string = Versions.as_str(version)
5655

5756
oa2client = Application.objects.get(name="TestApp")
5857
response['client_id'] = oa2client.client_id
@@ -65,20 +64,20 @@ def testclient_http_response_setup(include_client_secret: bool = True, version:
6564

6665
response['resource_uri'] = host
6766
response['redirect_uri'] = '{}{}'.format(host, settings.TESTCLIENT_REDIRECT_URI)
68-
response['coverage_uri'] = '{}/{}/fhir/Coverage/'.format(host, version_as_string)
67+
response['coverage_uri'] = '{}/v{}/fhir/Coverage/'.format(host, version)
6968

7069
auth_data = __generate_auth_data()
7170
response['code_challenge_method'] = "S256"
7271
response['code_verifier'] = auth_data['code_verifier']
7372
response['code_challenge'] = auth_data['code_challenge']
7473
response['state'] = auth_data['state']
7574

76-
response['authorization_uri'] = f'{host}/{version_as_string}/o/authorize/'
77-
response['token_uri'] = f'{host}/{version_as_string}/o/token/'
78-
response['userinfo_uri'] = f'{host}/{version_as_string}/connect/userinfo'
79-
response['patient_uri'] = f'{host}/{version_as_string}/fhir/Patient/'
80-
response['eob_uri'] = f'{host}/{version_as_string}/fhir/ExplanationOfBenefit/'
81-
response['coverage_uri'] = f'{host}/{version_as_string}/fhir/Coverage/'
75+
response['authorization_uri'] = f'{host}/v{version}/o/authorize/'
76+
response['token_uri'] = f'{host}/v{version}/o/token/'
77+
response['userinfo_uri'] = f'{host}/v{version}/connect/userinfo'
78+
response['patient_uri'] = f'{host}/v{version}/fhir/Patient/'
79+
response['eob_uri'] = f'{host}/v{version}/fhir/ExplanationOfBenefit/'
80+
response['coverage_uri'] = f'{host}/v{version}/fhir/Coverage/'
8281

8382
return response
8483

apps/testclient/views.py

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,43 +54,38 @@ def _get_oauth2_session_with_token(request: HttpRequest) -> OAuth2Session:
5454
FhirDataParams = namedtuple("FhirDataParams", "name,uri,version,patient")
5555

5656

57-
def _build_pagination_uri(params, request):
58-
uri = None
57+
def _build_pagination_uri(uri: str, params: FhirDataParams, request: HttpRequest) -> str:
5958
# This sets up the navigation URI (pagination) based on whether we are handling
6059
# a patient or a beneficiary. All of this logic is essentially to add one parameter,
6160
# name correctly, to the nav URI. It is version dependent (there is no pagination in V3).
62-
nav_link = request.GET.get('nav_link', None)
63-
if nav_link is not None:
64-
# for now it's either EOB or Coverage, make this more generic later
65-
patient = request.GET.get('patient')
66-
beneficiary = request.GET.get('beneficiary')
67-
if patient is not None:
68-
id_type = 'patient'
69-
id = patient
70-
elif beneficiary is not None:
71-
id_type = 'beneficiary'
72-
id = beneficiary
73-
else:
74-
# We should not be able to get here.
75-
raise VersionNotMatched(f"Failed to set a patient id for version; given {params.version}")
76-
77-
# Extend the base URI with pagination information.
78-
uri = EndpointUrl.nav_uri(uri,
79-
count=request.GET.get('_count', 10),
80-
start_index=request.GET.get('startIndex', 0),
81-
id_type=id_type,
82-
id=id)
61+
# for now it's either EOB or Coverage, make this more generic later
62+
patient = request.GET.get('patient')
63+
beneficiary = request.GET.get('beneficiary')
64+
if patient is not None:
65+
id_type = 'patient'
66+
id = patient
67+
elif beneficiary is not None:
68+
id_type = 'beneficiary'
69+
id = beneficiary
70+
else:
71+
# We should not be able to get here.
72+
raise ValueError("Failed to set a patient id or beneficiary id on the pagination URI") # noqa: E702
73+
74+
# Extend the base URI with pagination information.
75+
uri = EndpointUrl.nav_uri(uri,
76+
count=request.GET.get('_count', 10),
77+
start_index=request.GET.get('startIndex', 0),
78+
id_type=id_type,
79+
id=id)
8380
return uri
8481

8582

8683
def _get_fhir_data_as_json(request: HttpRequest, params: FhirDataParams) -> Dict[str, object]:
8784
"""Make a call to the FHIR backend and return the JSON data from the call"""
8885
uri = EndpointUrl.fmt(params.name, params.uri, params.version, params.patient)
8986

90-
if params.version in [Versions.V1, Versions.V2]:
91-
pagination_uri = _build_pagination_uri(params, request)
92-
if pagination_uri is not None:
93-
uri = pagination_uri
87+
if params.version in [Versions.V1, Versions.V2] and request.GET.get('nav_link', None):
88+
uri = _build_pagination_uri(uri, params, request)
9489

9590
oas = _get_oauth2_session_with_token(request)
9691
r = oas.get(uri)
@@ -109,7 +104,7 @@ def _convert_response_string_to_json(json_response: str) -> Dict[str, object]:
109104
try:
110105
return json.loads(json_response.content)
111106
except JSONDecodeError:
112-
return {'error': f'Could not decode JSON; status code {json_response.status_code}'}
107+
return {'error': f'Could not decode JSON; status code {json_response.status_code}'} # noqa: E702
113108
else:
114109
# Same as above.
115110
return {'error': json_response.status_code}

docker-compose/run_selenium_tests_local.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ PYTEST_SHOW_TRACE_OPT=''
8787
# set_slsx
8888

8989
# Parse command line option
90-
while getopts "hpgt" option; do
90+
while getopts "hgt" option; do
9191
case $option in
9292
h)
9393
display_usage

docker-compose/run_selenium_tests_remote.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ display_usage() {
2020
echo "Usage:"
2121
echo "------------------"
2222
echo
23-
echo "Syntax: run_selenium_tests_remote.sh [-h|d|p] [SBX|PROD|TEST|<bb2 server url>]"
23+
echo "Syntax: run_selenium_tests_remote.sh [-h|g|t|l] [SBX|PROD|TEST|<bb2 server url>]"
2424
echo
2525
echo "Options:"
2626
echo
@@ -62,7 +62,7 @@ export SELENIUM_GRID=false
6262
# Show test actions on std out : pytest -s
6363
PYTEST_SHOW_TRACE_OPT=''
6464

65-
while getopts "hpgt" option; do
65+
while getopts "hglt" option; do
6666
case $option in
6767
h)
6868
display_usage;

requirements/requirements.dev.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ dj-database-url==2.0.0 \
259259
--hash=sha256:9c9e5f7224f62635a787e9cc3c6762c9be2b19541a21e3c08fa573bd01609b4b \
260260
--hash=sha256:a35a9f0f43775ca6f90d819dc456233ef7bcc76b47377d5d908b75c7eb320624
261261
# via -r requirements/requirements.in
262-
django==4.2.24 \
263-
--hash=sha256:40cd7d3f53bc6cd1902eadce23c337e97200888df41e4a73b42d682f23e71d80 \
264-
--hash=sha256:a6527112c58821a0dfc5ab73013f0bdd906539790a17196658e36e66af43c350
262+
django==4.2.26 \
263+
--hash=sha256:9398e487bcb55e3f142cb56d19fbd9a83e15bb03a97edc31f408361ee76d9d7a \
264+
--hash=sha256:c96e64fc3c359d051a6306871bd26243db1bd02317472a62ffdbe6c3cae14280
265265
# via
266266
# -r requirements/requirements.in
267267
# dj-database-url

0 commit comments

Comments
 (0)