Skip to content

Commit f478f5c

Browse files
committed
Introduce factory methods in SslInfo and remove MockSslInfo
After further consideration, we have decided to remove the recently introduced MockSslInfo in favor of introducing the following static factory methods directly in the SslInfo interface. - SslInfo.from(String sessionId) - SslInfo from(String sessionId, X509Certificate... peerCertificates) See gh-35042 See gh-35078
1 parent 1fb04cb commit f478f5c

File tree

3 files changed

+22
-98
lines changed

3 files changed

+22
-98
lines changed

spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockSslInfo.java

Lines changed: 0 additions & 95 deletions
This file was deleted.

spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/ApplicationContextTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.springframework.context.annotation.Configuration;
2525
import org.springframework.context.annotation.Import;
2626
import org.springframework.http.server.reactive.ServerHttpRequest;
27-
import org.springframework.mock.http.server.reactive.MockSslInfo;
27+
import org.springframework.http.server.reactive.SslInfo;
2828
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
2929
import org.springframework.test.web.reactive.server.WebTestClient;
3030
import org.springframework.web.bind.annotation.GetMapping;
@@ -65,7 +65,7 @@ void buildWithDefaults() {
6565
@Test // gh-35042
6666
void buildWithSslInfo() {
6767
var client = WebTestClient.bindToApplicationContext(context)
68-
.sslInfo(new MockSslInfo("test123"))
68+
.sslInfo(SslInfo.from("test123"))
6969
.webFilter(new SslSessionIdFilter())
7070
.build();
7171

spring-web/src/main/java/org/springframework/http/server/reactive/SslInfo.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
* A holder for SSL session information.
2525
*
2626
* @author Rossen Stoyanchev
27+
* @author Sam Brannen
2728
* @since 5.0.2
29+
* @see javax.net.ssl.SSLSession
2830
*/
2931
public interface SslInfo {
3032

3133
/**
32-
* Return the SSL session id, if any.
34+
* Return the SSL session ID, if any.
3335
*/
3436
@Nullable String getSessionId();
3537

@@ -38,4 +40,21 @@ public interface SslInfo {
3840
*/
3941
X509Certificate @Nullable [] getPeerCertificates();
4042

43+
44+
/**
45+
* Create {@link SslInfo} configured with the supplied session ID.
46+
* @since 7.0
47+
*/
48+
static SslInfo from(String sessionId) {
49+
return new DefaultSslInfo(sessionId, new X509Certificate[0]);
50+
}
51+
52+
/**
53+
* Create {@link SslInfo} configured with the supplied session ID and certificates.
54+
* @since 7.0
55+
*/
56+
static SslInfo from(String sessionId, X509Certificate... peerCertificates) {
57+
return new DefaultSslInfo(sessionId, peerCertificates);
58+
}
59+
4160
}

0 commit comments

Comments
 (0)