|
60 | 60 | import org.springframework.security.web.server.authentication.DelegatingServerAuthenticationSuccessHandler;
|
61 | 61 | import org.springframework.security.web.server.authentication.HttpBasicServerAuthenticationEntryPoint;
|
62 | 62 | import org.springframework.security.web.server.authentication.HttpStatusServerEntryPoint;
|
| 63 | +import org.springframework.security.web.server.authentication.ServerAuthenticationConverter; |
63 | 64 | import org.springframework.security.web.server.authentication.ServerAuthenticationFailureHandler;
|
64 | 65 | import org.springframework.security.web.server.authentication.ServerAuthenticationSuccessHandler;
|
65 | 66 | import org.springframework.security.web.server.authentication.ServerX509AuthenticationConverter;
|
@@ -497,6 +498,17 @@ public void x509WhenCustomizedThenAddsX509Filter() {
|
497 | 498 | assertThat(x509WebFilter).isNotNull();
|
498 | 499 | }
|
499 | 500 |
|
| 501 | + @Test |
| 502 | + public void x509WithConverterAndNoExtractorThenAddsX509Filter() { |
| 503 | + ServerAuthenticationConverter mockConverter = mock(ServerAuthenticationConverter.class); |
| 504 | + this.http.x509((x509) -> x509.serverAuthenticationConverter(mockConverter)); |
| 505 | + SecurityWebFilterChain securityWebFilterChain = this.http.build(); |
| 506 | + WebFilter x509WebFilter = securityWebFilterChain.getWebFilters() |
| 507 | + .filter(filter -> matchesX509Converter(filter, mockConverter)) |
| 508 | + .blockFirst(); |
| 509 | + assertThat(x509WebFilter).isNotNull(); |
| 510 | + } |
| 511 | + |
500 | 512 | @Test
|
501 | 513 | public void addsX509FilterWhenX509AuthenticationIsConfiguredWithDefaults() {
|
502 | 514 | this.http.x509(withDefaults());
|
@@ -769,6 +781,17 @@ private boolean isX509Filter(WebFilter filter) {
|
769 | 781 | }
|
770 | 782 | }
|
771 | 783 |
|
| 784 | + private boolean matchesX509Converter(WebFilter filter, ServerAuthenticationConverter expectedConverter) { |
| 785 | + try { |
| 786 | + Object converter = ReflectionTestUtils.getField(filter, "authenticationConverter"); |
| 787 | + return converter.equals(expectedConverter); |
| 788 | + } |
| 789 | + catch (IllegalArgumentException ex) { |
| 790 | + // field doesn't exist |
| 791 | + return false; |
| 792 | + } |
| 793 | + } |
| 794 | + |
772 | 795 | private <T extends WebFilter> Optional<T> getWebFilter(SecurityWebFilterChain filterChain, Class<T> filterClass) {
|
773 | 796 | return (Optional<T>) filterChain.getWebFilters()
|
774 | 797 | .filter(Objects::nonNull)
|
|
0 commit comments