|
| 1 | +/* |
| 2 | + * Copyright 2013-2023 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
1 | 17 | package org.springframework.cloud.gateway.test.ssl;
|
2 | 18 |
|
3 | 19 | import io.netty.handler.ssl.SslContextBuilder;
|
4 | 20 | import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
5 | 21 | import org.junit.jupiter.api.BeforeEach;
|
| 22 | +import reactor.netty.http.client.HttpClient; |
| 23 | + |
6 | 24 | import org.springframework.beans.factory.annotation.Autowired;
|
7 | 25 | import org.springframework.boot.ssl.SslBundles;
|
8 | 26 | import org.springframework.boot.test.context.SpringBootTest;
|
9 | 27 | import org.springframework.http.client.reactive.ReactorClientHttpConnector;
|
10 | 28 | import org.springframework.test.annotation.DirtiesContext;
|
11 | 29 | import org.springframework.test.context.ActiveProfiles;
|
12 |
| -import reactor.netty.http.client.HttpClient; |
13 | 30 |
|
14 | 31 | import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
15 | 32 |
|
16 | 33 | @SpringBootTest(webEnvironment = RANDOM_PORT)
|
17 | 34 | @DirtiesContext
|
18 | 35 | @ActiveProfiles("client-auth-ssl-bundle")
|
19 | 36 | public class ClientCertAuthSSLBundleTests extends SingleCertSSLTests {
|
| 37 | + |
20 | 38 | @Autowired
|
21 | 39 | private SslBundles sslBundles;
|
22 | 40 |
|
23 | 41 | @BeforeEach
|
24 | 42 | public void setup() throws Exception {
|
25 | 43 | final var sslBundle = sslBundles.getBundle("scg-keystore-with-different-key-password");
|
26 | 44 | final var sslContext = SslContextBuilder.forClient()
|
27 |
| - .trustManager(InsecureTrustManagerFactory.INSTANCE) |
28 |
| - .keyManager(sslBundle.getManagers().getKeyManagerFactory()) |
29 |
| - .build(); |
| 45 | + .trustManager(InsecureTrustManagerFactory.INSTANCE) |
| 46 | + .keyManager(sslBundle.getManagers().getKeyManagerFactory()) |
| 47 | + .build(); |
30 | 48 | HttpClient httpClient = HttpClient.create().secure(ssl -> ssl.sslContext(sslContext));
|
31 | 49 | setup(new ReactorClientHttpConnector(httpClient), "https://localhost:" + port);
|
32 | 50 | }
|
| 51 | + |
33 | 52 | }
|
0 commit comments