forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rest Client Reactive - support for quarkus.tls.trust-all
fixes quarkusio#16656
- Loading branch information
1 parent
e4f1d6b
commit 1296a1a
Showing
6 changed files
with
97 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...t-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/ssl/TrustAllTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package io.quarkus.rest.client.reactive.ssl; | ||
|
||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; | ||
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.net.URI; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
|
||
import org.eclipse.microprofile.rest.client.RestClientBuilder; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import com.github.tomakehurst.wiremock.WireMockServer; | ||
import com.github.tomakehurst.wiremock.client.WireMock; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class TrustAllTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Client.class)) | ||
.withConfigurationResource("trust-all-test-application.properties"); | ||
|
||
WireMockServer server; | ||
URI baseUri; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
server = new WireMockServer(wireMockConfig().dynamicHttpsPort()); | ||
server.stubFor(WireMock.get("/ssl") | ||
.willReturn(aResponse().withBody("hello").withStatus(200))); | ||
server.start(); | ||
baseUri = URI.create("https://localhost:" + server.httpsPort()); | ||
} | ||
|
||
@AfterEach | ||
public void cleanUp() { | ||
server.shutdown(); | ||
} | ||
|
||
@Test | ||
void shouldWorkWithTrustAllAndSelfSignedCert() { | ||
Client client = RestClientBuilder.newBuilder() | ||
.baseUri(baseUri) | ||
.build(Client.class); | ||
assertThat(client.get()).isEqualTo("hello"); | ||
} | ||
|
||
@Path("ssl") | ||
interface Client { | ||
@GET | ||
String get(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
.../rest-client-reactive/deployment/src/test/resources/trust-all-test-application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
quarkus.tls.trust-all=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters