Skip to content

Commit c1d76e3

Browse files
committed
add test to check clientname isn't set from request when it does not match regex
1 parent 22632ed commit c1d76e3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/extensions/ConsumerNameExtractionFilterTest.kt

+15
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,19 @@ class ConsumerNameExtractionFilterTest {
4242
// Assert
4343
verify(mockRequest, times(1)).setAttribute("clientName", "consumer-name")
4444
}
45+
46+
@Test
47+
fun `does not set a clientName from request if it does not match the regex `() {
48+
// Arrange
49+
val mockRequest = mock(HttpServletRequest::class.java)
50+
whenever(mockRequest.getHeader("subject-distinguished-name")).thenReturn("CN=consumer-name")
51+
52+
val mockResponse = mock(HttpServletResponse::class.java)
53+
val mockChain = mock(FilterChain::class.java)
54+
// Act
55+
consumerNameExtractionFilter.doFilter(mockRequest, mockResponse, mockChain)
56+
57+
// Assert
58+
verify(mockRequest, times(1)).setAttribute("clientName", null)
59+
}
4560
}

0 commit comments

Comments
 (0)