Skip to content

Commit d26d929

Browse files
authored
impl(rest): use PQC algorithm when available (googleapis#16253)
1 parent 6fd3745 commit d26d929

27 files changed

Lines changed: 953 additions & 6 deletions

.bazelignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
build-out/
2-
ci/
2+
ci/bzlmod_tests/consumer-test
3+
ci/verify_current_targets
4+
ci/verify_deprecated_targets
35
cmake-out/
46
cmake-build-debug/
57
cmake-build-coverage/

ci/cloudbuild/builds/showcase.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2026 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -euo pipefail
18+
19+
source "$(dirname "$0")/../../lib/init.sh"
20+
source module ci/cloudbuild/builds/lib/bazel.sh
21+
source module ci/cloudbuild/builds/lib/cloudcxxrc.sh
22+
source module ci/lib/io.sh
23+
24+
export CC=clang
25+
export CXX=clang++
26+
27+
mapfile -t args < <(bazel::common_args)
28+
29+
io::log_h1 "Running Showcase PQC tests with Bazel"
30+
31+
# Ensure server and temporary files are cleaned up on script exit
32+
cleanup() {
33+
rm -f ci/showcase/BUILD.bazel
34+
if [[ -n "${showcase_pid:-}" ]]; then
35+
kill "${showcase_pid}" || true
36+
fi
37+
}
38+
trap cleanup EXIT
39+
40+
SHOWCASE_VERSION="${SHOWCASE_VERSION:-main}"
41+
SHOWCASE_DIR="ci/showcase/googleapis/gapic-showcase"
42+
if [[ ! -f "${SHOWCASE_DIR}/go.mod" ]]; then
43+
io::log_h2 "Downloading googleapis/gapic-showcase (${SHOWCASE_VERSION}) tarball into ${SHOWCASE_DIR}"
44+
mkdir -p "${SHOWCASE_DIR}"
45+
curl -fsSL "https://github.com/googleapis/gapic-showcase/archive/${SHOWCASE_VERSION}.tar.gz" |
46+
tar -C "${SHOWCASE_DIR}" -xzf - --strip-components=1
47+
fi
48+
49+
# Copy BUILD.bazel.in to BUILD.bazel. These shenanigans are necessary because
50+
# we want to test with packages that do not have public visibility and creating
51+
# a persistent BUILD.bazel file leads to errors when the files it refers to
52+
# are not there.
53+
cp ci/showcase/BUILD.bazel.in ci/showcase/BUILD.bazel
54+
55+
bazel_output_base="$(bazel info output_base)"
56+
protobuf_proto_path="${bazel_output_base}/external/protobuf+/src"
57+
googleapis_proto_path="${bazel_output_base}/external/googleapis+"
58+
59+
io::log_h2 "Running C++ codegen generator for gapic-showcase echo.proto"
60+
bazel run --action_env=GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes \
61+
//generator:google-cloud-cpp-codegen -- \
62+
--protobuf_proto_path="${protobuf_proto_path}" \
63+
--googleapis_proto_path="${googleapis_proto_path}" \
64+
--golden_proto_path="${PROJECT_ROOT}/${SHOWCASE_DIR}/schema" \
65+
--output_path="${PROJECT_ROOT}/ci/showcase" \
66+
--check_comment_substitutions=false \
67+
--config_file="${PROJECT_ROOT}/ci/showcase/showcase_config.textproto"
68+
69+
io::log_h2 "Building gapic-showcase server binary"
70+
mkdir -p "${PROJECT_ROOT}/ci/showcase/bin"
71+
(
72+
cd "${PROJECT_ROOT}/${SHOWCASE_DIR}"
73+
go build -o "${PROJECT_ROOT}/ci/showcase/bin/gapic-showcase" ./cmd/gapic-showcase
74+
)
75+
76+
SHOWCASE_PORT="${SHOWCASE_PORT:-7469}"
77+
SHOWCASE_CA_CERT="${PROJECT_ROOT}/ci/showcase/showcase.pem"
78+
rm -f "${SHOWCASE_CA_CERT}"
79+
80+
io::log_h2 "Starting gapic-showcase server on port ${SHOWCASE_PORT} with TLS"
81+
"${PROJECT_ROOT}/ci/showcase/bin/gapic-showcase" run \
82+
--port=":${SHOWCASE_PORT}" \
83+
--tls \
84+
--ca-cert-output-file="${SHOWCASE_CA_CERT}" >/dev/null 2>&1 &
85+
showcase_pid=$!
86+
87+
# Wait up to 15 seconds for CA cert file to be created and server to be listening
88+
for _ in $(seq 1 30); do
89+
if [[ -r "${SHOWCASE_CA_CERT}" ]] && curl --insecure -s "https://localhost:${SHOWCASE_PORT}" >/dev/null 2>&1; then
90+
break
91+
fi
92+
sleep 0.5
93+
done
94+
95+
io::log_h2 "Running showcase tests"
96+
bazel test --test_env=SHOWCASE_PORT="${SHOWCASE_PORT}" \
97+
--test_env=SHOWCASE_CA_CERT="${SHOWCASE_CA_CERT}" \
98+
--test_output=errors \
99+
//ci/showcase:rest_pqc_test
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
filename: ci/cloudbuild/cloudbuild.yaml
16+
github:
17+
name: google-cloud-cpp
18+
owner: googleapis
19+
push:
20+
branch: main
21+
includeBuildLogs: INCLUDE_BUILD_LOGS_WITH_STATUS
22+
name: showcase-ci
23+
substitutions:
24+
_BUILD_NAME: showcase
25+
_DISTRO: fedora-latest-bazel
26+
_TRIGGER_TYPE: ci
27+
tags:
28+
- ci
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
filename: ci/cloudbuild/cloudbuild.yaml
16+
github:
17+
name: google-cloud-cpp
18+
owner: googleapis
19+
pullRequest:
20+
branch: main
21+
commentControl: COMMENTS_ENABLED_FOR_EXTERNAL_CONTRIBUTORS_ONLY
22+
includeBuildLogs: INCLUDE_BUILD_LOGS_WITH_STATUS
23+
name: showcase-pr
24+
substitutions:
25+
_BUILD_NAME: showcase
26+
_DISTRO: fedora-latest-bazel
27+
_TRIGGER_TYPE: pr
28+
tags:
29+
- pr

ci/showcase/.bazelignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bazel-*

ci/showcase/.bazelrc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Use host-OS-specific config lines from bazelrc files.
16+
build --enable_platform_specific_config=true
17+
18+
# The project requires C++ >= 17.
19+
build:linux --cxxopt=-std=c++17
20+
build:macos --cxxopt=-std=c++17
21+
# Protobuf and gRPC require C++17 to compile the "host"
22+
# targets, such as protoc and the grpc plugin.
23+
build:linux --host_cxxopt=-std=c++17
24+
build:macos --host_cxxopt=-std=c++17
25+
26+
# Do not create the convenience links. They are inconvenient when the build
27+
# runs inside a docker image or if one builds a quickstart and then builds
28+
# the project separately.
29+
build --experimental_convenience_symlinks=ignore
30+
31+
# TODO(#13311) - remove once gRPC works with Bazel v7 or when gRPC stops using
32+
# `apple_rules`.
33+
common:macos --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1

ci/showcase/.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.7.0

ci/showcase/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Ignore downloaded gapic-showcase tarball contents when running locally.
2+
googleapis/gapic-showcase/
3+
# Ignore dynamically generated C++ library files when running locally.
4+
google/showcase/
5+
# Ignore compiled binaries and certificates when running locally.
6+
bin/
7+
showcase.pem

ci/showcase/BUILD.bazel.in

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
16+
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
17+
load("@grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
18+
19+
package(default_visibility = ["//visibility:private"])
20+
21+
licenses(["notice"])
22+
23+
proto_library(
24+
name = "showcase_echo_proto",
25+
srcs = ["googleapis/gapic-showcase/schema/google/showcase/v1beta1/echo.proto"],
26+
strip_import_prefix = "googleapis/gapic-showcase/schema",
27+
deps = [
28+
"@com_google_protobuf//:any_proto",
29+
"@com_google_protobuf//:duration_proto",
30+
"@com_google_protobuf//:timestamp_proto",
31+
"@googleapis//google/api:annotations_proto",
32+
"@googleapis//google/api:client_proto",
33+
"@googleapis//google/api:field_behavior_proto",
34+
"@googleapis//google/api:field_info_proto",
35+
"@googleapis//google/api:routing_proto",
36+
"@googleapis//google/longrunning:operations_proto",
37+
"@googleapis//google/rpc:status_proto",
38+
],
39+
)
40+
41+
cc_proto_library(
42+
name = "showcase_echo_cc_proto",
43+
deps = [":showcase_echo_proto"],
44+
)
45+
46+
cc_grpc_library(
47+
name = "showcase_echo_cc_grpc",
48+
srcs = [":showcase_echo_proto"],
49+
grpc_only = True,
50+
deps = [":showcase_echo_cc_proto"],
51+
)
52+
53+
filegroup(
54+
name = "echo_srcs",
55+
srcs = glob([
56+
"google/showcase/v1beta1/internal/*_sources.cc",
57+
]),
58+
)
59+
60+
filegroup(
61+
name = "echo_hdrs",
62+
srcs = glob(
63+
include = [
64+
"google/showcase/v1beta1/*.cc",
65+
"google/showcase/v1beta1/*.h",
66+
"google/showcase/v1beta1/internal/*.cc",
67+
"google/showcase/v1beta1/internal/*.h",
68+
],
69+
exclude = [
70+
"google/showcase/v1beta1/internal/*_sources.cc",
71+
],
72+
),
73+
)
74+
75+
cc_library(
76+
name = "showcase_echo_client",
77+
srcs = [":echo_srcs"],
78+
hdrs = [":echo_hdrs"],
79+
copts = [
80+
"-Ici/showcase",
81+
"-I$(BINDIR)/ci/showcase",
82+
],
83+
includes = ["."],
84+
strip_include_prefix = "",
85+
deps = [
86+
":showcase_echo_cc_grpc",
87+
":showcase_echo_cc_proto",
88+
"//:common",
89+
"//:grpc_utils",
90+
"//google/cloud:google_cloud_cpp_rest_internal",
91+
"//google/cloud:google_cloud_cpp_rest_protobuf_internal",
92+
"@abseil-cpp//absl/strings",
93+
"@googleapis//google/longrunning:longrunning_cc_grpc",
94+
],
95+
)
96+
97+
cc_test(
98+
name = "rest_pqc_test",
99+
srcs = ["rest_pqc_test.cc"],
100+
copts = [
101+
"-Ici/showcase",
102+
"-I$(BINDIR)/ci/showcase",
103+
],
104+
tags = ["integration-test"],
105+
deps = [
106+
":showcase_echo_client",
107+
"//:common",
108+
"//google/cloud:google_cloud_cpp_rest_internal",
109+
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
110+
"//google/cloud/testing_util:google_cloud_cpp_testing_rest_private",
111+
"@googletest//:gtest_main",
112+
],
113+
)

0 commit comments

Comments
 (0)