|
1 | 1 | /* |
2 | | - * Copyright 2012-2023 the original author or authors. |
| 2 | + * Copyright 2012-2025 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -295,14 +295,23 @@ void skipSslValidation() { |
295 | 295 | Object interceptorSecurityService = ReflectionTestUtils.getField(interceptor, |
296 | 296 | "cloudFoundrySecurityService"); |
297 | 297 | WebClient webClient = (WebClient) ReflectionTestUtils.getField(interceptorSecurityService, "webClient"); |
298 | | - webClient.get() |
| 298 | + doesNotFailWithSslException(() -> webClient.get() |
299 | 299 | .uri("https://self-signed.badssl.com/") |
300 | 300 | .retrieve() |
301 | 301 | .toBodilessEntity() |
302 | | - .block(Duration.ofSeconds(30)); |
| 302 | + .block(Duration.ofSeconds(30))); |
303 | 303 | }); |
304 | 304 | } |
305 | 305 |
|
| 306 | + private static void doesNotFailWithSslException(Runnable action) { |
| 307 | + try { |
| 308 | + action.run(); |
| 309 | + } |
| 310 | + catch (RuntimeException ex) { |
| 311 | + assertThat(findCause(ex, SSLException.class)).isNull(); |
| 312 | + } |
| 313 | + } |
| 314 | + |
306 | 315 | @Test |
307 | 316 | void sslValidationNotSkippedByDefault() { |
308 | 317 | this.contextRunner.withConfiguration(AutoConfigurations.of(HealthEndpointAutoConfiguration.class)) |
@@ -340,6 +349,16 @@ private WebOperation findOperationWithRequestPath(ExposableWebEndpoint endpoint, |
340 | 349 | "No operation found with request path " + requestPath + " from " + endpoint.getOperations()); |
341 | 350 | } |
342 | 351 |
|
| 352 | + private static <E extends Throwable> E findCause(Throwable failure, Class<E> type) { |
| 353 | + while (failure != null) { |
| 354 | + if (type.isInstance(failure)) { |
| 355 | + return type.cast(failure); |
| 356 | + } |
| 357 | + failure = failure.getCause(); |
| 358 | + } |
| 359 | + return null; |
| 360 | + } |
| 361 | + |
343 | 362 | @Endpoint(id = "test") |
344 | 363 | static class TestEndpoint { |
345 | 364 |
|
|
0 commit comments