Skip to content

Commit 6c043e6

Browse files
committed
update
1 parent bdad053 commit 6c043e6

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

packages/gapic-generator/noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def showcase_mtls(
457457
"""Run the Showcase mtls test suite."""
458458

459459
with showcase_library(session, templates=templates, other_opts=other_opts):
460-
session.install("pytest", "pytest-asyncio")
460+
session.install("pytest", "pytest-asyncio", "pyopenssl")
461461
test_directory = Path("tests", "system")
462462
ignore_file = env.get("IGNORE_FILE")
463463
pytest_command = [

packages/gapic-generator/tests/system/test_pqc.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import os
1516
import pytest
17+
import requests
1618
from google import showcase
1719

1820
@pytest.fixture
@@ -50,3 +52,46 @@ def test_pqc_negotiated_group(run_pqc_test, request, transport_fixture):
5052
# Enforce PQC compliance (this will fail if not using MLKEM/Kyber)
5153
assert "MLKEM" in negotiated_group or "Kyber" in negotiated_group, \
5254
f"Failed: {transport_fixture} Connection is NOT PQC-compliant! Negotiated: {negotiated_group}"
55+
56+
57+
def test_google_auth_transport_pqc(run_pqc_test):
58+
"""Verifies that the google-auth HTTP transport adapter negotiates PQC with the Showcase server."""
59+
import google.auth.transport.requests
60+
from conftest import HostNameIgnoringAdapter
61+
62+
# 1. Initialize a standard requests Session with mTLS certs
63+
session = requests.Session()
64+
cert_path = "/usr/local/google/home/omairn/git/googleapis/google-cloud-python-dev2/packages/gapic-generator/tests/cert/mtls.crt"
65+
key_path = "/usr/local/google/home/omairn/git/googleapis/google-cloud-python-dev2/packages/gapic-generator/tests/cert/mtls.key"
66+
67+
session.verify = cert_path
68+
session.cert = (cert_path, key_path)
69+
70+
# Bypass localhost hostname mismatch
71+
session.mount("https://", HostNameIgnoringAdapter())
72+
73+
# 2. Wrap it in google-auth's Transport Request adapter
74+
# This is the exact object google-auth uses to execute its own HTTP/REST requests.
75+
auth_transport = google.auth.transport.requests.Request(session=session)
76+
77+
# 3. Make secure call using the google-auth transport adapter
78+
url = "https://localhost:7469/v1beta1/echo:echo"
79+
method = "POST"
80+
headers = {"Content-Type": "application/json"}
81+
body = b'{"content": "Verify google-auth transport PQC connection."}'
82+
83+
# Execute the request through google-auth's transport layer
84+
response = auth_transport(url=url, method=method, body=body, headers=headers)
85+
assert response.status == 200
86+
87+
# 4. Extract TLS group from response headers returned by Showcase
88+
negotiated_group = response.headers.get("x-showcase-tls-group")
89+
supported_groups = response.headers.get("x-showcase-tls-client-supported-groups")
90+
91+
assert negotiated_group is not None, "Failed: Showcase server did not return negotiated TLS group header."
92+
print(f"\n[google-auth Transport PQC] Negotiated TLS Group: {negotiated_group}")
93+
print(f"[google-auth Transport PQC] Client Advertised Supported Groups: {supported_groups}")
94+
95+
# Assert PQC compliance
96+
assert "MLKEM" in negotiated_group or "Kyber" in negotiated_group, \
97+
f"Failed: google-auth Transport is NOT PQC-compliant! Negotiated: {negotiated_group}"

0 commit comments

Comments
 (0)