Skip to content

Commit c31c18f

Browse files
BB2-3882: Add selenium coverage to ensure v2 SMART App scopes are ret… (#1380)
* BB2-3882: Add selenium coverage to ensure v2 SMART App scopes are returned * Revert env var * Address feedback and update a scope to correct format * Update last test to use constants as well
1 parent 0759e29 commit c31c18f

File tree

3 files changed

+64
-4
lines changed

3 files changed

+64
-4
lines changed

apps/dot_ext/tests/demographic_scopes_test_cases.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
'patient/Coverage.r',
3030
'patient/Coverage.s',
3131
'patient/Coverage.rs',
32-
'patient/launch',
32+
'launch/patient',
3333
'openid'
3434
]
3535
V2_SCOPES_ALL_CONDENSED = [
3636
'patient/Patient.rs',
3737
'patient/ExplanationOfBenefit.rs',
3838
'patient/Coverage.rs',
39-
'patient/launch',
39+
'launch/patient',
4040
'openid'
4141
]
4242
V2_SCOPES_NON_DEMOGRAPHIC = [
@@ -46,13 +46,13 @@
4646
'patient/Coverage.r',
4747
'patient/Coverage.s',
4848
'patient/Coverage.rs',
49-
'patient/launch',
49+
'launch/patient',
5050
'openid'
5151
]
5252
V2_SCOPES_NON_DEMOGRAPHIC_CONDENSED = [
5353
'patient/ExplanationOfBenefit.rs',
5454
'patient/Coverage.rs',
55-
'patient/launch',
55+
'launch/patient',
5656
'openid'
5757
]
5858

apps/integration_tests/selenium_cases.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,14 @@ class Action(Enum):
157157
# API versions
158158
API_V2 = "v2"
159159

160+
# v2 SMART APP scope constants
161+
X_PATH_FOR_USER_SCOPES = "//*[@id='main-content']/div/div/div/pre"
162+
COVERAGE_SCOPE = "patient/Coverage.rs"
163+
PATIENT_SCOPE = "patient/Patient.rs"
164+
EOB_SCOPE = "patient/ExplanationOfBenefit.rs"
165+
OPENID_SCOPE = "openid"
166+
LAUNCH_SCOPE = "launch/patient"
167+
160168
BROWSERBACK = {
161169
"display": "Back to FHIR resource page",
162170
"action": Action.BACK,
@@ -513,6 +521,34 @@ class Action(Enum):
513521
BROWSERBACK,
514522
]
515523

524+
SEQ_CHECK_SCOPES = [
525+
{
526+
"display": "Check that v2 SMART APP scopes were returned",
527+
"action": Action.CONTAIN_TEXT,
528+
"params": [20, By.XPATH, X_PATH_FOR_USER_SCOPES, COVERAGE_SCOPE]
529+
},
530+
{
531+
"display": "Check that v2 SMART APP scopes were returned",
532+
"action": Action.CONTAIN_TEXT,
533+
"params": [20, By.XPATH, X_PATH_FOR_USER_SCOPES, PATIENT_SCOPE]
534+
},
535+
{
536+
"display": "Check that v2 SMART APP scopes were returned",
537+
"action": Action.CONTAIN_TEXT,
538+
"params": [20, By.XPATH, X_PATH_FOR_USER_SCOPES, EOB_SCOPE]
539+
},
540+
{
541+
"display": "Check that v2 SMART APP scopes were returned",
542+
"action": Action.CONTAIN_TEXT,
543+
"params": [20, By.XPATH, X_PATH_FOR_USER_SCOPES, OPENID_SCOPE]
544+
},
545+
{
546+
"display": "Check that v2 SMART APP scopes were returned",
547+
"action": Action.CONTAIN_TEXT,
548+
"params": [20, By.XPATH, X_PATH_FOR_USER_SCOPES, LAUNCH_SCOPE]
549+
}
550+
]
551+
516552
TESTS = {
517553
"auth_grant_pkce_fhir_calls": [
518554
{"sequence": SEQ_AUTHORIZE_PKCE_START},
@@ -565,6 +601,15 @@ class Action(Enum):
565601
# the 'approve' and 'deny' button click not using locale based text
566602
# so it is lang agnostic
567603
CLICK_AGREE_ACCESS
604+
],
605+
"authorize_get_v2_scopes": [
606+
{"sequence": SEQ_AUTHORIZE_PKCE_START},
607+
CALL_LOGIN,
608+
WAIT_SECONDS,
609+
WAIT_SECONDS,
610+
CLICK_AGREE_ACCESS,
611+
# Check the different scopes that have been returned
612+
{"sequence": SEQ_CHECK_SCOPES}
568613
]
569614
}
570615

apps/integration_tests/selenium_tests.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,18 @@ def test_authorize_lang_english_button(self):
6060
print("Skip test " + test_name + " - only for new perm screen.")
6161
self._testclient_home()
6262
self._print_testcase_banner(test_name, api_ver, step[0], self.use_mslsx, False)
63+
64+
'''
65+
Test authorizing through the test client, using v2 URLs, and ensuring all of the
66+
SMART App v2 Scopes are available within the returned token
67+
'''
68+
def test_v2_authorization_and_scopes(self):
69+
step = [0]
70+
test_name = "authorize_get_v2_scopes"
71+
api_ver = API_V2
72+
self._print_testcase_banner(test_name, api_ver, step[0], self.use_mslsx, True)
73+
74+
self._play(TESTS[test_name], step, api_ver=api_ver)
75+
76+
self._testclient_home()
77+
self._print_testcase_banner(test_name, api_ver, step[0], self.use_mslsx, False)

0 commit comments

Comments
 (0)