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

Platform/13506/int tests for fhir router #14241

Open
wants to merge 35 commits into
base: master
Choose a base branch
from

Conversation

david-navapbc
Copy link
Collaborator

This PR ...

If you are suggesting a fix for a currently exploitable issue, please disclose the issue to the prime-reportstream team directly outside of GitHub instead of filing a PR, so we may immediately patch the affected systems before a disclosure. See SECURITY.md/Reporting a Vulnerability for more information.

Test Steps:

  1. Include steps to test these changes

Changes

  • Include a comprehensive list of changes in this PR
  • (For web UI changes) Include screenshots/video of changes

Checklist

Testing

  • Tested locally?
  • Ran ./prime test or ./gradlew testSmoke against local Docker ReportStream container?
  • (For Changes to /frontend-react/...) Ran npm run lint:write?
  • Added tests?

Process

  • Are there licensing issues with any new dependencies introduced?
  • Includes a summary of what a code reviewer should test/verify?
  • Updated the release notes?
  • Database changes are submitted as a separate PR?
  • DevOps team has been notified if PR requires ops support?

Linked Issues

  • Fixes #issue

To Be Done

Create GitHub issues to track the work remaining, if any

  • #issue

Specific Security-related subjects a reviewer should pay specific attention to

  • Does this PR introduce new endpoints?
    • new endpoint A
    • new endpoint B
  • Does this PR include changes in authentication and/or authorization of existing endpoints?
  • Does this change introduce new dependencies that need vetting?
  • Does this change require changes to our infrastructure?
  • Does logging contain sensitive data?
  • Does this PR include or remove any sensitive information itself?

If you answered 'yes' to any of the questions above, conduct a detailed Review that addresses at least:

  • What are the potential security threats and mitigations? Please list the STRIDE threats and how they are mitigated
    • Spoofing (faking authenticity)
      • Threat T, which could be achieved by A, is mitigated by M
    • Tampering (influence or sabotage the integrity of information, data, or system)
    • Repudiation (the ability to dispute the origin or originator of an action)
    • Information disclosure (data made available to entities who should not have it)
    • Denial of service (make a resource unavailable)
    • Elevation of Privilege (reduce restrictions that apply or gain privileges one should not have)
  • Have you ensured logging does not contain sensitive data?
  • Have you received any additional approvals needed for this change?

@david-navapbc david-navapbc requested a review from a team as a code owner April 30, 2024 16:09
Copy link

github-actions bot commented Apr 30, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

Copy link

github-actions bot commented Apr 30, 2024

Test Results

1 208 tests  +10   1 204 ✅ +10   7m 15s ⏱️ +35s
  153 suites + 1       4 💤 ± 0 
  153 files   + 1       0 ❌ ± 0 

Results for commit 36fda72. ± Comparison against base commit 58d528b.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Apr 30, 2024

Integration Test Results

 62 files  ±0   62 suites  ±0   34m 9s ⏱️ +40s
395 tests ±0  385 ✅ ±0  10 💤 ±0  0 ❌ ±0 
398 runs  ±0  388 ✅ ±0  10 💤 ±0  0 ❌ ±0 

Results for commit 36fda72. ± Comparison against base commit 58d528b.

♻️ This comment has been updated with latest results.

@david-navapbc david-navapbc force-pushed the platform/13506/int_tests_for_fhir_router branch from 49a237d to 0a7a643 Compare May 9, 2024 02:46
@david-navapbc david-navapbc added platform Platform Team and removed DRAFT labels May 9, 2024
@david-navapbc david-navapbc changed the title DRAFT -- Platform/13506/int tests for fhir router Platform/13506/int tests for fhir router May 9, 2024
@david-navapbc david-navapbc enabled auto-merge (squash) May 9, 2024 17:28
Copy link
Collaborator

@mkalish mkalish left a comment

Choose a reason for hiding this comment

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

Nice work! This is really good stuff. Couple of high level things I think need to get added before merging:

  • We should should be checking the action log details to make sure the filtering gets logged properly
  • Adding a test around the observation pruning
  • Adding a test where a report gets routed to multiple receivers
  • The processing mode filter

}

