Skip to content

Commit c38cdac

Browse files
committed
test(showcase): update integration tests to use Showcase Auto-TLS mode
TAG=agy CONV=385b9ab5-874c-4c9a-b331-66dab51fef61
1 parent afc05d1 commit c38cdac

3 files changed

Lines changed: 46 additions & 19 deletions

File tree

build-with-local-http-client.sh

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,40 @@ else
5656
popd
5757
fi
5858

59+
SHOWCASE_DIR="${SHOWCASE_DIR:-${PARENT_DIR}/gapic-showcase}"
60+
SHOWCASE_BIN="${SHOWCASE_DIR}/gapic-showcase"
61+
62+
if [ -f "${SHOWCASE_BIN}" ]; then
63+
echo "========================================================================="
64+
echo "Starting Showcase TLS server in background..."
65+
echo "========================================================================="
66+
67+
# Ensure the target directory exists for writing the CA certificate
68+
mkdir -p java-showcase/gapic-showcase/target
69+
70+
# Start showcase in Auto-TLS mode on port 7470
71+
"${SHOWCASE_BIN}" run \
72+
--port 7470 \
73+
--tls \
74+
--ca-cert-output-file java-showcase/gapic-showcase/target/showcase-ca.pem > showcase-server.log 2>&1 &
75+
SHOWCASE_PID=$!
76+
77+
# Ensure we kill the background process on script exit
78+
trap "echo 'Stopping Showcase...'; kill ${SHOWCASE_PID} 2>/dev/null || true; wait ${SHOWCASE_PID} 2>/dev/null || true" EXIT
79+
80+
# Wait a bit for the server to initialize and write the cert
81+
sleep 2
82+
else
83+
echo "========================================================================="
84+
echo "Warning: gapic-showcase binary not found at: ${SHOWCASE_BIN}"
85+
echo "Please ensure Showcase is running manually in TLS mode on port 7470,"
86+
echo "and its CA certificate is written to java-showcase/gapic-showcase/target/showcase-ca.pem."
87+
echo "========================================================================="
88+
fi
89+
5990
echo "========================================================================="
6091
echo "Building and verifying gapic-showcase with PQC in google-cloud-java..."
6192
echo "========================================================================="
6293

63-
# Run the showcase tests
64-
mvn test -pl java-showcase/gapic-showcase -Dtest=ITPqc
94+
# Run the showcase tests using the secure endpoint
95+
mvn test -pl java-showcase/gapic-showcase -Dtest=ITPqc -Dshowcase.secure.endpoint=localhost:7470

java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITPqc.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020
import static com.google.common.truth.Truth.assertWithMessage;
21-
import static com.google.showcase.v1beta1.it.util.TestClientInitializer.DEFAULT_GRPC_ENDPOINT;
22-
import static com.google.showcase.v1beta1.it.util.TestClientInitializer.DEFAULT_HTTPJSON_ENDPOINT;
2321

2422
import com.google.api.client.http.javanet.NetHttpTransport;
2523
import com.google.api.gax.core.NoCredentialsProvider;
@@ -117,6 +115,9 @@ public class ITPqc {
117115

118116
private static final String DEFAULT_CA_CERT_PATH = "target/showcase-ca.pem";
119117

118+
private static final String SECURE_ENDPOINT =
119+
System.getProperty("showcase.secure.endpoint", "localhost:7470");
120+
120121
@BeforeAll
121122
static void setUp() {
122123
File certFile = new File(DEFAULT_CA_CERT_PATH);
@@ -132,7 +133,7 @@ void testGrpcPqc() throws Exception {
132133
ChannelCredentials creds =
133134
TlsChannelCredentials.newBuilder().trustManager(new File(DEFAULT_CA_CERT_PATH)).build();
134135

135-
ManagedChannel channel = Grpc.newChannelBuilder(DEFAULT_GRPC_ENDPOINT, creds).build();
136+
ManagedChannel channel = Grpc.newChannelBuilder(SECURE_ENDPOINT, creds).build();
136137
try {
137138
TransportChannel transportChannel = GrpcTransportChannel.create(channel);
138139

@@ -195,7 +196,7 @@ void testHttpJsonPqc() throws Exception {
195196
InstantiatingHttpJsonChannelProvider transportChannelProvider =
196197
EchoSettings.defaultHttpJsonTransportProviderBuilder()
197198
.setHttpTransport(transport)
198-
.setEndpoint(DEFAULT_HTTPJSON_ENDPOINT.replace("http://", "https://"))
199+
.setEndpoint("https://" + SECURE_ENDPOINT)
199200
.setInterceptorProvider(() -> Collections.singletonList(interceptor))
200201
.build();
201202

@@ -250,7 +251,7 @@ void testHttpJsonPqc_withExplicitSecurityProvider() throws Exception {
250251
InstantiatingHttpJsonChannelProvider transportChannelProvider =
251252
EchoSettings.defaultHttpJsonTransportProviderBuilder()
252253
.setHttpTransport(transport)
253-
.setEndpoint(DEFAULT_HTTPJSON_ENDPOINT.replace("http://", "https://"))
254+
.setEndpoint("https://" + SECURE_ENDPOINT)
254255
.setInterceptorProvider(() -> Collections.singletonList(interceptor))
255256
.build();
256257

pqc-verification/README.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,19 @@ git checkout feat-pqc-tls
3030
go build ./cmd/gapic-showcase
3131
```
3232

33-
### Step 2.2: Generate TLS Certificates
34-
Generate self-signed testing certificates using `openssl` (saved to `~/pqc-certs`):
35-
```shell
36-
mkdir -p ~/pqc-certs
37-
openssl req -x509 -newkey rsa:4096 -keyout ~/pqc-certs/server.key -out ~/pqc-certs/server.crt -sha256 -days 365 -nodes -subj "/CN=localhost"
38-
openssl x509 -outform pem -in ~/pqc-certs/server.crt -out ~/pqc-certs/ca.crt
39-
```
33+
### Step 2.2: Run the Showcase Server with Auto-TLS (Recommended)
34+
Start the Showcase server in Auto-TLS mode. This automatically generates a CA certificate in-memory at startup and saves it to the target directory:
4035

41-
### Step 2.3: Run the Showcase Server
42-
Start the Showcase server in TLS mode using the generated certificate:
4336
```shell
4437
# Run on secure port 7470
4538
./gapic-showcase run \
46-
--tls-cert ~/pqc-certs/server.crt \
47-
--tls-key ~/pqc-certs/server.key \
48-
--port 7470
39+
--port 7470 \
40+
--tls \
41+
--ca-cert-output-file ../google-cloud-java/java-showcase/gapic-showcase/target/showcase-ca.pem
4942
```
5043

44+
*Note: The helper script `build-with-local-http-client.sh` will automatically launch and clean up this Showcase server if it finds the `gapic-showcase` repository cloned next to the `google-cloud-java` monorepo.*
45+
5146
---
5247

5348
## 3. Running Local Verification Tests

0 commit comments

Comments
 (0)