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

Use certificate-generator for gRPC integration tests #6167

Merged
merged 1 commit into from
Jun 10, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions integration-tests/grpc/README.adoc

This file was deleted.

5 changes: 5 additions & 0 deletions integration-tests/grpc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-grpc</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests-support-certificate-generator</artifactId>
<scope>test</scope>
</dependency>

<!-- test dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void configure() throws Exception {

// Verifies that the serviceAccountResource can be loaded on startup
from("direct:googleAuthenticationType")
.toF("grpc://localhost:{{camel.grpc.test.async.server.port}}/%s?method=pingAsyncAsync&negotiationType=TLS&keyResource=certs/server.key&authenticationType=GOOGLE&serviceAccountResource=keys/app.json&KeyCertChainResource=certs/server.pem",
.toF("grpc://localhost:{{camel.grpc.test.async.server.port}}/%s?method=pingAsyncAsync&negotiationType=TLS&keyResource=certs/grpc.key&authenticationType=GOOGLE&serviceAccountResource=keys/app.json&KeyCertChainResource=certs/grpc.pem",
PING_PONG_SERVICE);

// Streaming producer strategy
Expand Down Expand Up @@ -111,8 +111,9 @@ public void configure() throws Exception {
// TLS secured consumer
fromF("grpc://localhost:{{camel.grpc.test.tls.server.port}}"
+ "/%s?consumerStrategy=PROPAGATION&"
+ "negotiationType=TLS&keyCertChainResource=certs/server.pem&"
+ "keyResource=certs/server.key&trustCertCollectionResource=certs/ca.pem", PING_PONG_SERVICE)
+ "negotiationType=TLS&keyCertChainResource=file:target/certs/grpc.crt&"
+ "keyResource=file:target/certs/grpc.key&trustCertCollectionResource=file:target/certs/grpc-ca.crt",
PING_PONG_SERVICE)
.process("messageOriginProcessor")
.choice()
.when(simple("${header.origin} == 'producer'"))
Expand All @@ -126,8 +127,9 @@ public void configure() throws Exception {
from("direct:sendTls")
.toF("grpc://localhost:{{camel.grpc.test.tls.server.port}}"
+ "/%s?method=pingSyncSync&synchronous=true&"
+ "negotiationType=TLS&keyCertChainResource=certs/client.pem&"
+ "keyResource=certs/client.key&trustCertCollectionResource=certs/ca.pem", PING_PONG_SERVICE);
+ "negotiationType=TLS&keyCertChainResource=file:target/certs/grpc.crt&"
+ "keyResource=file:target/certs/grpc.key&trustCertCollectionResource=file:target/certs/grpc-ca.crt",
PING_PONG_SERVICE);

// JWT secured consumer
fromF("grpc://localhost:{{camel.grpc.test.jwt.server.port}}"
Expand Down
18 changes: 0 additions & 18 deletions integration-tests/grpc/src/main/resources/certs/ca-openssl.conf

This file was deleted.

27 changes: 0 additions & 27 deletions integration-tests/grpc/src/main/resources/certs/ca.key

This file was deleted.

20 changes: 0 additions & 20 deletions integration-tests/grpc/src/main/resources/certs/ca.pem

This file was deleted.

28 changes: 0 additions & 28 deletions integration-tests/grpc/src/main/resources/certs/client.key

This file was deleted.

20 changes: 0 additions & 20 deletions integration-tests/grpc/src/main/resources/certs/client.pem

This file was deleted.

28 changes: 0 additions & 28 deletions integration-tests/grpc/src/main/resources/certs/server.key

This file was deleted.

20 changes: 0 additions & 20 deletions integration-tests/grpc/src/main/resources/certs/server.pem

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.camel.quarkus.component.grpc.it;

import java.io.FileInputStream;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CountDownLatch;
Expand All @@ -32,6 +33,8 @@
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import me.escoffier.certs.Format;
import me.escoffier.certs.junit5.Certificate;
import org.apache.camel.component.grpc.auth.jwt.JwtAlgorithm;
import org.apache.camel.component.grpc.auth.jwt.JwtCallCredentials;
import org.apache.camel.component.grpc.auth.jwt.JwtHelper;
Expand All @@ -40,6 +43,7 @@
import org.apache.camel.quarkus.component.grpc.it.model.PingPongGrpc.PingPongStub;
import org.apache.camel.quarkus.component.grpc.it.model.PingRequest;
import org.apache.camel.quarkus.component.grpc.it.model.PongResponse;
import org.apache.camel.quarkus.test.support.certificate.TestCertificates;
import org.apache.camel.util.StringHelper;
import org.awaitility.Awaitility;
import org.eclipse.microprofile.config.Config;
Expand All @@ -66,6 +70,9 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

@TestCertificates(certificates = {
@Certificate(name = "grpc", formats = { Format.PEM })
}, baseDir = "target/certs")
@QuarkusTest
@QuarkusTestResource(GrpcServerTestResource.class)
class GrpcTest {
Expand Down Expand Up @@ -256,15 +263,13 @@ public void tlsConsumer() throws Exception {
Config config = ConfigProvider.getConfig();
Integer port = config.getValue("camel.grpc.test.tls.server.port", Integer.class);

ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

ManagedChannel channel = null;
try {
channel = NettyChannelBuilder.forAddress("localhost", port)
.sslContext(GrpcSslContexts.forClient()
.keyManager(classLoader.getResourceAsStream("certs/client.pem"),
classLoader.getResourceAsStream("certs/client.key"))
.trustManager(classLoader.getResourceAsStream("certs/ca.pem"))
.keyManager(new FileInputStream("target/certs/grpc.crt"),
new FileInputStream("target/certs/grpc.key"))
.trustManager(new FileInputStream("target/certs/grpc-ca.crt"))
.build())
.build();

Expand Down
Loading