View Javadoc
1   /*
2    * SPDX-FileCopyrightText: Copyright (c) 2011-2025 Yegor Bugayenko
3    * SPDX-License-Identifier: MIT
4    */
5   package com.jcabi.http.wire;
6   
7   import com.jcabi.http.mock.MkAnswer;
8   import com.jcabi.http.mock.MkContainer;
9   import com.jcabi.http.mock.MkGrizzlyContainer;
10  import com.jcabi.http.request.JdkRequest;
11  import com.jcabi.http.response.RestResponse;
12  import java.net.HttpURLConnection;
13  import org.junit.jupiter.api.Test;
14  
15  /**
16   * Test case for {@link TrustedWire}.
17   * @since 1.10
18   */
19  final class TrustedWireTest {
20  
21      /**
22       * TrustedWire can ignore PKIX errors.
23       * @throws Exception If something goes wrong inside
24       */
25      @Test
26      void ignoresPkixErrors() throws Exception {
27          final MkContainer container = new MkGrizzlyContainer().next(
28              new MkAnswer.Simple("")
29          ).start();
30          try {
31              new JdkRequest(container.home())
32                  .through(TrustedWire.class)
33                  .fetch()
34                  .as(RestResponse.class)
35                  .assertStatus(HttpURLConnection.HTTP_OK);
36          } finally {
37              container.stop();
38          }
39      }
40  
41  }