Skip to content

Commit

Permalink
[RESTEASY-1926]:Fix ssl client authentication test
Browse files Browse the repository at this point in the history
  • Loading branch information
jimma committed Nov 22, 2018
1 parent a72cbaa commit 6c52374
Show file tree
Hide file tree
Showing 12 changed files with 7 additions and 35 deletions.
Expand Up @@ -19,11 +19,8 @@
*/
public enum SSLCerts
{
DEFAULT_SERVER_KEYSTORE("ssl/default_server_keystore.jks", "secret".toCharArray(), null, null),
SNI_SERVER_KEYSTORE("ssl/sni_server_keystore.jks", "secret".toCharArray(), null, null),
NO_TRUSTED_CLIENTS_KEYSTORE("ssl/no_trusted_clients_keystore.jks", "secret".toCharArray(), null, null),
DEFAULT_TRUSTSTORE(null, null, "ssl/default_client_truststore.jks", "secret".toCharArray()),
SNI_TRUSTSTORE(null, null, "ssl/sni_client_truststore.jks", "secret".toCharArray());
SERVER_KEYSTORE("ssl/server.keystore", "password".toCharArray(), "ssl/server.truststore", "password".toCharArray()),
CLIENT_KEYSTORE("ssl/client.keystore", "password".toCharArray(), "ssl/client.truststore", "password".toCharArray());

private final SSLContext sslContext;

Expand Down
Expand Up @@ -81,28 +81,27 @@ public void testJAXRS() throws Exception
public void testSSLClientAuthNone() throws Exception
{
JAXRS.Configuration configuration = JAXRS.Configuration.builder().host("localhost").port(8443).rootPath("ssl")
.sslContext(SSLCerts.DEFAULT_SERVER_KEYSTORE.getSslContext())
.sslContext(SSLCerts.SERVER_KEYSTORE.getSslContext())
.sslClientAuthentication(SSLClientAuthentication.NONE).build();
CompletionStage<Instance> instance = JAXRS.start(new MyApp(), configuration);
instance.toCompletableFuture().get();
ResteasyClient client = createClientWithCertificate(SSLCerts.DEFAULT_TRUSTSTORE.getSslContext());
ResteasyClient client = createClientWithCertificate(SSLCerts.CLIENT_KEYSTORE.getSslContext());
Assert.assertEquals("hello world",
client.target("https://localhost:8443/ssl/base/test").request().get(String.class));
instance.toCompletableFuture().get().stop();

}

//@Test
//TODO:Fix this
@Test
public void testSSLClientAuthRequired() throws Exception
{

JAXRS.Configuration configuration = JAXRS.Configuration.builder().host("localhost").port(8443).rootPath("clientauth")
.sslContext(SSLCerts.SNI_SERVER_KEYSTORE.getSslContext())
.sslContext(SSLCerts.SERVER_KEYSTORE.getSslContext())
.sslClientAuthentication(SSLClientAuthentication.MANDATORY).build();
CompletionStage<Instance> instance = JAXRS.start(new MyApp(), configuration);
instance.toCompletableFuture().get();
ResteasyClient client = createClientWithCertificate(SSLCerts.SNI_TRUSTSTORE.getSslContext());
ResteasyClient client = createClientWithCertificate(SSLCerts.CLIENT_KEYSTORE.getSslContext());
Assert.assertEquals("hello world",
client.target("https://localhost:8443/clientauth/base/test").request().get(String.class));
instance.toCompletableFuture().get().stop();
Expand Down
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 6c52374

Please sign in to comment.