Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FI-3222: DTR Client Tests: Use Random Number for Attestation Continuation Links #20

Conversation

degradification
Copy link
Contributor

@degradification degradification commented Oct 11, 2024

Description

This ticket updated the Full EHR and SMART App attestation tests to use random ids instead of client id tokens

Important Changes

Removed client id tokens and replaced with random id tokens for the following files

  • lib/davinci_dtr_test_kit/client_groups/dinner_static/dtr_full_ehr_launch_attestation_test.rb
  • lib/davinci_dtr_test_kit/client_groups/dinner_static/dtr_full_ehr_prepopulation_attestation_test.rb
  • lib/davinci_dtr_test_kit/client_groups/dinner_static/dtr_full_ehr_prepopulation_override_attestation_test.rb
  • lib/davinci_dtr_test_kit/client_groups/dinner_static/dtr_full_ehr_rendering_enabled_questions_attestation_test.rb
  • lib/davinci_dtr_test_kit/client_groups/dinner_static/dtr_full_ehr_store_attestation_test.rb
  • lib/davinci_dtr_test_kit/client_groups/dinner_static/dtr_smart_app_prepopulation_attestation_test.rb
  • lib/davinci_dtr_test_kit/client_groups/dinner_static/dtr_smart_app_prepopulation_override_attestation_test.rb
  • lib/davinci_dtr_test_kit/client_groups/dinner_static/dtr_smart_app_rendering_enabled_questions_attestation_test.rb

lib/davinci_dtr_test_kit/client_groups/resp_assist_device/dtr_questionnaire_rendering_attestation_test.rb

  • Fixed Typos
  • Update the client id to use a random token value instead this resulted in other changes needed to be made

lib/davinci_dtr_test_kit/mock_auth_server.rb

  • Defined a function to determine if the query value being used is a client_id or token value

lib/davinci_dtr_test_kit/dtr_smart_app_suite.rb

  • Updated resume_test_route to use the new defined determine query value function

spec/davinci_dtr_test_kit/dtr_questionnaire_rendering_group_spec.rb

  • Updated to change client_id usage to token
  • Made adjustments to ensure token from dtr_questionnaire_rendering_attestation_test.rb was received and returned

Testing Recommendations

Make sure all unit tests pass (unit tests were not added for this pull request), and the application runs as expected. Run the FullEHR tests to test both expected successes and expected failures. Run the SMART App Test Suite tests to test both expected success and expected failures.

Checklists

Submitter:

  • This MR describes why these changes were made.
  • This MR is into the correct branch (usually 'main').
  • Comment added to the relevant Jira ticket(s) with a link to this MR.
  • The relevant Jira ticket has been moved to 'Peer Review' (may be N/A if a Jira ticket is associated with multiple MRs)
  • Code diff has been reviewed (it does not contain: additional white space, not applicable code changes, debug statements, etc.).
  • Ensure automated tests pass successfully.

Final Merger

  • The necessary number of reviews/approvals have been received on this PR and all checklists have been completed.
  • The relevant Jira ticket has been moved to 'Done' (may N/A if a Jira ticket is associated with multiple MRs)

@degradification degradification added the enhancement New feature or request label Oct 11, 2024
@degradification degradification self-assigned this Oct 11, 2024
@karlnaden
Copy link
Contributor

The changes Look good. While we're doing this, I would change the use of client_id in dtr_questionnaire_rendering_attestation_test.rb because it also means that the client_id input gets added to a group that it wouldn't otherwise be on (all others are involved in communication with inferno, so its already needed). This will ideally require a few other changes

  • change the parameter name from client_id to token or something similar that doesn't suggest this is a non-random value
  • change the definition of the resume routes in lib/davinci_dtr_test_kit/dtr_smart_app_suite.rb to extract the session identifier from the new parameter name using the extract_token_from_query_params

Copy link
Contributor

@karlnaden karlnaden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment on one place to replace the use of client_id

@degradification degradification force-pushed the fi-3222-dtr-client-tests-use-random-number-attestation-links branch from 54926aa to f868ae5 Compare October 29, 2024 17:19
- Fixed typos in `lib/davinci_dtr_test_kit/client_groups/resp_assist_device/dtr_questionnaire_rendering_attestation_test.rb`
@degradification degradification force-pushed the fi-3222-dtr-client-tests-use-random-number-attestation-links branch from f868ae5 to 84bf302 Compare November 13, 2024 16:27
…to use token instead of client_id

-Addressed rubocop warnings
-Changed lib/davinci_dtr_test_kit/dtr_smart_app_suite.rb to extract the session identifier from the new parameter name using the extract_token_from_query_params
-Updated tests to use the correct token definition
@degradification degradification force-pushed the fi-3222-dtr-client-tests-use-random-number-attestation-links branch from 7c53623 to e0ccd78 Compare November 19, 2024 19:46
-Ensured the attestation tests for resp work
-Updated the resume_test_routes in mock_auth_server.rb to check for parameter value
)
input :client_id

config(options: { token: SecureRandom.uuid })
Copy link
Contributor

@karlnaden karlnaden Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vanessuniq @degradification - can you explain the use of a config option here instead of including it in the run block as done in all the other tests? Should this pattern be used everywhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workaround allows for unit testing this test. When the token is included as a variable within the run block, mocking the requests get("#{resume_pass_url}?token=#{token}") or get("#{resume_fail_url}?token=#{token}") in the spec file spec/davinci_dtr_test_kit/dtr_questionnaire_rendering_group_spec.rb will always results in a "wait" status instead of a "pass" or "fail." This happens because the token defined in the unit test will always differ from the token generated in the test's run block.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting - we haven't typically unit tested attestations because they are so simple. On the fence as to whether I think using this more complicated pattern is worth enabling unit tests. But since we already had them, let's leave in place and call this good. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I found a simpler way, keeping the token in the run block. will reach out to Dalton to refactor and keep it simple before we merge it.

Copy link
Contributor

@karlnaden karlnaden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one last question.

)
input :client_id

config(options: { token: SecureRandom.uuid })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting - we haven't typically unit tested attestations because they are so simple. On the fence as to whether I think using this more complicated pattern is worth enabling unit tests. But since we already had them, let's leave in place and call this good. Thanks!

@degradification degradification merged commit a98e97f into main Nov 21, 2024
3 checks passed
@degradification degradification deleted the fi-3222-dtr-client-tests-use-random-number-attestation-links branch November 21, 2024 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants