Skip to content

Commit

Permalink
Merge pull request #206 from hubwoop/main
Browse files Browse the repository at this point in the history
adds tests for require_unique_uid_per_workload policy
  • Loading branch information
chipzoller authored Dec 20, 2021
2 parents 08c81d5 + 25f1018 commit fb012c7
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
25 changes: 25 additions & 0 deletions other/require_unique_uid_per_workload/resource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v1
kind: Pod
metadata:
labels:
app: server
name: already-taken-user
spec:
containers:
- image: nginxinc/nginx-unprivileged
name: already-taken-user
securityContext:
runAsUser: 1337
---
apiVersion: v1
kind: Pod
metadata:
labels:
app: server
name: free-user
spec:
containers:
- image: nginxinc/nginx-unprivileged
name: free-user
securityContext:
runAsUser: 42
17 changes: 17 additions & 0 deletions other/require_unique_uid_per_workload/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: require_unique_uid_per_workload
policies:
- require_unique_uid_per_workload.yaml
resources:
- resource.yaml
variables: variables.yaml
results:
- policy: require-unique-uid-per-workload
rule: require-unique-uid
resource: already-taken-user
kind: Pod
result: fail
- policy: require-unique-uid-per-workload
rule: require-unique-uid
resource: free-user
kind: Pod
result: pass
8 changes: 8 additions & 0 deletions other/require_unique_uid_per_workload/variables.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
globalValues:
request.operation: CREATE
policies:
- name: require-unique-uid-per-workload
rules:
- name: require-unique-uid
values:
uidsAllPodsExceptSameOwnerAsRequestObject: "[\"1337\"]"

0 comments on commit fb012c7

Please sign in to comment.