Skip to content

Commit

Permalink
Merge branch 'master' into engagement/nj_prework
Browse files Browse the repository at this point in the history
  • Loading branch information
victor-chaparro authored Sep 6, 2024
2 parents 9b07852 + 7f93cf9 commit e804079
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .environment/gitleaks/gitleaks-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ title = "PRIME ReportStream Gitleaks Configuration"
'authority\", \"extension\"', # FHIR extension URL also shows up in normal FHIR test data
'ApiKeyCredential\(\"flexion\"',
'authType: \"two-legged\"',
'\"apiKey\"',
'api-key\" to \"oracle123\"',
'Authorization-Type: \"username/password\"',
'cdctiautomated_sa'
]
Expand Down
22 changes: 17 additions & 5 deletions prime-router/settings/STLTs/Oracle/oracle-rln.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,21 @@
initialTime: "00:00"
timeZone: "EASTERN"
maxReportCount: 100
description: ""
transport:
type: "SFTP"
host: "172.17.6.20"
port: 22
filePath: "./upload"
credentialName: null
reportUrl: "https://spaces.erxhubdevcert.cerner.com/etor"
authTokenUrl: ""
encryptionKeyUrl: ""
authType: "apiKey"
tlsKeystore: null
parameters: {}
jwtParams: {}
headers:
Content-Type: "text/plain"
shared-api-key: "From Vault"
authHeaders: {}
type: "REST"
externalName: null
enrichmentSchemaNames: []
timeZone: null
dateTimeFormat: "OFFSET"
1 change: 1 addition & 0 deletions prime-router/src/main/kotlin/transport/RESTTransport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class RESTTransport(private val httpClient: HttpClient? = null) : ITransport {

if (restTransportInfo.authType == "apiKey") {
val apiKeyCredential = credential as UserApiKeyCredential
httpHeaders["shared-api-key"] = apiKeyCredential.apiKey
httpHeaders["System_ID"] = apiKeyCredential.user
httpHeaders["Key"] = apiKeyCredential.apiKey
accessToken = apiKeyCredential.apiKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,64 @@ hnm8COa8Kr+bnTqzScpQuOfujHcFEtfcYUGfSS6HusxidwXx+lYi1A==
assertThat(retryItems).isNull()
}

// Epic localhost end-to-end testing
private val oracleRlNRestTransport = RESTTransportType(
"https://sendURL",
"",
authType = "apiKey",
headers = mapOf(
"Content-Type" to "text/plain",
"shared-api-key" to "From Vault"
)
)

val expectedHttpHeaders = mapOf(
"Content-Type" to "text/plain",
"shared-api-key" to "oracle123",
"System_ID" to "test-user",
"Key" to "oracle123"
)

@Test
fun `test transport postReport with valid message to oracle-rln--etor-nbs-results`() {
val header = makeHeader()
val mockRestTransport = spyk(RESTTransport(mockClientAuthOk()))

// Given:
// lookupDefaultCredential returns mock UserApiKeyCredential object to allow
// the getAuthTokenWIthUserApiKey() to be called.
every { mockRestTransport.lookupDefaultCredential(any()) }.returns(
UserApiKeyCredential(
"test-user",
"oracle123"
)
)

// When:
// RESTTransport is called WITH flexionRestTransportType which has transport.parameters
val retryItems = mockRestTransport.send(
oracleRlNRestTransport, header, reportId, "test", null,
context, actionHistory, mockk<IReportStreamEventService>(relaxed = true)
)

// Then:
// postReport should be called with correct httpheaders' values as given.
verify {
runBlocking {
mockRestTransport.postReport(
any(),
any(),
any(),
expectedHttpHeaders,
any(),
any(),
any()
)
}
}
assertThat(retryItems).isNull()
}

@Test
fun `test post vs put http client`() {
val logger = mockkClass(Logger::class)
Expand Down

0 comments on commit e804079

Please sign in to comment.