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

Oo/oslynn/15664/update rest transport for oracle rln etor nbs results #15721

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading