mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-28 18:38:40 +00:00
add test case (currently fails)
This commit is contained in:
parent
d58113233c
commit
440c23f231
3 changed files with 37 additions and 0 deletions
|
@ -115,3 +115,7 @@ func Test_validate_disallow_host_filesystem_fail(t *testing.T) {
|
|||
func Test_validate_disallow_host_filesystem_pass(t *testing.T) {
|
||||
testScenario(t, "test/scenarios/samples/best_practices/scenario_validate_disallow_host_filesystem_pass.yaml")
|
||||
}
|
||||
|
||||
func Test_validate_disallow_new_capabilities(t *testing.T) {
|
||||
testScenario(t, "/test/scenarios/samples/best_practices/scenario_validate_disallow_new_capabilities.yaml")
|
||||
}
|
||||
|
|
15
test/resources/disallow_new_capabilities.yaml
Normal file
15
test/resources/disallow_new_capabilities.yaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: mypod
|
||||
spec:
|
||||
containers:
|
||||
- name: add-new-capabilities
|
||||
image: "ubuntu:18.04"
|
||||
command:
|
||||
- /bin/sleep
|
||||
- "300"
|
||||
securityContext:
|
||||
capabilities:
|
||||
add:
|
||||
- NET_ADMIN
|
|
@ -0,0 +1,18 @@
|
|||
# file path relative to project root
|
||||
input:
|
||||
policy: samples/best_practices/disallow_new_capabilities.yaml
|
||||
resource: test/resources/disallow_new_capabilities.yaml
|
||||
expected:
|
||||
validation:
|
||||
policyresponse:
|
||||
policy: validate-new-capabilities
|
||||
resource:
|
||||
kind: Pod
|
||||
apiVersion: v1
|
||||
namespace: ''
|
||||
name: "add-new-capabilities"
|
||||
rules:
|
||||
- name: deny-new-capabilities
|
||||
type: Validation
|
||||
message: Validation rule 'deny-new-capabilities' failed at '/spec/containers/securityContext/capabilities/add' for resource Pod//capabilities. Capabilities cannot be added
|
||||
success: false
|
Loading…
Add table
Reference in a new issue