Skip to content
This repository was archived by the owner on May 12, 2026. It is now read-only.

Commit e7c97fc

Browse files
authored
Return 410 Gone response to inactive senders in pipeline (#18748)
* Return 410 Gone response to inactive senders in pipeline * Moved sender checking to the processRequest function * Added allowed senders to the list * Added more test senders to the comment * Added check the sender.customerStatus inactive * Added Unit Test * Made message short and simple * Update the message
1 parent b6da23f commit e7c97fc

3 files changed

Lines changed: 43 additions & 3 deletions

File tree

prime-router/src/main/kotlin/azure/HttpUtilities.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,19 @@ class HttpUtilities {
210210
return httpResponse(request, msg, status)
211211
}
212212

213+
/**
214+
* convenience method that combines logging, and generation of an HtttpResponse
215+
* the requested resourece is permanently unavailable and will not be available again in the future.
216+
*/
217+
fun gone(
218+
request: HttpRequestMessage<String?>,
219+
msg: String,
220+
status: HttpStatus = HttpStatus.GONE,
221+
): HttpResponseMessage {
222+
logger.error(msg)
223+
return httpResponse(request, msg, status)
224+
}
225+
213226
/**
214227
* Do a variety of checks on payload size.
215228
* Returns a Pair (http error code, human readable error message)

prime-router/src/main/kotlin/azure/ReportFunction.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,18 @@ class ReportFunction(
533533
request: HttpRequestMessage<String?>,
534534
sender: Sender,
535535
): HttpResponseMessage {
536+
// Allow only CVS.default sender to pass through and deactivate all other senders.
537+
// We also allow sender organizations of igore and test to pass since they are using for smoketest for RS.
538+
if (!listOf("test", "ignore", "waters").contains(sender.organizationName) &&
539+
sender.customerStatus == CustomerStatus.INACTIVE
540+
) {
541+
return HttpUtilities.gone(
542+
request,
543+
"ReportStream sunsetted on December 31, 2025. For more detail, please refer to " +
544+
"https://reportstream.cdc.gov."
545+
)
546+
}
547+
536548
// determine if we should be following the sync or async workflow
537549
val isAsync = processingType(request, sender) == ProcessingType.async
538550
// allow duplicates 'override' param

prime-router/src/test/kotlin/azure/ReportFunctionTests.kt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class ReportFunctionTests {
252252
}
253253

254254
/** Do all the setup required to be able to run any process request tests**/
255-
private fun setupForProcessRequestTests(actionHistory: ActionHistory):
255+
private fun setupForProcessRequestTests(actionHistory: ActionHistory, senderOrg: String = "test"):
256256
Triple<ReportFunction, MockHttpRequestMessage, Sender> {
257257
val metadata = UnitTestUtils.simpleMetadata
258258
val settings = FileSettings().loadOrganizations(oneOrganization)
@@ -261,7 +261,7 @@ class ReportFunctionTests {
261261
val reportFunc = spyk(ReportFunction(engine, actionHistory))
262262
val sender = CovidSender(
263263
"Test Sender",
264-
"test",
264+
senderOrg,
265265
MimeFormat.CSV,
266266
schemaName =
267267
"one",
@@ -855,6 +855,21 @@ class ReportFunctionTests {
855855
verify(exactly = 0) { actionHistory.trackLogs(any<ActionLog>()) }
856856
}
857857

858+
@Test
859+
fun `test processRequest should return HttpStatus GONE`() {
860+
// setup steps
861+
val actionHistory = spyk(ActionHistory(TaskAction.receive))
862+
var (reportFunc, req, sender) = setupForProcessRequestTests(actionHistory, "senderInactive")
863+
req.queryParameters["option"] = "ValidatePayload"
864+
865+
// Call the processRequest
866+
var resp = reportFunc.processRequest(req, sender)
867+
868+
// Report Validated and no warnings returned
869+
assert(resp.status.equals(HttpStatus.GONE))
870+
verify(exactly = 0) { actionHistory.trackLogs(any<ActionLog>()) }
871+
}
872+
858873
@Test
859874
fun `test throws an error for an invalid payloadname`() {
860875
// 2052 character
@@ -1450,7 +1465,7 @@ class ReportFunctionTests {
14501465

14511466
val sender = UniversalPipelineSender(
14521467
name = "Test Sender",
1453-
organizationName = "org",
1468+
organizationName = "test",
14541469
format = MimeFormat.HL7,
14551470
hl7AcknowledgementEnabled = true,
14561471
topic = Topic.FULL_ELR,

0 commit comments

Comments
 (0)