|
25 | 25 | import org.springframework.boot.cloudfoundry.autoconfigure.actuate.endpoint.AccessLevel; |
26 | 26 | import org.springframework.boot.cloudfoundry.autoconfigure.actuate.endpoint.CloudFoundryAuthorizationException; |
27 | 27 | import org.springframework.boot.cloudfoundry.autoconfigure.actuate.endpoint.CloudFoundryAuthorizationException.Reason; |
28 | | -import org.springframework.boot.restclient.RestTemplateBuilder; |
29 | | -import org.springframework.boot.restclient.test.MockServerRestTemplateCustomizer; |
30 | 28 | import org.springframework.http.HttpStatus; |
31 | 29 | import org.springframework.http.MediaType; |
32 | 30 | import org.springframework.test.web.client.MockRestServiceServer; |
@@ -60,24 +58,21 @@ class SecurityServiceTests { |
60 | 58 |
|
61 | 59 | @BeforeEach |
62 | 60 | void setup() { |
63 | | - MockServerRestTemplateCustomizer mockServerCustomizer = new MockServerRestTemplateCustomizer(); |
64 | | - RestTemplateBuilder builder = new RestTemplateBuilder(mockServerCustomizer); |
65 | | - this.securityService = new SecurityService(RestClient.builder(builder.build()), CLOUD_CONTROLLER, false); |
66 | | - this.server = mockServerCustomizer.getServer(); |
| 61 | + RestClient.Builder builder = RestClient.builder(); |
| 62 | + this.server = MockRestServiceServer.bindTo(builder).build(); |
| 63 | + this.securityService = new SecurityService(builder, CLOUD_CONTROLLER, false); |
67 | 64 | } |
68 | 65 |
|
69 | 66 | @Test |
70 | 67 | void skipSslValidationWhenTrue() { |
71 | | - RestTemplateBuilder builder = new RestTemplateBuilder(); |
72 | | - this.securityService = new SecurityService(RestClient.builder(builder.build()), CLOUD_CONTROLLER, true); |
| 68 | + this.securityService = new SecurityService(RestClient.builder(), CLOUD_CONTROLLER, true); |
73 | 69 | assertThat(this.securityService).extracting("restClient.clientRequestFactory") |
74 | 70 | .isInstanceOf(SkipSslVerificationHttpRequestFactory.class); |
75 | 71 | } |
76 | 72 |
|
77 | 73 | @Test |
78 | 74 | void doNotSkipSslValidationWhenFalse() { |
79 | | - RestTemplateBuilder builder = new RestTemplateBuilder(); |
80 | | - this.securityService = new SecurityService(RestClient.builder(builder.build()), CLOUD_CONTROLLER, false); |
| 75 | + this.securityService = new SecurityService(RestClient.builder(), CLOUD_CONTROLLER, false); |
81 | 76 | assertThat(this.securityService).extracting("restClient.clientRequestFactory") |
82 | 77 | .isNotInstanceOf(SkipSslVerificationHttpRequestFactory.class); |
83 | 78 | } |
|
0 commit comments