Skip to content

Commit

Permalink
Merge branch 'main' into vpn-wants-standard-static-ip
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrichlake authored Mar 27, 2024
2 parents 097c04a + 428dc09 commit de39a58
Show file tree
Hide file tree
Showing 14 changed files with 270 additions and 164 deletions.
34 changes: 1 addition & 33 deletions .github/workflows/terraform-ci-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:

- uses: actions/checkout@v4

# keep in sync with terraform-ci-destroy.yml
- uses: dorny/paths-filter@v3
id: filter
with:
Expand Down Expand Up @@ -74,36 +75,3 @@ jobs:
- paths-filter
uses: ./.github/workflows/deploy_reusable-skip.yml
if: needs.paths-filter.outputs.operations != 'true'


destroy-environment:
name: Destroy PR Environment
environment:
name: pr
needs:
- pr-deploy
- paths-filter
if: needs.paths-filter.outputs.operations == 'true' && always()
runs-on: ubuntu-latest
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_USE_OIDC: true
permissions:
id-token: write
contents: read
defaults:
run:
working-directory: operations/environments/pr

steps:

- uses: actions/checkout@v4

- name: Terraform Init
id: init
run: terraform init -backend-config="key=pr_${{ github.event.number }}.tfstate"

- name: Terraform Destroy
run: terraform destroy -auto-approve -input=false -var="pr_number=${{ github.event.number }}"
56 changes: 56 additions & 0 deletions .github/workflows/terraform-ci-destroy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Terraform CI Destroy

on:
pull_request:
types:
- closed

jobs:

paths-filter:
runs-on: ubuntu-latest
outputs:
operations: ${{ steps.filter.outputs.operations }}

steps:

- uses: actions/checkout@v4

# keep in sync with terraform-ci-deploy.yml
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
operations:
- 'operations/environments/pr/**'
- 'operations/template/**'
destroy-environment:
name: Destroy PR Environment
environment:
name: pr
needs:
- paths-filter
if: needs.paths-filter.outputs.operations == 'true'
runs-on: ubuntu-latest
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_USE_OIDC: true
permissions:
id-token: write
contents: read
defaults:
run:
working-directory: operations/environments/pr

steps:

- uses: actions/checkout@v4

- name: Terraform Init
run: terraform init -backend-config="key=pr_${{ github.event.number }}.tfstate"

- name: Terraform Destroy
run: terraform destroy -auto-approve -input=false -var="pr_number=${{ github.event.number }}"
14 changes: 11 additions & 3 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -138,23 +138,31 @@
"filename": "README.md",
"hashed_secret": "367e3228ed16bf72b36de9a4134ee8b825cafacb",
"is_verified": false,
"line_number": 316,
"line_number": 314,
"is_secret": false
},
{
"type": "Secret Keyword",
"filename": "README.md",
"hashed_secret": "40bd7d88eae0468b048e62e1056ac390970b2b51",
"is_verified": false,
"line_number": 321,
"line_number": 319,
"is_secret": false
},
{
"type": "Secret Keyword",
"filename": "README.md",
"hashed_secret": "0d46754ae17642645ca041edaac9a1c1569f5edc",
"is_verified": false,
"line_number": 326,
"line_number": 324,
"is_secret": false
},
{
"type": "Secret Keyword",
"filename": "README.md",
"hashed_secret": "3c4da28c9bc45d01e4950ee6f8e67a8d1a1ec19b",
"is_verified": false,
"line_number": 334,
"is_secret": false
}
],
Expand Down
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,11 @@ For database documentation [go here](/docs/database.md)
ApplicationContext.register(RSEndpointClient.class, MockRSEndpointClient.getInstance());
} else {
ApplicationContext.register(RSEndpointClient.class, ReportStreamEndpointClient.getInstance());
ApplicationContext.register(AzureClient.class, AzureClient.getInstance());
}
```
with:
```Java
ApplicationContext.register(RSEndpointClient.class, ReportStreamEndpointClient.getInstance());
ApplicationContext.register(AzureClient.class, AzureClient.getInstance());
```
3. Run TI with `./gradlew clean app:run`

Expand Down Expand Up @@ -331,9 +329,31 @@ with this option enabled.
"apiKey": "Contents of file at trusted-intermediary/mock_credentials/organization-report-stream-private-key-local.pem",
"user": "flexion"
}
```
3. Create secret for `DEFAULT-SFTP`
1. Path for this secret: `DEFAULT-SFTP`
2. JSON data:
```
{
"@type": "UserPass",
"user": "user",
"pass": "pass"
}
```
#### Submit request to ReportStream
In order to submit a request, you'll need to authenticate with ReportStream using JWT auth:
1. Create a JWT for the sender (e.g. `flexion.simulated-hospital`) using the sender's private key. You may use [this CLI tool](https://github.com/mike-engel/jwt-cli) to create the JWT:
```
jwt encode --exp='+5min' --jti $(uuidgen) --alg RS256 -k <sender> -i <sender> -s <sender> -a staging.prime.cdc.gov --no-iat -S @/path/to/sender_private.pem
```
2. Use the generated JWT to authenticate with ReportStream and get the token, which will be in the `access_token` response
```
curl --header 'Content-Type: application/x-www-form-urlencoded' --data 'scope=flexion.*.report' --data 'client_assertion=<jwt>' --data 'client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer' --data 'grant_type=client_credentials' 'http://localhost:7071/api/token'
```
3. Submit an Order or Result using the returned token
##### Orders
To test sending from a simulated hospital:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gov.hhs.cdc.trustedintermediary.e2e


