Skip to content

Commit 6e1ab0f

Browse files
authored
First pass at fixing Selenium tests (#1328)
* First pass at fixing Selenium tests * Attempt to fix broken logging integration test * Fix failing logging integration test. * Fix integration logging test * Yet another adjustment to failing test * Another tweak * Hopefully last one * More V2 updates to logging tests * Update userinfo path * Fix connect userinfo * Update metadata endpoint * Update openidConfig
1 parent 4aa9dd7 commit 6e1ab0f

File tree

5 files changed

+49
-135
lines changed

5 files changed

+49
-135
lines changed

apps/integration_tests/log_event_schemas.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"elapsed": {"type": "number"},
3737
"ip_addr": {"type": "string", "format": "ip-address"},
3838
"request_uuid": {"type": "string", "format": "uuid"},
39-
"path": {"pattern": "/v1/o/token"},
39+
"path": {"pattern": "/v2/o/token"},
4040
"request_method": {"pattern": "POST"},
4141
"request_scheme": {"pattern": "http"},
4242
"response_code": {"type": "integer", "enum": [http.client.OK]},
@@ -347,7 +347,7 @@
347347
"req_qparam_format": {"pattern": "json"},
348348
"req_qparam_patient": {"type": "string"},
349349
"req_qparam_beneficiary": {"type": "string"},
350-
"path": {"pattern": "/v1/fhir/.+"},
350+
"path": {"pattern": "/v2/fhir/.+"},
351351
"user": {"type": "string"},
352352
"fhir_id": {"type": "string"},
353353
"access_token_scopes": {"type": "string"},
@@ -390,7 +390,7 @@
390390
"req_qparam_patient": {"type": "string"},
391391
"req_qparam_beneficiary": {"type": "string"},
392392
"req_qparam_startindex": {"type": "string"},
393-
"path": {"pattern": "/v1/fhir/.+"},
393+
"path": {"pattern": "/v2/fhir/.+"},
394394
"user": {"type": "string"},
395395
"fhir_id": {"type": "string"},
396396
"access_token_scopes": {"type": "string"},
@@ -429,7 +429,7 @@
429429
"req_user_id": {"type": "integer"},
430430
"req_user_username": {"type": "string"},
431431
"req_fhir_id": {"type": "string"},
432-
"path": {"pattern": "/v1/fhir/.+"},
432+
"path": {"pattern": "/v2/fhir/.+"},
433433
"user": {"type": "string"},
434434
"fhir_id": {"type": "string"},
435435
"access_token_scopes": {"type": "string"},
@@ -467,7 +467,7 @@
467467
"req_user_id": {"type": "integer"},
468468
"req_user_username": {"type": "string"},
469469
"req_fhir_id": {"type": "string"},
470-
"path": {"pattern": "/v1/connect/userinfo"},
470+
"path": {"pattern": "/v2/connect/userinfo"},
471471
"user": {"type": "string"},
472472
"fhir_id": {"type": "string"},
473473
"access_token_scopes": {"type": "string"},

apps/integration_tests/logging_tests.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
"path": "/testclient/",
3636
},
3737
{
38-
# v1 auth link
38+
# auth link
3939
"schema": LOG_MIDDLEWARE_TESTCLIENT_AUTHLINK_EVENT_SCHEMA,
40-
"path": "/testclient/authorize-link",
40+
"path": "/testclient/authorize-link-v2",
4141
},
4242
{
4343
# authorize as a bene
@@ -62,11 +62,11 @@
6262
},
6363
{
6464
"schema": LOG_MIDDLEWARE_POST_TOKEN_EVENT_SCHEMA,
65-
"path": "/v1/o/token/",
65+
"path": "/v2/o/token/",
6666
},
6767
{
6868
"schema": LOG_MIDDLEWARE_EVENT_SCHEMA,
69-
"path": "/v1/connect/userinfo",
69+
"path": "/v2/connect/userinfo",
7070
},
7171
{
7272
"schema": LOG_MIDDLEWARE_EVENT_SCHEMA,
@@ -80,29 +80,29 @@
8080
},
8181
{
8282
"schema": LOG_MIDDLEWARE_FHIR_READ_EVENT_SCHEMA,
83-
"path_regex": "/v1/fhir/Patient/-20140000008325|/v1/fhir/Patient/-19990000000001"
83+
"path_regex": "/v2/fhir/Patient/-20140000008325|/v2/fhir/Patient/-19990000000001"
8484
},
8585
{
8686
"schema": LOG_MIDDLEWARE_TESTCLIENT_FHIR_READ_EVENT_SCHEMA,
87-
"path": "/testclient/Patient"
87+
"path": "/testclient/PatientV2"
8888
},
8989
{
9090
# first Coverage
9191
"schema": LOG_MIDDLEWARE_FHIR_SEARCH_EVENT_SCHEMA,
92-
"path": "/v1/fhir/Coverage/"
92+
"path": "/v2/fhir/Coverage/"
9393
},
9494
{
9595
"schema": LOG_MIDDLEWARE_TESTCLIENT_FHIR_SEARCH_EVENT_SCHEMA,
96-
"path": "/testclient/Coverage"
96+
"path": "/testclient/CoverageV2"
9797
},
9898
{
9999
# last Coverage
100100
"schema": LOG_MIDDLEWARE_FHIR_NAVIGATION_EVENT_SCHEMA,
101-
"path": "/v1/fhir/Coverage/"
101+
"path": "/v2/fhir/Coverage/"
102102
},
103103
{
104104
"schema": LOG_MIDDLEWARE_TESTCLIENT_FHIR_NAVIGATION_EVENT_SCHEMA,
105-
"path": "/testclient/Coverage"
105+
"path": "/testclient/CoverageV2"
106106
},
107107
{
108108
# test client fhir links page
@@ -112,20 +112,20 @@
112112
{
113113
# first EOB
114114
"schema": LOG_MIDDLEWARE_FHIR_SEARCH_EVENT_SCHEMA,
115-
"path": "/v1/fhir/ExplanationOfBenefit/"
115+
"path": "/v2/fhir/ExplanationOfBenefit/"
116116
},
117117
{
118118
"schema": LOG_MIDDLEWARE_TESTCLIENT_FHIR_SEARCH_EVENT_SCHEMA,
119-
"path": "/testclient/ExplanationOfBenefit"
119+
"path": "/testclient/ExplanationOfBenefitV2"
120120
},
121121
{
122122
# last EOB
123123
"schema": LOG_MIDDLEWARE_FHIR_NAVIGATION_EVENT_SCHEMA,
124-
"path": "/v1/fhir/ExplanationOfBenefit/"
124+
"path": "/v2/fhir/ExplanationOfBenefit/"
125125
},
126126
{
127127
"schema": LOG_MIDDLEWARE_TESTCLIENT_FHIR_NAVIGATION_EVENT_SCHEMA,
128-
"path": "/testclient/ExplanationOfBenefit"
128+
"path": "/testclient/ExplanationOfBenefitV2"
129129
},
130130
{
131131
# test client fhir links page
@@ -135,22 +135,22 @@
135135
{
136136
# userinfo ep
137137
"schema": LOG_MIDDLEWARE_FHIR_USERINFO_EVENT_SCHEMA,
138-
"path": "/v1/connect/userinfo"
138+
"path": "/v2/connect/userinfo"
139139
},
140140
{
141141
# userinfo testclient url
142142
"schema": LOG_MIDDLEWARE_TESTCLIENT_MISCINFO_EVENT_SCHEMA,
143-
"path": "/testclient/userinfo"
143+
"path": "/testclient/userinfoV2"
144144
},
145145
{
146146
# meta data
147147
"schema": LOG_MIDDLEWARE_TESTCLIENT_MISCINFO_EVENT_SCHEMA,
148-
"path": "/testclient/metadata"
148+
"path": "/testclient/metadataV2"
149149
},
150150
{
151151
# openid discovery
152152
"schema": LOG_MIDDLEWARE_TESTCLIENT_MISCINFO_EVENT_SCHEMA,
153-
"path": "/testclient/openidConfig"
153+
"path": "/testclient/openidConfigV2"
154154
},
155155
{
156156
# restart test client - go to test client home page with v1, v2 get sample token buttons
@@ -199,6 +199,6 @@ def _validate_events(self):
199199
assert len(expected_events) == 0
200200

201201
def test_auth_fhir_flows_logging(self):
202-
self.test_auth_grant_fhir_calls_v1()
202+
self.test_auth_grant_pkce_fhir_calls_v2()
203203
print("validating logging events in log...")
204204
self._validate_events()

apps/integration_tests/selenium_cases.py

Lines changed: 23 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ class Action(Enum):
1818
BACK = 7
1919
LOGIN = 8
2020
CONTAIN_TEXT = 9
21-
GET_SAMPLE_TOKEN_START = 10
22-
GET_SAMPLE_TOKEN_PKCE_START = 11
23-
SLEEP = 12
24-
VALIDATE_EMAIL_NOTIFICATION = 13
25-
CHECK_DATE_FORMAT = 14
26-
COPY_LINK_AND_LOAD_WITH_PARAM = 15
27-
FIND_MSG_BY_CLASS = 16
21+
GET_SAMPLE_TOKEN_PKCE_START = 10
22+
SLEEP = 11
23+
VALIDATE_EMAIL_NOTIFICATION = 12
24+
CHECK_DATE_FORMAT = 13
25+
COPY_LINK_AND_LOAD_WITH_PARAM = 14
26+
FIND_MSG_BY_CLASS = 15
2827

2928

3029
TESTCLIENT_BUNDLE_LABEL_FMT = "Response (Bundle of {}), API version: {}"
@@ -36,10 +35,7 @@ class Action(Enum):
3635
'''
3736
LNK_TXT_SIGNUP = "Signup"
3837
LNK_TXT_TESTCLIENT = "Test Client"
39-
LNK_TXT_GET_TOKEN_V1 = "Get a Sample Authorization Token"
40-
LNK_TXT_GET_TOKEN_V2 = "Get a Sample Authorization Token for v2"
41-
LNK_TXT_GET_TOKEN_PKCE_V1 = "Get a Sample Authorization Token (PKCE Enabled)"
42-
LNK_TXT_GET_TOKEN_PKCE_V2 = "Get a Sample Authorization Token for v2 (PKCE Enabled)"
38+
LNK_TXT_GET_TOKEN = "Get a Sample Authorization Token"
4339
LNK_TXT_AUTH_AS_BENE = "Authorize as a Beneficiary"
4440
LNK_TXT_AUTH_AS_BENE_SPANISH = "Authorize as a Beneficiary (Spanish)"
4541
LNK_TXT_RESTART_TESTCLIENT = "restart testclient"
@@ -160,7 +156,6 @@ class Action(Enum):
160156

161157
# API versions
162158
API_V2 = "v2"
163-
API_V1 = "v1"
164159

165160
BROWSERBACK = {
166161
"display": "Back to FHIR resource page",
@@ -176,7 +171,7 @@ class Action(Enum):
176171
CHECK_TESTCLIENT_START_PAGE = {
177172
"display": "Check it's on 'Test Client' start page",
178173
"action": Action.FIND,
179-
"params": [30, By.LINK_TEXT, LNK_TXT_GET_TOKEN_V1]
174+
"params": [30, By.LINK_TEXT, LNK_TXT_GET_TOKEN]
180175
}
181176

182177
CLICK_TESTCLIENT = {
@@ -289,22 +284,18 @@ class Action(Enum):
289284
},
290285
CLICK_TESTCLIENT if not HOSTNAME_URL.startswith(PROD_URL) else LOAD_TESTCLIENT_HOME,
291286
{
292-
"display": "Click link to get sample token v1/v2",
293-
"action": Action.GET_SAMPLE_TOKEN_START,
287+
"display": "Click link to get sample token v1/v2 with PKCE enabled",
288+
"action": Action.GET_SAMPLE_TOKEN_PKCE_START,
294289
},
295290
]
296291

297-
SEQ_AUTHORIZE_START = [
292+
SEQ_AUTHORIZE_START_SPANISH = [
298293
{"sequence": SEQ_REACH_AUTHORIZE_BTN},
299294
{
300-
"display": "Click link 'Authorize as a Beneficiary' - start authorization",
301-
"action": Action.FIND_CLICK,
302-
"params": [30, By.LINK_TEXT, LNK_TXT_AUTH_AS_BENE]
295+
"display": "Check authorize link for PKCE challenge info present",
296+
"action": Action.CHECK_PKCE_CHALLENGE,
297+
"params": [20, By.TAG_NAME, TAG_FOR_AUTHORIZE_LINK, True]
303298
},
304-
]
305-
306-
SEQ_AUTHORIZE_START_SPANISH = [
307-
{"sequence": SEQ_REACH_AUTHORIZE_BTN},
308299
{
309300
"display": "Click link 'Authorize as a Beneficiary (Spanish)' - start authorization using medicare login in Spanish",
310301
"action": Action.FIND_CLICK,
@@ -316,7 +307,7 @@ class Action(Enum):
316307
CLICK_RESTART_TESTCLIENT,
317308
{
318309
"display": "Click link to get sample token v1/v2",
319-
"action": Action.GET_SAMPLE_TOKEN_START,
310+
"action": Action.GET_SAMPLE_TOKEN_PKCE_START,
320311
},
321312
{
322313
"display": "Click link 'Authorize as a Beneficiary' - start authorization",
@@ -326,16 +317,7 @@ class Action(Enum):
326317
]
327318

328319
SEQ_AUTHORIZE_PKCE_START = [
329-
{
330-
"display": "Load BB2 Landing Page ...",
331-
"action": Action.LOAD_PAGE,
332-
"params": [HOSTNAME_URL]
333-
},
334-
CLICK_TESTCLIENT if not HOSTNAME_URL.startswith(PROD_URL) else LOAD_TESTCLIENT_HOME,
335-
{
336-
"display": "Click link to get sample token v1/v2 with PKCE enabled",
337-
"action": Action.GET_SAMPLE_TOKEN_PKCE_START,
338-
},
320+
{"sequence": SEQ_REACH_AUTHORIZE_BTN},
339321
{
340322
"display": "Check authorize link for PKCE challenge info present",
341323
"action": Action.CHECK_PKCE_CHALLENGE,
@@ -357,7 +339,7 @@ class Action(Enum):
357339
CLICK_TESTCLIENT if not HOSTNAME_URL.startswith(PROD_URL) else LOAD_TESTCLIENT_HOME,
358340
{
359341
"display": "Click link to get sample token v1/v2",
360-
"action": Action.GET_SAMPLE_TOKEN_START,
342+
"action": Action.GET_SAMPLE_TOKEN_PKCE_START,
361343
},
362344
{
363345
"display": "Call authorize endpoint with lang param - start authorization",
@@ -532,40 +514,34 @@ class Action(Enum):
532514
]
533515

534516
TESTS = {
535-
"auth_grant_fhir_calls": [
536-
{"sequence": SEQ_AUTHORIZE_START},
537-
CALL_LOGIN,
538-
CLICK_AGREE_ACCESS,
539-
{"sequence": SEQ_QUERY_FHIR_RESOURCES}
540-
],
541517
"auth_grant_pkce_fhir_calls": [
542518
{"sequence": SEQ_AUTHORIZE_PKCE_START},
543519
CALL_LOGIN,
544520
CLICK_AGREE_ACCESS,
545521
{"sequence": SEQ_QUERY_FHIR_RESOURCES}
546522
],
547523
"auth_deny_fhir_calls": [
548-
{"sequence": SEQ_AUTHORIZE_START},
524+
{"sequence": SEQ_AUTHORIZE_PKCE_START},
549525
CALL_LOGIN,
550526
CLICK_DENY_ACCESS,
551527
CHECK_TESTCLIENT_START_PAGE
552528
],
553529
"auth_grant_w_no_demo": [
554-
{"sequence": SEQ_AUTHORIZE_START},
530+
{"sequence": SEQ_AUTHORIZE_PKCE_START},
555531
CALL_LOGIN,
556532
CLICK_RADIO_NOT_SHARE,
557533
CLICK_AGREE_ACCESS,
558534
{"sequence": SEQ_QUERY_FHIR_RESOURCES_NO_DEMO}
559535
],
560536
"auth_grant_w_no_demo_new_perm_screen": [
561-
{"sequence": SEQ_AUTHORIZE_START},
537+
{"sequence": SEQ_AUTHORIZE_PKCE_START},
562538
CALL_LOGIN,
563539
CLICK_RADIO_NOT_SHARE_NEW_PERM_SCREEN,
564540
CLICK_AGREE_ACCESS,
565541
{"sequence": SEQ_QUERY_FHIR_RESOURCES_NO_DEMO}
566542
],
567543
"authorize_lang_english_button": [
568-
{"sequence": SEQ_AUTHORIZE_START},
544+
{"sequence": SEQ_AUTHORIZE_PKCE_START},
569545
CALL_LOGIN,
570546
WAIT_SECONDS,
571547
WAIT_SECONDS,
@@ -596,7 +572,7 @@ class Action(Enum):
596572
SPANISH_TESTS = {
597573
"toggle_language": [
598574
# kick off default test client
599-
{"sequence": SEQ_AUTHORIZE_START},
575+
{"sequence": SEQ_AUTHORIZE_PKCE_START},
600576
CALL_LOGIN,
601577
# Wait to make sure we're logged in because login page also has Spanish link
602578
WAIT_SECONDS,
@@ -972,7 +948,7 @@ class Action(Enum):
972948
],
973949
# call authorize twice (1st call and 2nd call) - only 1st call emit email notification
974950
"first_api_call_email": [
975-
{"sequence": SEQ_AUTHORIZE_START},
951+
{"sequence": SEQ_AUTHORIZE_PKCE_START},
976952
CALL_LOGIN,
977953
CLICK_AGREE_ACCESS,
978954
VALIDATE_1ST_APP_CREATED_EMAIL,

apps/integration_tests/selenium_generic.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,8 @@
1515
from .selenium_cases import (
1616
Action,
1717
TESTCASE_BANNER_FMT,
18-
LNK_TXT_GET_TOKEN_V1,
19-
LNK_TXT_GET_TOKEN_PKCE_V1,
20-
LNK_TXT_GET_TOKEN_V2,
21-
LNK_TXT_GET_TOKEN_PKCE_V2,
18+
LNK_TXT_GET_TOKEN,
2219
LNK_TXT_RESTART_TESTCLIENT,
23-
API_V2,
24-
API_V1,
2520
SEQ_LOGIN_MSLSX,
2621
SEQ_LOGIN_SLSX,
2722
PROD_URL,
@@ -96,7 +91,6 @@ def setup_method(self, method):
9691
Action.CHECK: self._check_page_title,
9792
Action.CHECK_PKCE_CHALLENGE: self._check_pkce_challenge,
9893
Action.CONTAIN_TEXT: self._check_page_content,
99-
Action.GET_SAMPLE_TOKEN_START: self._click_get_sample_token,
10094
Action.GET_SAMPLE_TOKEN_PKCE_START: self._click_get_sample_token_pkce,
10195
Action.BACK: self._back,
10296
Action.LOGIN: self._login,
@@ -151,15 +145,8 @@ def _find_and_sendkey(self, timeout_sec, by, by_expr, txt, **kwargs):
151145
elem.send_keys(txt)
152146
return elem
153147

154-
def _click_get_sample_token(self, **kwargs):
155-
return self._find_and_click(30, By.LINK_TEXT,
156-
LNK_TXT_GET_TOKEN_V2 if kwargs.get("api_ver",
157-
API_V1) == API_V2 else LNK_TXT_GET_TOKEN_V1)
158-
159148
def _click_get_sample_token_pkce(self, **kwargs):
160-
return self._find_and_click(30, By.LINK_TEXT,
161-
LNK_TXT_GET_TOKEN_PKCE_V2 if kwargs.get("api_ver", API_V1) == API_V2
162-
else LNK_TXT_GET_TOKEN_PKCE_V1)
149+
return self._find_and_click(30, By.LINK_TEXT, LNK_TXT_GET_TOKEN)
163150

164151
def _find_and_return(self, timeout_sec, by, by_expr, **kwargs):
165152
elem = WebDriverWait(self.driver, timeout_sec).until(EC.visibility_of_element_located((by, by_expr)))

0 commit comments

Comments
 (0)