From 3ffc34b1573224779f94c9dd30f274da66706a7b Mon Sep 17 00:00:00 2001 From: Huabing Zhao Date: Fri, 3 Jan 2025 05:32:48 +0000 Subject: [PATCH] add test Signed-off-by: Huabing Zhao --- examples/http-ext-auth/http-ext-auth.js | 2 +- ...ecuritypolicy-with-extauth-backend.in.yaml | 12 ++++++-- ...curitypolicy-with-extauth-backend.out.yaml | 29 +++++++++++++++---- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/examples/http-ext-auth/http-ext-auth.js b/examples/http-ext-auth/http-ext-auth.js index 17ece9218222..626694518d91 100644 --- a/examples/http-ext-auth/http-ext-auth.js +++ b/examples/http-ext-auth/http-ext-auth.js @@ -35,4 +35,4 @@ console.log(`starting HTTP server on: ${port}`); function checkToken(token) { return tokens[token]; -} \ No newline at end of file +} diff --git a/internal/gatewayapi/testdata/securitypolicy-with-extauth-backend.in.yaml b/internal/gatewayapi/testdata/securitypolicy-with-extauth-backend.in.yaml index 5d756b3b981b..11715e27e719 100644 --- a/internal/gatewayapi/testdata/securitypolicy-with-extauth-backend.in.yaml +++ b/internal/gatewayapi/testdata/securitypolicy-with-extauth-backend.in.yaml @@ -107,6 +107,15 @@ backends: - fqdn: hostname: 'primary.foo.com' port: 3000 + - apiVersion: gateway.envoyproxy.io/v1alpha1 + kind: Backend + metadata: + name: backend-uds + namespace: default + spec: + endpoints: + - unix: + path: '/var/run/uds.sock' referenceGrants: - apiVersion: gateway.networking.k8s.io/v1alpha2 kind: ReferenceGrant @@ -179,7 +188,6 @@ securityPolicies: extAuth: http: backendRef: - name: backend-fqdn + name: backend-uds kind: Backend group: gateway.envoyproxy.io - port: 3000 diff --git a/internal/gatewayapi/testdata/securitypolicy-with-extauth-backend.out.yaml b/internal/gatewayapi/testdata/securitypolicy-with-extauth-backend.out.yaml index d5326219c97f..34eff3c3cc5a 100644 --- a/internal/gatewayapi/testdata/securitypolicy-with-extauth-backend.out.yaml +++ b/internal/gatewayapi/testdata/securitypolicy-with-extauth-backend.out.yaml @@ -17,6 +17,23 @@ backends: reason: Accepted status: "True" type: Accepted +- apiVersion: gateway.envoyproxy.io/v1alpha1 + kind: Backend + metadata: + creationTimestamp: null + name: backend-uds + namespace: default + spec: + endpoints: + - unix: + path: /var/run/uds.sock + status: + conditions: + - lastTransitionTime: null + message: The Backend was accepted + reason: Accepted + status: "True" + type: Accepted gateways: - apiVersion: gateway.networking.k8s.io/v1 kind: Gateway @@ -322,8 +339,7 @@ securityPolicies: backendRef: group: gateway.envoyproxy.io kind: Backend - name: backend-fqdn - port: 3000 + name: backend-uds targetRef: group: gateway.networking.k8s.io kind: HTTPRoute @@ -526,14 +542,15 @@ xdsIR: security: extAuth: http: - authority: primary.foo.com:3000 + authority: backend-uds.default destination: name: securitypolicy/default/policy-for-http-route-3-http-backendref/extauth/0 settings: - - addressType: FQDN + - addressType: IP endpoints: - - host: primary.foo.com - port: 3000 + - host: "" + path: /var/run/uds.sock + port: 0 protocol: HTTP weight: 1 path: ""