import spock.lang.Specification

import java.nio.file.Files
Expand All @@ -17,7 +18,6 @@ class MetadataTest extends Specification {
given:
def expectedStatusCode = 200
def inboundSubmissionId = UUID.randomUUID().toString()
def outboundSubmissionId = "1234567890"
def orderClient = new EndpointClient("/v1/etor/orders")
def labOrderJsonFileString = Files.readString(Path.of("../examples/Test/Orders/002_ORM_O01.fhir"))

Expand All @@ -29,8 +29,9 @@ class MetadataTest extends Specification {

when:
def inboundMetadataResponse = metadataClient.get(inboundSubmissionId, true)
def outboundMetadataResponse = metadataClient.get(outboundSubmissionId, true)
def inboundParsedJsonBody = JsonParsing.parseContent(inboundMetadataResponse)
def outboundSubmissionId = inboundParsedJsonBody.issue[8].diagnostics
def outboundMetadataResponse = metadataClient.get(outboundSubmissionId, true)
def outboundParsedJsonBody = JsonParsing.parseContent(outboundMetadataResponse)

then:
Expand All @@ -42,10 +43,13 @@ class MetadataTest extends Specification {
[
"sender name",
"receiver name",
"order ingestion",
"ingestion",
"payload hash",
"delivery status",
"status message"
"status message",
"message type",
"outbound submission id",
"inbound submission id"
].each { String metadataKey ->
def issue = (inboundParsedJsonBody.issue as List).find( {issue -> issue.details.text == metadataKey })
assert issue != null
Expand All @@ -58,7 +62,6 @@ class MetadataTest extends Specification {
given:
def expectedStatusCode = 200
def inboundSubmissionId = UUID.randomUUID().toString()
def outboundSubmissionId = "1234567890"
def resultClient = new EndpointClient("/v1/etor/results")
def labResult = Files.readString(Path.of("../examples/Test/Results/001_ORU_R01.fhir"))

Expand All @@ -70,8 +73,9 @@ class MetadataTest extends Specification {

when:
def inboundMetadataResponse = metadataClient.get(inboundSubmissionId, true)
def outboundMetadataResponse = metadataClient.get(outboundSubmissionId, true)
def inboundParsedJsonBody = JsonParsing.parseContent(inboundMetadataResponse)
def outboundSubmissionId = inboundParsedJsonBody.issue[8].diagnostics
def outboundMetadataResponse = metadataClient.get(outboundSubmissionId, true)
def outboundParsedJsonBody = JsonParsing.parseContent(outboundMetadataResponse)

then:
Expand All @@ -83,10 +87,13 @@ class MetadataTest extends Specification {
[
"sender name",
"receiver name",
"result ingestion",
"ingestion",
"payload hash",
"delivery status",
"status message"
"status message",
"message type",
"outbound submission id",
"inbound submission id"
].each { String metadataKey ->
def issue = (inboundParsedJsonBody.issue as List).find( {issue -> issue.details.text == metadataKey })
assert issue != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import gov.hhs.cdc.trustedintermediary.etor.messages.SendMessageHelper;
import gov.hhs.cdc.trustedintermediary.etor.messages.UnableToSendMessageException;
import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadata;
import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadataConverter;
import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadataException;
import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadataOrchestrator;
import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadataStorage;
Expand All @@ -38,6 +39,7 @@
import gov.hhs.cdc.trustedintermediary.external.database.PostgresDao;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiMessageConverterHelper;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiOrderConverter;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiPartnerMetadataConverter;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiResultConverter;
import gov.hhs.cdc.trustedintermediary.external.localfile.FilePartnerMetadataStorage;
import gov.hhs.cdc.trustedintermediary.external.localfile.MockRSEndpointClient;
Expand Down Expand Up @@ -81,8 +83,7 @@ public class EtorDomainRegistration implements DomainConnector {
@Inject Logger logger;
@Inject DomainResponseHelper domainResponseHelper;
@Inject PartnerMetadataOrchestrator partnerMetadataOrchestrator;

@Inject OrderConverter orderConverter;
@Inject PartnerMetadataConverter partnerMetadataConverter;

@Inject HapiFhir fhir;

Expand Down Expand Up @@ -122,6 +123,8 @@ public Map<HttpEndpoint, Function<DomainRequest, DomainResponse>> domainRegistra
// Metadata
ApplicationContext.register(
PartnerMetadataOrchestrator.class, PartnerMetadataOrchestrator.getInstance());
ApplicationContext.register(
PartnerMetadataConverter.class, HapiPartnerMetadataConverter.getInstance());
// Validation rules
ApplicationContext.register(RuleLoader.class, RuleLoader.getInstance());
ApplicationContext.register(RuleEngine.class, RuleEngine.getInstance());
Expand Down Expand Up @@ -214,7 +217,7 @@ DomainResponse handleMetadata(DomainRequest request) {
}

FhirMetadata<?> responseObject =
orderConverter.extractPublicMetadataToOperationOutcome(
partnerMetadataConverter.extractPublicMetadataToOperationOutcome(
metadata.get(), metadataId);

return domainResponseHelper.constructOkResponseFromString(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package gov.hhs.cdc.trustedintermediary.etor.metadata.partner;

import gov.hhs.cdc.trustedintermediary.etor.operationoutcomes.FhirMetadata;

public interface PartnerMetadataConverter {

/**
* This method will convert {@link PartnerMetadata} and convert it into an {@link
* org.hl7.fhir.r4.model.OperationOutcome}
*
* @param metadata
* @param requestedId
* @return
*/
FhirMetadata<?> extractPublicMetadataToOperationOutcome(
PartnerMetadata metadata, String requestedId);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package gov.hhs.cdc.trustedintermediary.etor.orders;

import gov.hhs.cdc.trustedintermediary.etor.demographics.Demographics;
import gov.hhs.cdc.trustedintermediary.etor.metadata.partner.PartnerMetadata;
import gov.hhs.cdc.trustedintermediary.etor.operationoutcomes.FhirMetadata;

/** Interface for converting things to orders and things in orders. */
public interface OrderConverter {
Expand All @@ -13,7 +11,4 @@ public interface OrderConverter {
Order<?> addContactSectionToPatientResource(Order<?> order);

Order<?> addEtorProcessingTag(Order<?> message);

FhirMetadata<?> extractPublicMetadataToOperationOutcome(
PartnerMetadata metadata, String requestedId);
}
Loading

0 comments on commit de39a58

Please sign in to comment.