Skip to content
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

add gcpAuthzExtension CRD #201

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions authz-extension/cr-validation/backend_ref_invalid_group.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: networking.gke.io/v1
kind: GCPAuthzExtension
metadata:
name: "test"
spec:
backendRef:
group: "fake-group"
kind: Service
name: test-service
port: 80
authority: hello.com
11 changes: 11 additions & 0 deletions authz-extension/cr-validation/backend_ref_invalid_kind.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: networking.gke.io/v1
kind: GCPAuthzExtension
metadata:
name: "test"
spec:
backendRef:
group: ""
kind: Gateway
name: test-service
port: 80
authority: hello.com
14 changes: 14 additions & 0 deletions authz-extension/cr-validation/invalid_metadata_key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: networking.gke.io/v1
kind: GCPAuthzExtension
metadata:
name: "test"
spec:
backendRef:
group: ""
kind: Service
name: test-service
port: 80
authority: hello.com
timeout: 1s
metadata:
"???": "value"
14 changes: 14 additions & 0 deletions authz-extension/cr-validation/invalid_metadata_value.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: networking.gke.io/v1
kind: GCPAuthzExtension
metadata:
name: "test"
spec:
backendRef:
group: ""
kind: Service
name: test-service
port: 80
authority: hello.com
timeout: 1s
metadata:
"key": ""
11 changes: 11 additions & 0 deletions authz-extension/cr-validation/no_authority.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: networking.gke.io/v1
kind: GCPAuthzExtension
metadata:
name: "test"
spec:
backendRef:
group: ""
kind: Service
name: test-service
port: 80
timeout: 1s
11 changes: 11 additions & 0 deletions authz-extension/cr-validation/no_timeout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: networking.gke.io/v1
kind: GCPAuthzExtension
metadata:
name: "test"
spec:
backendRef:
group: ""
kind: Service
name: test-service
port: 80
authority: hello.com
52 changes: 52 additions & 0 deletions authz-extension/cr-validation/run-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

# Copyright 2024 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
#
# http://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.

set -o errexit;
set -o nounset;
set -o pipefail;
set -o xtrace;

check_cr_validation() {
path="$1"
fail="$2"
crd_path="./gateway-api/config/mesh/crd/experimental"
set +e
output=$(kubectl validate "${path}" --local-crds "${crd_path}" 2>&1)
set -e

# Check if the validation passed or failed
if [[ "$output" == *"OK"* && "$fail" == "false" ]]; then
echo "Validation passed."
return 0 # Test passes
elif [[ "$output" != *"OK"* && "$fail" == "true" ]]; then
echo "Validation failed as expected due to fail condition."
return 0 # Test passes because fail is true and we expect validation to fail
else
echo "Validation failed."
return 1 # Test fails
fi
}

check_cr_validation "./authz-extension/cr-validation/backend_ref_invalid_group.yaml" "true"
check_cr_validation "./authz-extension/cr-validation/backend_ref_invalid_kind.yaml" "true"
check_cr_validation "./authz-extension/cr-validation/invalid_metadata_key.yaml" "true"
check_cr_validation "./authz-extension/cr-validation/invalid_metadata_value.yaml" "true"
check_cr_validation "./authz-extension/cr-validation/no_authority.yaml" "true"
check_cr_validation "./authz-extension/cr-validation/no_timeout.yaml" "true"
check_cr_validation "./authz-extension/cr-validation/too_big_timeout.yaml" "true"
check_cr_validation "./authz-extension/cr-validation/too_small_timeout.yaml" "true"
check_cr_validation "./authz-extension/cr-validation/wrong_wire_format.yaml" "true"
check_cr_validation "./authz-extension/cr-validation/valid.yaml" "false"
12 changes: 12 additions & 0 deletions authz-extension/cr-validation/too_big_timeout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: networking.gke.io/v1
kind: GCPAuthzExtension
metadata:
name: "test"
spec:
backendRef:
group: ""
kind: Service
name: test-service
port: 80
authority: hello.com
timeout: 11s
12 changes: 12 additions & 0 deletions authz-extension/cr-validation/too_small_timeout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: networking.gke.io/v1
kind: GCPAuthzExtension
metadata:
name: "test"
spec:
backendRef:
group: ""
kind: Service
name: test-service
port: 80
authority: hello.com
timeout: 1ms
18 changes: 18 additions & 0 deletions authz-extension/cr-validation/valid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: networking.gke.io/v1
kind: GCPAuthzExtension
metadata:
name: "test"
spec:
backendRef:
group: ""
kind: Service
name: test-service
port: 80
authority: hello.com
timeout: 1s
failOpen: true
metadata:
"key": "value"
forwardHeaders:
- hello.com
wireFormat: ExtProcGRPC
13 changes: 13 additions & 0 deletions authz-extension/cr-validation/wrong_wire_format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: networking.gke.io/v1
kind: GCPAuthzExtension
metadata:
name: "test"
spec:
backendRef:
group: ""
kind: Service
name: test-service
port: 80
timeout: 1s
authority: hello.com
wireFormat: ExtProc
Loading
Loading