-
Notifications
You must be signed in to change notification settings - Fork 1.7k
chore(generator): add post-quantum cryptography (PQC) integration tests #17586
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
Open
ohmayr
wants to merge
14
commits into
main
Choose a base branch
from
feat-pqc-verification
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+142
−15
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bdad053
feat: add post-quantum cryptography (PQC) integration tests and fixtures
ohmayr 6c043e6
update
ohmayr 449f2e6
debug: disable verification in google-auth test
ohmayr f476283
feat: use MessageToJson for google-auth test payload
ohmayr 2d0fe09
wip
ohmayr 30c6ecc
update tests
ohmayr 4e3be17
cleanup
ohmayr 03ac316
address feedback
ohmayr ee8b1c8
update tests
ohmayr 2620f09
update tests
ohmayr 63f33f2
link bugs
ohmayr 7b52775
address feedback
ohmayr 7283c3b
cleanup
ohmayr a3d4c58
remove Kyber
ohmayr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import grpc | ||
| from packaging.version import Version | ||
| import pytest | ||
| from google import showcase | ||
|
|
||
|
|
||
| @pytest.fixture(autouse=True) | ||
| def require_tls(use_tls): | ||
| if not use_tls: | ||
| pytest.skip("PQC integration test requires standard TLS (--tls flag) to be enabled.") | ||
|
|
||
|
|
||
| def _verify_pqc_metadata(interceptor, transport_name): | ||
| """Extracts and verifies negotiated PQC group and supported groups from interceptor metadata.""" | ||
| response_metadata = getattr(interceptor, "response_metadata", []) or [] | ||
| headers = {key.lower(): value for key, value in response_metadata} | ||
| negotiated_group = headers.get("x-showcase-tls-group") | ||
| supported_groups = headers.get("x-showcase-tls-client-supported-groups") | ||
|
|
||
| assert negotiated_group is not None, "Failed: Showcase server did not return negotiated TLS group header." | ||
| assert supported_groups is not None, "Failed: Showcase server did not return client advertised supported groups." | ||
|
|
||
| # Enforce PQC compliance (X25519MLKEM768) | ||
| assert ( | ||
| "MLKEM" in negotiated_group | ||
| ), f"Failed: {transport_name} Connection did not negotiate X25519MLKEM768! Negotiated: {negotiated_group}" | ||
|
|
||
|
|
||
| def test_pqc_grpc(intercepted_echo_grpc): | ||
| """Verifies that the gRPC client library negotiates PQC (X25519MLKEM768) with Showcase server.""" | ||
| # TODO(https://github.com/googleapis/google-cloud-python/issues/17752): | ||
| # Remove this check once grpcio >= 1.83.0 is enforced across all client libraries. | ||
| if Version(grpc.__version__) < Version("1.83.0rc0"): | ||
| # TODO(https://github.com/googleapis/google-cloud-python/issues/17751): | ||
| # Update the version in the check above to `1.83.0` once released. | ||
| pytest.skip(f"gRPC PQC negotiation requires grpcio >= 1.83.0 (current: {grpc.__version__})") | ||
|
|
||
| client, interceptor = intercepted_echo_grpc | ||
| response = client.echo(request=showcase.EchoRequest(content="Verify PQC connection.")) | ||
| assert response.content == "Verify PQC connection." | ||
| _verify_pqc_metadata(interceptor, "grpc") | ||
|
|
||
|
|
||
| def test_pqc_rest(intercepted_echo_rest): | ||
| """Verifies that the REST client library negotiates PQC (X25519MLKEM768) with Showcase server.""" | ||
| client, interceptor = intercepted_echo_rest | ||
| response = client.echo(request=showcase.EchoRequest(content="Verify PQC connection.")) | ||
| assert response.content == "Verify PQC connection." | ||
| _verify_pqc_metadata(interceptor, "rest") | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_pqc_grpc_async(intercepted_echo_grpc_async): | ||
| """Verifies that the async gRPC client library negotiates PQC (X25519MLKEM768) with Showcase server.""" | ||
| # TODO(https://github.com/googleapis/google-cloud-python/issues/17752): | ||
| # Remove this check once grpcio >= 1.83.0 is enforced across all client libraries. | ||
| if Version(grpc.__version__) < Version("1.83.0rc0"): | ||
| # TODO(https://github.com/googleapis/google-cloud-python/issues/17751): | ||
| # Update the version in the check above to `1.83.0` once released. | ||
| pytest.skip( | ||
| f"gRPC PQC negotiation requires grpcio >= 1.83.0 (current: {grpc.__version__})" | ||
| ) | ||
|
|
||
| client, interceptor = intercepted_echo_grpc_async | ||
| response = await client.echo( | ||
| request=showcase.EchoRequest(content="Verify PQC connection.") | ||
| ) | ||
| assert response.content == "Verify PQC connection." | ||
| _verify_pqc_metadata(interceptor, "grpc_asyncio") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.