From 75e44b96d57874593a5a4e9fa41901abddc24a14 Mon Sep 17 00:00:00 2001 From: hectorhammett Date: Wed, 24 Jun 2026 21:47:09 +0000 Subject: [PATCH] Add the PQC conformance tests --- .../conformance-tests-gax-showcase.yaml | 19 ++-- Gax/tests/Conformance/PqcShowcaseTest.php | 100 ++++++++++++++++++ 2 files changed, 113 insertions(+), 6 deletions(-) create mode 100644 Gax/tests/Conformance/PqcShowcaseTest.php diff --git a/.github/workflows/conformance-tests-gax-showcase.yaml b/.github/workflows/conformance-tests-gax-showcase.yaml index 7962003b4d2e..1d20ae21ec7c 100644 --- a/.github/workflows/conformance-tests-gax-showcase.yaml +++ b/.github/workflows/conformance-tests-gax-showcase.yaml @@ -10,7 +10,7 @@ jobs: gapic-showcase: runs-on: ubuntu-latest env: - GAPIC_SHOWCASE_VERSION: 0.36.2 + GAPIC_SHOWCASE_VERSION: 0.40.0 OS: linux ARCH: amd64 name: GAPIC Showcase Conformance Tests @@ -21,13 +21,21 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.2' extensions: grpc - - name: Install and run GAPIC Showcase + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '>=1.26' + + - name: Install GAPIC Showcase from Branch run: | - curl -L https://github.com/googleapis/gapic-showcase/releases/download/v${GAPIC_SHOWCASE_VERSION}/gapic-showcase-${GAPIC_SHOWCASE_VERSION}-${OS}-${ARCH}.tar.gz | tar -zx - ./gapic-showcase run & + go install github.com/googleapis/gapic-showcase@feat-pqc-tls + + - name: Run the GAPIC showcase server + run: | + gapic-showcase run --port :7469 --tls --ca-cert-output-file showcase.pem & sleep 5 - name: Install dependencies run: | @@ -35,4 +43,3 @@ jobs: - name: Run PHPUnit run: Gax/vendor/bin/phpunit -c Gax/phpunit-conformance.xml.dist - diff --git a/Gax/tests/Conformance/PqcShowcaseTest.php b/Gax/tests/Conformance/PqcShowcaseTest.php new file mode 100644 index 000000000000..5de03615d09c --- /dev/null +++ b/Gax/tests/Conformance/PqcShowcaseTest.php @@ -0,0 +1,100 @@ +fail('Could not read showcase.pem'); + } + + $grpcTransport = GrpcTransport::build($host, [ + 'stubOpts' => [ + 'credentials' => ChannelCredentials::createSsl($pemContents) + ] + ]); + + // REST Configuration + $restConfigPath = __DIR__ . '/src/V1beta1/resources/echo_rest_client_config.php'; + + $requestBuilder = new RequestBuilder($host, $restConfigPath); + $guzzleClient = new Client([ + 'verify' => $pemPath + ]); + $httpHandler = HttpHandlerFactory::build($guzzleClient); + $restTransport = new RestTransport($requestBuilder, [$httpHandler, 'async']); + + return [[$grpcTransport], [$restTransport]]; + } + + /** @dataProvider provideTransport */ + public function testPqc(TransportInterface $transport): void + { + $expected = 'This is a test'; + $expectedGroup = 'X25519MLKEM768'; + $expectedVersion = 'TLS 1.3'; + $responseHeaders = null; + $metadataCallback = function (array $metadata) use (&$responseHeaders) { + $responseHeaders = $metadata; + }; + + $echoClient = new EchoClient([ + 'credentials' => new InsecureCredentialsWrapper(), + 'transport' => $transport + ]); + + $echoRequest = new EchoRequest(); + $echoRequest->setContent($expected); + $response = $echoClient->echo($echoRequest, [ + 'metadataCallback' => $metadataCallback + ]); + + $this->assertEquals($expected, $response->getContent()); + $this->assertNotNull($responseHeaders); + + /** @var array> $responseHeaders */ + $responseHeaders = array_change_key_case($responseHeaders, CASE_LOWER); + + $this->assertEquals($expectedVersion, $responseHeaders[self::TLS_VERSION][0]); + $this->assertEquals($expectedGroup, $responseHeaders[self::TLS_GROUP][0]); + } +}