Skip to content

Commit d6c4f20

Browse files
committed
wip: add integration test for custom SSL via gRPCs
1 parent 74b40ae commit d6c4f20

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package io.weaviate.integration;
2+
3+
import java.io.IOException;
4+
import java.util.UUID;
5+
6+
import javax.net.ssl.TrustManagerFactory;
7+
8+
import org.assertj.core.api.Assertions;
9+
import org.junit.After;
10+
import org.junit.Before;
11+
import org.junit.Test;
12+
13+
import io.weaviate.ConcurrentTest;
14+
import io.weaviate.client6.v1.api.WeaviateClient;
15+
import io.weaviate.containers.Container;
16+
import io.weaviate.truststore.SingleTrustManagerFactory;
17+
import io.weaviate.truststore.SpyTrustManager;
18+
19+
public class DefaultGrpcTransportITest extends ConcurrentTest {
20+
private static final WeaviateClient _setupClient = Container.WEAVIATE.getClient();
21+
22+
private WeaviateClient client = Container.WEAVIATE.getClient();
23+
private TrustManagerFactory tmf;
24+
25+
@Before
26+
public void setUp() throws IOException {
27+
tmf = SingleTrustManagerFactory.create(new SpyTrustManager());
28+
client = WeaviateClient.custom(opt -> opt
29+
.scheme("https")
30+
.httpHost(Container.WEAVIATE.getHost())
31+
.grpcHost(Container.WEAVIATE.getHost())
32+
.httpPort(Container.WEAVIATE.getMappedPort(8080))
33+
.grpcPort(Container.WEAVIATE.getMappedPort(50051))
34+
.trustManagerFactory(tmf));
35+
}
36+
37+
@Test
38+
public void testCustomTrustStore_sync() throws IOException {
39+
// Arrange
40+
var nsThings = ns("Things");
41+
_setupClient.collections.create(nsThings);
42+
43+
client.collections.use(nsThings).query.byId(UUID.randomUUID().toString());
44+
45+
var spy = SpyTrustManager.getSpy(tmf);
46+
Assertions.assertThat(spy).get()
47+
.as("HttpClient uses custom TrustManager")
48+
.returns(true, SpyTrustManager::wasUsed);
49+
}
50+
51+
@After
52+
public void tearDown() throws IOException {
53+
client.close();
54+
}
55+
}

0 commit comments

Comments
 (0)