Search in sources :

Example 1 with SERVER_KEY_STORE

use of org.infinispan.rest.helper.RestServerHelper.SERVER_KEY_STORE in project infinispan by infinispan.

the class CertificateTest method shouldAllowProperCertificate.

@Test
public void shouldAllowProperCertificate() throws Exception {
    restServer = RestServerHelper.defaultRestServer().withAuthenticator(new ClientCertAuthenticator()).withKeyStore(SERVER_KEY_STORE, STORE_PASSWORD, STORE_TYPE).withTrustStore(SERVER_KEY_STORE, STORE_PASSWORD, STORE_TYPE).withClientAuth().start(TestResourceTracker.getCurrentTestShortName());
    RestClientConfigurationBuilder config = new RestClientConfigurationBuilder();
    config.security().ssl().enable().trustStoreFileName(CLIENT_KEY_STORE).trustStorePassword(STORE_PASSWORD).trustStoreType(STORE_TYPE).keyStoreFileName(CLIENT_KEY_STORE).keyStorePassword(STORE_PASSWORD).keyStoreType(STORE_TYPE).hostnameVerifier((hostname, session) -> true).addServer().host("localhost").port(restServer.getPort());
    client = RestClient.forConfiguration(config.build());
    // when
    CompletionStage<RestResponse> response = client.raw().get("/rest/v2/caches/default/test", Collections.emptyMap());
    // then
    assertEquals(404, response.toCompletableFuture().get(10, TimeUnit.MINUTES).getStatus());
}
Also used : TestResourceTracker(org.infinispan.commons.test.TestResourceTracker) RestResponse(org.infinispan.client.rest.RestResponse) RestClient(org.infinispan.client.rest.RestClient) Test(org.testng.annotations.Test) CLIENT_KEY_STORE(org.infinispan.rest.helper.RestServerHelper.CLIENT_KEY_STORE) ClientCertAuthenticator(org.infinispan.rest.authentication.impl.ClientCertAuthenticator) AfterMethod(org.testng.annotations.AfterMethod) RestServerHelper(org.infinispan.rest.helper.RestServerHelper) STORE_PASSWORD(org.infinispan.rest.helper.RestServerHelper.STORE_PASSWORD) TimeUnit(java.util.concurrent.TimeUnit) RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) STORE_TYPE(org.infinispan.rest.helper.RestServerHelper.STORE_TYPE) CompletionStage(java.util.concurrent.CompletionStage) AbstractInfinispanTest(org.infinispan.test.AbstractInfinispanTest) SERVER_KEY_STORE(org.infinispan.rest.helper.RestServerHelper.SERVER_KEY_STORE) AfterSuite(org.testng.annotations.AfterSuite) AssertJUnit.assertEquals(org.testng.AssertJUnit.assertEquals) Collections(java.util.Collections) RestClientConfigurationBuilder(org.infinispan.client.rest.configuration.RestClientConfigurationBuilder) ClientCertAuthenticator(org.infinispan.rest.authentication.impl.ClientCertAuthenticator) RestResponse(org.infinispan.client.rest.RestResponse) Test(org.testng.annotations.Test) AbstractInfinispanTest(org.infinispan.test.AbstractInfinispanTest)

Aggregations

Collections (java.util.Collections)1 CompletionStage (java.util.concurrent.CompletionStage)1 TimeUnit (java.util.concurrent.TimeUnit)1 RestClient (org.infinispan.client.rest.RestClient)1 RestResponse (org.infinispan.client.rest.RestResponse)1 RestClientConfigurationBuilder (org.infinispan.client.rest.configuration.RestClientConfigurationBuilder)1 TestResourceTracker (org.infinispan.commons.test.TestResourceTracker)1 ClientCertAuthenticator (org.infinispan.rest.authentication.impl.ClientCertAuthenticator)1 RestServerHelper (org.infinispan.rest.helper.RestServerHelper)1 CLIENT_KEY_STORE (org.infinispan.rest.helper.RestServerHelper.CLIENT_KEY_STORE)1 SERVER_KEY_STORE (org.infinispan.rest.helper.RestServerHelper.SERVER_KEY_STORE)1 STORE_PASSWORD (org.infinispan.rest.helper.RestServerHelper.STORE_PASSWORD)1 STORE_TYPE (org.infinispan.rest.helper.RestServerHelper.STORE_TYPE)1 AbstractInfinispanTest (org.infinispan.test.AbstractInfinispanTest)1 AssertJUnit.assertEquals (org.testng.AssertJUnit.assertEquals)1 AfterMethod (org.testng.annotations.AfterMethod)1 AfterSuite (org.testng.annotations.AfterSuite)1 Test (org.testng.annotations.Test)1