Skip to content

Commit f476283

Browse files
committed
feat: use MessageToJson for google-auth test payload
1 parent 449f2e6 commit f476283

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,35 +57,37 @@ def test_pqc_negotiated_group(run_pqc_test, request, transport_fixture):
5757
def test_google_auth_transport_pqc(run_pqc_test):
5858
"""Verifies that the google-auth HTTP transport adapter negotiates PQC with the Showcase server."""
5959
import google.auth.transport.requests
60+
from google.protobuf.json_format import MessageToJson
6061
from conftest import HostNameIgnoringAdapter
6162

6263
# 1. Initialize a standard requests Session with mTLS certs
6364
session = requests.Session()
6465
cert_path = "/usr/local/google/home/omairn/git/googleapis/google-cloud-python-dev2/packages/gapic-generator/tests/cert/mtls.crt"
6566
key_path = "/usr/local/google/home/omairn/git/googleapis/google-cloud-python-dev2/packages/gapic-generator/tests/cert/mtls.key"
6667

67-
# Disable verification temporarily to isolate hostname/cert validation errors
68-
session.verify = False
68+
session.verify = cert_path
6969
session.cert = (cert_path, key_path)
7070

7171
# Bypass localhost hostname mismatch
7272
session.mount("https://", HostNameIgnoringAdapter())
7373

7474
# 2. Wrap it in google-auth's Transport Request adapter
75-
# This is the exact object google-auth uses to execute its own HTTP/REST requests.
7675
auth_transport = google.auth.transport.requests.Request(session=session)
7776

78-
# 3. Make secure call using the google-auth transport adapter
77+
# 3. Serialize the request body using the official protobuf JSON serializer
78+
req = showcase.EchoRequest(content="Verify google-auth transport PQC connection.")
79+
body = MessageToJson(req, including_default_value_fields=True).encode("utf-8")
80+
81+
# 4. Make secure call using the google-auth transport adapter
7982
url = "https://localhost:7469/v1beta1/echo:echo"
8083
method = "POST"
8184
headers = {"Content-Type": "application/json"}
82-
body = b'{"content": "Verify google-auth transport PQC connection."}'
8385

8486
# Execute the request through google-auth's transport layer
8587
response = auth_transport(url=url, method=method, body=body, headers=headers)
8688
assert response.status == 200
8789

88-
# 4. Extract TLS group from response headers returned by Showcase
90+
# 5. Extract TLS group from response headers returned by Showcase
8991
negotiated_group = response.headers.get("x-showcase-tls-group")
9092
supported_groups = response.headers.get("x-showcase-tls-client-supported-groups")
9193

0 commit comments

Comments
 (0)