Skip to content

Commit

Permalink
PI-2597 Remove message logging (#4357)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-bcl authored Oct 30, 2024
1 parent caeb1ad commit 32f8dfe
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ class AwsNotificationListener(
SpanKind.CONSUMER
) {
Span.current().setAttribute("queue", queueName)
if (notification.eventType != null && notification.eventType !in sensitiveEventTypes) {
Span.current().setAttribute("message", message)
}
try {
retry(3, RETRYABLE_EXCEPTIONS) { handler.handle(message) }
} catch (t: Throwable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package uk.gov.justice.digital.hmpps.listener

import io.awspring.cloud.sqs.listener.AsyncAdapterBlockingExecutionFailedException
import io.awspring.cloud.sqs.listener.ListenerExecutionFailedException
import io.opentelemetry.api.trace.Span
import io.sentry.Sentry
import org.hamcrest.CoreMatchers.equalTo
import org.hamcrest.MatcherAssert.assertThat
Expand All @@ -11,13 +10,12 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.Mock
import org.mockito.Mockito.*
import org.mockito.Mockito.mockStatic
import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.kotlin.any
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
import org.springframework.messaging.support.GenericMessage
import uk.gov.justice.digital.hmpps.message.MessageAttributes
import uk.gov.justice.digital.hmpps.message.Notification
import uk.gov.justice.digital.hmpps.messaging.NotificationHandler
import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.objectMapper
Expand Down Expand Up @@ -81,38 +79,4 @@ class AwsNotificationListenerTest {
it.verify { Sentry.captureException(meaningfulException) }
}
}

@Test
fun `sensitive messages are not logged`() {
val span = mock(Span::class.java, CALLS_REAL_METHODS)
mockStatic(Span::class.java, CALLS_REAL_METHODS).use {
it.`when`<Span> { Span.current() }.thenReturn(span)
listener.receive(
objectMapper.writeValueAsString(
Notification(
"my message",
MessageAttributes("my-sensitive-event-type")
)
)
)
verify(span, never()).setAttribute(eq("message"), any<String>())
}
}

@Test
fun `non-sensitive messages are logged`() {
val span = mock(Span::class.java, CALLS_REAL_METHODS)
mockStatic(Span::class.java, CALLS_REAL_METHODS).use {
it.`when`<Span> { Span.current() }.thenReturn(span)
listener.receive(
objectMapper.writeValueAsString(
Notification(
"my message",
MessageAttributes("some-other-event-type")
)
)
)
verify(span).setAttribute(eq("message"), any<String>())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ spring:

delius.db.username: CommonPlatformAndDelius # Should match value in [deploy/database/access.yml].

messaging.consumer.sensitive-event-types:
- commonplatform.case.received

management:
endpoints.web:
base-path: /
Expand Down

0 comments on commit 32f8dfe

Please sign in to comment.