private fun createReport(
fileFormat: Report.Format,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Intellij is saying that this will always be the FHIR I would maybe drop it or you could modify one of the tests so that the HL7 is what is in the receive step

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

does the route step ever receive an HL7 message? I thought everything got converted to FHIR by the preceding step?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was this resolved? Comment seems unaddressed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that's on me - I thought the route step never received anything but FHIR hence I marked it as resolved. What would you like me to do here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

You are correct, the route step doesn't receive anything but FHIR. I think what Michael is saying is we should resolve the IntelliJ warning somehow. One option is to not pass fileFormat in at all. I think I'm actually okay with the way it is now because I see createReport getting abstracted into a common location where other integration tests, like translation, can use it?

nextAction: TaskAction,
nextEventAction: Event.EventAction,
topic: Topic,
taskIndex: Long = 0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here on this default, could amend one of the receive steps to have more than one item. Also, this name seems strange?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

happy to make whatever changes - but what name seems strange?

Copy link
Collaborator

Choose a reason for hiding this comment

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

you are passing taskIndex to ReportLineage call as reportLineageId, I think that is confusing? Also yes, same issue is in FhirFunctionIntegrationTests. I think this was left over from my original approach.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ack. will change reportLineageId to something else

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you can just remove taskIndex param from createReport and hard code a 0 for the ReportLineage ID?

reportFile, txn, action
)
if (childReport != null) {
ReportStreamTestDatabaseContainer.testDatabaseAccess
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure that it would impact your test, but this is not quite right since the item lineages are not getting created? It might not impact your test though in this case

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what do you mean the item lineages are not being created?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you look at our database tables, you'll see report_lineage and item_lineage. We are updating the report_lineage table but ignoring the item_lineage table. The FHIRRouter does not depend on the item_lineage table to perform its function, but it does update it so that means we should mock it properly so we can verify the item_lineage is correct after the step has completed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I could see this being a different ticket so we can move forward with Routing refactor. @mkalish thoughts?

every { BlobAccess getProperty "defaultBlobMetadata" } returns getBlobContainerMetadata()
mockkObject(BlobAccess.BlobContainerMetadata)
every { BlobAccess.BlobContainerMetadata.build(any(), any()) } returns getBlobContainerMetadata()
mockkConstructor(DatabaseLookupTableAccess::class)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe as a follow up, but I think in the spirit of these being integration gets I think it would great to not mock the lookup tables

Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to be addressed or ticket created and added to comment. Only then resolve the conversation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

on me - I didn't take this as an action item so much as a passing thought. Do you want me to refactor the test or do you want me to write a ticket? Happy to do either. I'm ambivalent.

Copy link
Collaborator

Choose a reason for hiding this comment

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

How about let's just add a comment for now? I don't think we need a ticket, this seems low prio tech debt to me.

Copy link

sonarcloud bot commented May 29, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
42.1% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

Copy link
Collaborator

@arnejduranovic arnejduranovic left a comment

Choose a reason for hiding this comment

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

Went through and unresolved some conversations that I wasn't sure were properly addressed.

}

private fun createReport(
fileFormat: Report.Format,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was this resolved? Comment seems unaddressed?

nextAction: TaskAction,
nextEventAction: Event.EventAction,
topic: Topic,
taskIndex: Long = 0,
Copy link
Collaborator

Choose a reason for hiding this comment

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

you are passing taskIndex to ReportLineage call as reportLineageId, I think that is confusing? Also yes, same issue is in FhirFunctionIntegrationTests. I think this was left over from my original approach.

reportFile, txn, action
)
if (childReport != null) {
ReportStreamTestDatabaseContainer.testDatabaseAccess
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you look at our database tables, you'll see report_lineage and item_lineage. We are updating the report_lineage table but ignoring the item_lineage table. The FHIRRouter does not depend on the item_lineage table to perform its function, but it does update it so that means we should mock it properly so we can verify the item_lineage is correct after the step has completed.

every { BlobAccess getProperty "defaultBlobMetadata" } returns getBlobContainerMetadata()
mockkObject(BlobAccess.BlobContainerMetadata)
every { BlobAccess.BlobContainerMetadata.build(any(), any()) } returns getBlobContainerMetadata()
mockkConstructor(DatabaseLookupTableAccess::class)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to be addressed or ticket created and added to comment. Only then resolve the conversation.

reportFile, txn, action
)
if (childReport != null) {
ReportStreamTestDatabaseContainer.testDatabaseAccess
Copy link
Collaborator

Choose a reason for hiding this comment

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

I could see this being a different ticket so we can move forward with Routing refactor. @mkalish thoughts?

// for receiver Y all five observations should be intact
assertEquals(5, fhirBundleReceiverY.getObservations().size)
val expectedCodes = listOf("94558-5", "95418-0", "95417-2", "95421-4", "95419-8")
for (i in 0..fhirBundleReceiverX.getObservations().size - 1) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Intellij doesn't like this syntax

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what do you mean it doesn't like this syntax? can you be more specific? everything works AFAIK

Copy link
Collaborator

Choose a reason for hiding this comment

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

Screenshot 2024-05-31 at 9 31 52 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform Platform Team
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants