-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add match conditions errors chainsaw test
Signed-off-by: Charles-Edouard Brétéché <[email protected]>
- Loading branch information
1 parent
c5df7b5
commit 831d4eb
Showing
17 changed files
with
447 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...e2e/authz-server/match-conditions/failure-policy-fail/error-with-false/chainsaw-test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: error-with-false | ||
spec: | ||
namespace: app | ||
steps: | ||
- try: | ||
- create: | ||
file: ./istio-policy.yaml | ||
- create: | ||
file: ./policy.yaml | ||
- create: | ||
file: ./shell.yaml | ||
- wait: | ||
apiVersion: v1 | ||
kind: Pod | ||
timeout: 1m | ||
for: | ||
condition: | ||
name: Ready | ||
value: 'true' | ||
- script: | ||
content: > | ||
kubectl exec -n $NAMESPACE deploy/curl -- curl -s -w "\nhttp_code=%{http_code}" httpbin:8000/get | ||
check: | ||
(wildcard('*http_code=200', $stdout)): true | ||
finally: | ||
- sleep: | ||
duration: 10s |
14 changes: 14 additions & 0 deletions
14
.../e2e/authz-server/match-conditions/failure-policy-fail/error-with-false/istio-policy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: security.istio.io/v1 | ||
kind: AuthorizationPolicy | ||
metadata: | ||
name: policy | ||
namespace: istio-system | ||
spec: | ||
selector: | ||
matchLabels: | ||
ext-authz: enabled | ||
action: CUSTOM | ||
provider: | ||
name: kyverno-authz-server | ||
rules: | ||
- {} |
18 changes: 18 additions & 0 deletions
18
tests/e2e/authz-server/match-conditions/failure-policy-fail/error-with-false/policy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# yaml-language-server: $schema=../../../../../../.schemas/json/authorizationpolicy-envoy-v1alpha1.json | ||
apiVersion: envoy.kyverno.io/v1alpha1 | ||
kind: AuthorizationPolicy | ||
metadata: | ||
name: policy | ||
spec: | ||
failurePolicy: Fail | ||
matchConditions: | ||
- name: error | ||
expression: '(2 / 0) == 1' | ||
- name: 'false' | ||
expression: 'false' | ||
deny: | ||
- response: > | ||
envoy | ||
.Denied(403) | ||
.WithBody("Unauthorized Request") | ||
.Response() |
48 changes: 48 additions & 0 deletions
48
tests/e2e/authz-server/match-conditions/failure-policy-fail/error-with-false/shell.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: curl | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: curl | ||
labels: | ||
app: curl | ||
service: curl | ||
spec: | ||
ports: | ||
- port: 80 | ||
name: http | ||
selector: | ||
app: curl | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: curl | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: curl | ||
template: | ||
metadata: | ||
labels: | ||
app: curl | ||
spec: | ||
terminationGracePeriodSeconds: 0 | ||
serviceAccountName: curl | ||
containers: | ||
- name: curl | ||
image: curlimages/curl | ||
command: ["/bin/sleep", "infinity"] | ||
imagePullPolicy: IfNotPresent | ||
volumeMounts: | ||
- mountPath: /etc/curl/tls | ||
name: secret-volume | ||
volumes: | ||
- name: secret-volume | ||
secret: | ||
secretName: curl-secret | ||
optional: true |
30 changes: 30 additions & 0 deletions
30
.../e2e/authz-server/match-conditions/failure-policy-fail/error-with-true/chainsaw-test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: error-with-true | ||
spec: | ||
namespace: app | ||
steps: | ||
- try: | ||
- create: | ||
file: ./istio-policy.yaml | ||
- create: | ||
file: ./policy.yaml | ||
- create: | ||
file: ./shell.yaml | ||
- wait: | ||
apiVersion: v1 | ||
kind: Pod | ||
timeout: 1m | ||
for: | ||
condition: | ||
name: Ready | ||
value: 'true' | ||
- script: | ||
content: > | ||
kubectl exec -n $NAMESPACE deploy/curl -- curl -s -w "\nhttp_code=%{http_code}" httpbin:8000/get | ||
check: | ||
(wildcard('*http_code=403', $stdout)): true | ||
finally: | ||
- sleep: | ||
duration: 10s |
14 changes: 14 additions & 0 deletions
14
...s/e2e/authz-server/match-conditions/failure-policy-fail/error-with-true/istio-policy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: security.istio.io/v1 | ||
kind: AuthorizationPolicy | ||
metadata: | ||
name: policy | ||
namespace: istio-system | ||
spec: | ||
selector: | ||
matchLabels: | ||
ext-authz: enabled | ||
action: CUSTOM | ||
provider: | ||
name: kyverno-authz-server | ||
rules: | ||
- {} |
18 changes: 18 additions & 0 deletions
18
tests/e2e/authz-server/match-conditions/failure-policy-fail/error-with-true/policy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# yaml-language-server: $schema=../../../../../../.schemas/json/authorizationpolicy-envoy-v1alpha1.json | ||
apiVersion: envoy.kyverno.io/v1alpha1 | ||
kind: AuthorizationPolicy | ||
metadata: | ||
name: policy | ||
spec: | ||
failurePolicy: Fail | ||
matchConditions: | ||
- name: error | ||
expression: '(2 / 0) == 1' | ||
- name: 'true' | ||
expression: 'true' | ||
deny: | ||
- response: > | ||
envoy | ||
.Denied(403) | ||
.WithBody("Unauthorized Request") | ||
.Response() |
48 changes: 48 additions & 0 deletions
48
tests/e2e/authz-server/match-conditions/failure-policy-fail/error-with-true/shell.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: curl | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: curl | ||
labels: | ||
app: curl | ||
service: curl | ||
spec: | ||
ports: | ||
- port: 80 | ||
name: http | ||
selector: | ||
app: curl | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: curl | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: curl | ||
template: | ||
metadata: | ||
labels: | ||
app: curl | ||
spec: | ||
terminationGracePeriodSeconds: 0 | ||
serviceAccountName: curl | ||
containers: | ||
- name: curl | ||
image: curlimages/curl | ||
command: ["/bin/sleep", "infinity"] | ||
imagePullPolicy: IfNotPresent | ||
volumeMounts: | ||
- mountPath: /etc/curl/tls | ||
name: secret-volume | ||
volumes: | ||
- name: secret-volume | ||
secret: | ||
secretName: curl-secret | ||
optional: true |
30 changes: 30 additions & 0 deletions
30
...e/authz-server/match-conditions/failure-policy-ignore/error-with-false/chainsaw-test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: error-with-false | ||
spec: | ||
namespace: app | ||
steps: | ||
- try: | ||
- create: | ||
file: ./istio-policy.yaml | ||
- create: | ||
file: ./policy.yaml | ||
- create: | ||
file: ./shell.yaml | ||
- wait: | ||
apiVersion: v1 | ||
kind: Pod | ||
timeout: 1m | ||
for: | ||
condition: | ||
name: Ready | ||
value: 'true' | ||
- script: | ||
content: > | ||
kubectl exec -n $NAMESPACE deploy/curl -- curl -s -w "\nhttp_code=%{http_code}" httpbin:8000/get | ||
check: | ||
(wildcard('*http_code=200', $stdout)): true | ||
finally: | ||
- sleep: | ||
duration: 10s |
14 changes: 14 additions & 0 deletions
14
...2e/authz-server/match-conditions/failure-policy-ignore/error-with-false/istio-policy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: security.istio.io/v1 | ||
kind: AuthorizationPolicy | ||
metadata: | ||
name: policy | ||
namespace: istio-system | ||
spec: | ||
selector: | ||
matchLabels: | ||
ext-authz: enabled | ||
action: CUSTOM | ||
provider: | ||
name: kyverno-authz-server | ||
rules: | ||
- {} |
18 changes: 18 additions & 0 deletions
18
tests/e2e/authz-server/match-conditions/failure-policy-ignore/error-with-false/policy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# yaml-language-server: $schema=../../../../../../.schemas/json/authorizationpolicy-envoy-v1alpha1.json | ||
apiVersion: envoy.kyverno.io/v1alpha1 | ||
kind: AuthorizationPolicy | ||
metadata: | ||
name: policy | ||
spec: | ||
failurePolicy: Ignore | ||
matchConditions: | ||
- name: error | ||
expression: '(2 / 0) == 1' | ||
- name: 'false' | ||
expression: 'false' | ||
deny: | ||
- response: > | ||
envoy | ||
.Denied(403) | ||
.WithBody("Unauthorized Request") | ||
.Response() |
48 changes: 48 additions & 0 deletions
48
tests/e2e/authz-server/match-conditions/failure-policy-ignore/error-with-false/shell.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: curl | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: curl | ||
labels: | ||
app: curl | ||
service: curl | ||
spec: | ||
ports: | ||
- port: 80 | ||
name: http | ||
selector: | ||
app: curl | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: curl | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: curl | ||
template: | ||
metadata: | ||
labels: | ||
app: curl | ||
spec: | ||
terminationGracePeriodSeconds: 0 | ||
serviceAccountName: curl | ||
containers: | ||
- name: curl | ||
image: curlimages/curl | ||
command: ["/bin/sleep", "infinity"] | ||
imagePullPolicy: IfNotPresent | ||
volumeMounts: | ||
- mountPath: /etc/curl/tls | ||
name: secret-volume | ||
volumes: | ||
- name: secret-volume | ||
secret: | ||
secretName: curl-secret | ||
optional: true |
Oops, something went wrong.