Skip to content

Commit

Permalink
Migrate gRPC same server TLS test to new API
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvavrik committed Sep 5, 2024
1 parent c049576 commit bcc3d14
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 130 deletions.
14 changes: 7 additions & 7 deletions http/grpc/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ quarkus.grpc.server.enable-reflection-service=true
quarkus.grpc.clients.reflection-service.port=${quarkus.grpc.clients.plain.port}
quarkus.grpc.clients.streaming.port=${quarkus.grpc.clients.plain.port}

%ssl.quarkus.grpc.clients.plain.ssl.trust-store=tls/ca.pem
%ssl.quarkus.grpc.clients.reflection-service.ssl.trust-store=${quarkus.grpc.clients.plain.ssl.trust-store}
%ssl.quarkus.grpc.clients.streaming.ssl.trust-store=${quarkus.grpc.clients.plain.ssl.trust-store}
%ssl.quarkus.grpc.clients.plain.ssl.trust-store=${grpc.client.ca-cert}
%ssl.quarkus.grpc.clients.reflection-service.ssl.trust-store=${grpc.client.ca-cert}
%ssl.quarkus.grpc.clients.streaming.ssl.trust-store=${grpc.client.ca-cert}

# See https://github.com/quarkusio/quarkus/issues/38965 to learn, why we use these parameters
%ssl.quarkus.grpc.clients.plain.port=${quarkus.http.ssl-port}
%ssl.quarkus.http.ssl.certificate.files=tls/server.pem
%ssl.quarkus.http.ssl.certificate.key-files=tls/server.key
%ssl.quarkus.grpc.server.ssl.certificate=tls/server.pem
%ssl.quarkus.grpc.server.ssl.key=tls/server.key
%ssl.quarkus.http.ssl.certificate.files=${grpc.server.cert}
%ssl.quarkus.http.ssl.certificate.key-files=${grpc.server.key}
%ssl.quarkus.grpc.server.ssl.certificate=${grpc.server.cert}
%ssl.quarkus.grpc.server.ssl.key=${grpc.server.key}
6 changes: 0 additions & 6 deletions http/grpc/src/main/resources/tls/ca.cnf

This file was deleted.

21 changes: 0 additions & 21 deletions http/grpc/src/main/resources/tls/ca.pem

This file was deleted.

28 changes: 0 additions & 28 deletions http/grpc/src/main/resources/tls/server.key

This file was deleted.

20 changes: 0 additions & 20 deletions http/grpc/src/main/resources/tls/server.pem

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package io.quarkus.ts.http.grpc;

import static io.quarkus.test.services.Certificate.Format.PEM;

import io.quarkus.test.bootstrap.CloseableManagedChannel;
import io.quarkus.test.bootstrap.GrpcService;
import io.quarkus.test.bootstrap.RestService;
import io.quarkus.test.scenarios.QuarkusScenario;
import io.quarkus.test.security.certificate.Certificate.PemCertificate;
import io.quarkus.test.security.certificate.CertificateBuilder;
import io.quarkus.test.services.Certificate;
import io.quarkus.test.services.QuarkusApplication;
import io.restassured.specification.RequestSpecification;

@QuarkusScenario
public class GrpcTlsSeparateServerIT implements GRPCIT, StreamingHttpIT, ReflectionHttpIT {

private static final String CERT_PREFIX = "grpc-tls-separate-server";

@QuarkusApplication(grpc = true, ssl = true, certificates = @Certificate(prefix = CERT_PREFIX, format = PEM, configureKeystore = true, configureTruststore = true))
static final GrpcService app = (GrpcService) new GrpcService()
.withProperty("quarkus.profile", "ssl")
.withProperty("grpc.client.ca-cert", CertificateBuilder.INSTANCE_KEY, GrpcTlsSeparateServerIT::getClientCaCert)
.withProperty("grpc.server.cert", CertificateBuilder.INSTANCE_KEY, GrpcTlsSeparateServerIT::getServerCert)
.withProperty("grpc.server.key", CertificateBuilder.INSTANCE_KEY, GrpcTlsSeparateServerIT::getServerKey);

public CloseableManagedChannel getChannel() {
return app.securedGrpcChannel();
}

@Override
public RestService app() {
return app;
}

@Override
public RequestSpecification given() {
return app().relaxedHttps().given();
}

private static String getClientCaCert(CertificateBuilder certificateBuilder) {
return getPemCertificate(certificateBuilder).truststorePath();
}

private static String getServerCert(CertificateBuilder certificateBuilder) {
return getPemCertificate(certificateBuilder).certPath();
}

private static String getServerKey(CertificateBuilder certificateBuilder) {
return getPemCertificate(certificateBuilder).keyPath();
}

private static PemCertificate getPemCertificate(CertificateBuilder certificateBuilder) {
return (PemCertificate) certificateBuilder.findCertificateByPrefix(CERT_PREFIX);
}
}
48 changes: 0 additions & 48 deletions http/grpc/src/test/java/io/quarkus/ts/http/grpc/TLSIT.java

This file was deleted.

0 comments on commit bcc3d14

Please sign in to comment.