Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISPN-14050 Create test for TLS in transport #10251

Merged
merged 1 commit into from Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -80,6 +80,7 @@ public void evaluate() throws Throwable {
base.evaluate();
} catch (Throwable e) {
log.error("Problem during the server initialization", e);
throw e;
} finally {
InfinispanServerRule.this.after(testName);
if (manageServer && testServer.isDriverInitialized()) {
Expand Down
@@ -0,0 +1,52 @@
package org.infinispan.server.security;

import static org.junit.Assert.assertEquals;

import org.infinispan.client.hotrod.RemoteCache;
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.configuration.cache.CacheMode;
import org.infinispan.server.test.api.TestUser;
import org.infinispan.server.test.core.category.Security;
import org.infinispan.server.test.junit4.InfinispanServerRule;
import org.infinispan.server.test.junit4.InfinispanServerRuleBuilder;
import org.infinispan.server.test.junit4.InfinispanServerTestMethodRule;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;

/**
* Tests transport TLS
*
* @author Pedro Ruivo
* @since 14.0
**/
@Category(Security.class)
public class TransportTLSIT {

@ClassRule
public static InfinispanServerRule SERVERS =
InfinispanServerRuleBuilder.config("configuration/TransportTLSTest.xml")
.numServers(2)
.build();

@Rule
public InfinispanServerTestMethodRule SERVER_TEST = new InfinispanServerTestMethodRule(SERVERS);

@Test
public void testReadWrite() {
ConfigurationBuilder hotRodBuilder = new ConfigurationBuilder();
hotRodBuilder.security().authentication()
.serverName("infinispan")
.realm("default")
.username(TestUser.ADMIN.getUser())
.password(TestUser.ADMIN.getPassword());
RemoteCache<String, String> cache = SERVER_TEST.hotrod()
.withClientConfiguration(hotRodBuilder)
.withCacheMode(CacheMode.DIST_SYNC)
.create();
cache.put("k1", "v1");
assertEquals(1, cache.size());
assertEquals("v1", cache.get("k1"));
}
}
25 changes: 25 additions & 0 deletions server/tests/src/test/resources/configuration/TransportTLSTest.xml
@@ -0,0 +1,25 @@
<infinispan
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xi="http://www.w3.org/2001/XInclude"
xsi:schemaLocation="urn:infinispan:config:14.0 https://infinispan.org/schemas/infinispan-config-14.0.xsd
urn:infinispan:server:14.0 https://infinispan.org/schemas/infinispan-server-14.0.xsd"
xmlns="urn:infinispan:config:14.0"
xmlns:server="urn:infinispan:server:14.0">

<xi:include href="jgroups/stacks.xml"/>

<xi:include href="cache-container/clustered-tls.xml"/>

<server xmlns="urn:infinispan:server:14.0">

<xi:include href="interfaces/default.xml"/>

<xi:include href="socket-bindings/default.xml"/>

<xi:include href="security/tls-transport.xml"/>

<endpoints>
<xi:include href="endpoints/auth-implicit.xml"/>
</endpoints>
</server>
</infinispan>
@@ -0,0 +1,15 @@
<cache-container xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:locks="urn:infinispan:config:clustered-locks:14.0"
xsi:schemaLocation="urn:infinispan:config:14.0 https://infinispan.org/schemas/infinispan-config-fragment-14.0.xsd urn:infinispan:server:14.0 https://infinispan.org/schemas/infinispan-server-14.0.xsd"
xmlns="urn:infinispan:config:14.0"
name="default" statistics="true"
xmlns:server="urn:infinispan:server:14.0">
<transport cluster="${infinispan.cluster.name:cluster}" stack="${infinispan.cluster.stack}" server:security-realm="cluster-transport"/>
<serialization>
<allow-list>
<regex>.*</regex>
</allow-list>
</serialization>
<metrics gauges="true" histograms="true" accurate-size="true"/>
<locks:clustered-locks num-owners="-1"/>
</cache-container>
@@ -0,0 +1,24 @@
<security xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:server:14.0 https://infinispan.org/schemas/infinispan-server-14.0.xsd"
xmlns="urn:infinispan:server:14.0">
<security-realms>
<security-realm name="default">
<properties-realm groups-attribute="Roles">
<user-properties path="users.properties" relative-to="infinispan.server.config.path" plain-text="true"/>
<group-properties path="groups.properties" relative-to="infinispan.server.config.path"/>
</properties-realm>
</security-realm>
<security-realm name="cluster-transport">
<server-identities>
<ssl>
<keystore path="server.pfx"
password="secret"
alias="server"/>
<truststore path="server.pfx"
password="secret"/>

</ssl>
</server-identities>
</security-realm>
</security-realms>
</security>