-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add missing fields to e2e fixtures
Signed-off-by: Flavio Castelli <[email protected]>
- Loading branch information
Showing
6 changed files
with
274 additions
and
218 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,83 @@ | ||
@test "Accept all capabilities when star in allowed capabilities" { | ||
run kwctl run --request-path test_data/req_pod_with_allowed_capabilities_accept.json --settings-json '{"allowed_capabilities": ["*"]}' annotated-policy.wasm | ||
|
||
# this prints the output when one the checks below fails | ||
echo "output = ${output}" | ||
|
||
[ "$status" -eq 0 ] | ||
echo "$output" | ||
[ $(expr "$output" : '.*"allowed":true.*') -ne 0 ] | ||
|
||
run kwctl run --request-path test_data/req_pod_with_allowed_capabilities_reject.json --settings-json '{"allowed_capabilities": ["*"]}' annotated-policy.wasm | ||
echo "$output" | ||
|
||
# this prints the output when one the checks below fails | ||
echo "output = ${output}" | ||
|
||
[ "$status" -eq 0 ] | ||
[ $(expr "$output" : '.*"allowed":true.*') -ne 0 ] | ||
} | ||
|
||
@test "Reject when star in allowed capabilities and capabilities in required_drop_capabilities" { | ||
run kwctl run --request-path test_data/req_pod_with_allowed_capabilities_reject.json --settings-json '{"allowed_capabilities": ["*"], "required_drop_capabilities": ["BPF"]}' annotated-policy.wasm | ||
|
||
# this prints the output when one the checks below fails | ||
echo "output = ${output}" | ||
|
||
[ "$status" -eq 0 ] | ||
echo "$output" | ||
[ $(expr "$output" : '.*"allowed":false.*') -ne 0 ] | ||
[ $(expr "$output" : '.*"message":"PSP capabilities policies doesn'\''t allow these capabilities to be added*') -ne 0 ] | ||
|
||
} | ||
@test "Reject capabilities in required_drop_capabilities" { | ||
run kwctl run --request-path test_data/req_pod_with_capabilities_in_required_drop_capabilities.json --settings-json '{"required_drop_capabilities": ["NET_ADMIN"]}' annotated-policy.wasm | ||
|
||
# this prints the output when one the checks below fails | ||
echo "output = ${output}" | ||
|
||
[ "$status" -eq 0 ] | ||
echo "$output" | ||
[ $(expr "$output" : '.*"allowed":false.*') -ne 0 ] | ||
[ $(expr "$output" : '.*"message":"PSP capabilities policies doesn'\''t allow these capabilities to be added*') -ne 0 ] | ||
} | ||
|
||
|
||
@test "Accept capabilities in allowed capabilities" { | ||
run kwctl run --request-path test_data/req_pod_with_allowed_capabilities_accept.json --settings-json '{"allowed_capabilities": ["CHOWN", "KILL"]}' annotated-policy.wasm | ||
|
||
# this prints the output when one the checks below fails | ||
echo "output = ${output}" | ||
|
||
[ "$status" -eq 0 ] | ||
echo "$output" | ||
[ $(expr "$output" : '.*"allowed":true.*') -ne 0 ] | ||
} | ||
|
||
@test "Reject capabilities not in allowed capabilities" { | ||
run kwctl run --request-path test_data/req_pod_with_allowed_capabilities_reject.json --settings-json '{"allowed_capabilities": ["CHOWN", "KILL"]}' annotated-policy.wasm | ||
|
||
# this prints the output when one the checks below fails | ||
echo "output = ${output}" | ||
|
||
[ "$status" -eq 0 ] | ||
echo "$output" | ||
[ $(expr "$output" : '.*"allowed":false.*') -ne 0 ] | ||
[ $(expr "$output" : '.*"message":"PSP capabilities policies doesn'\''t allow these capabilities to be added*') -ne 0 ] | ||
} | ||
|
||
@test "Mutate pods" { | ||
run kwctl run --request-path test_data/req_pod_with_mutate_capabilities.json --settings-json '{"allowed_capabilities": ["CHOWN", "KILL"], "required_drop_capabilities":["NET_ADMIN"], "default_add_capabilities":["CHOWN"]}' annotated-policy.wasm | ||
echo "$output" | ||
|
||
# this prints the output when one the checks below fails | ||
echo "output = ${output}" | ||
|
||
[ "$status" -eq 0 ] | ||
[ $(expr "$output" : '.*"allowed":true.*') -ne 0 ] | ||
[ $(expr "$output" : '.*"patchType":"JSONPatch"') -ne 0 ] | ||
} | ||
|
||
@test "Mutate deployments" { | ||
run kwctl run --request-path test_data/req_pod_with_mutate_capabilities_for_deployment.json --settings-json '{"allowed_capabilities": ["CHOWN", "KILL"], "required_drop_capabilities":["NET_ADMIN"], "default_add_capabilities":["CHOWN"]}' annotated-policy.wasm | ||
echo "$output" | ||
|
||
# this prints the output when one the checks below fails | ||
echo "output = ${output}" | ||
|
||
[ "$status" -eq 0 ] | ||
[ $(expr "$output" : '.*"allowed":true.*') -ne 0 ] | ||
[ $(expr "$output" : '.*"patchType":"JSONPatch"') -ne 0 ] | ||
} |
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 |
---|---|---|
@@ -1,47 +1,53 @@ | ||
{ | ||
"uid": "f0b8fba3-4f4f-465b-af8c-84d0326a2dc2", | ||
"kind": { | ||
"kind": "Pod", | ||
"version": "v1" | ||
"group": "", | ||
"kind": "Pod", | ||
"version": "v1" | ||
}, | ||
"resource": { | ||
"group": "", | ||
"version": "v1", | ||
"resource": "pods" | ||
}, | ||
"object": { | ||
"metadata": { | ||
"name": "hello" | ||
}, | ||
"spec": { | ||
"containers": [ | ||
{ | ||
"command": [ | ||
"sh", | ||
"-c", | ||
"echo 'Hello!' && sleep 1h" | ||
], | ||
"image": "busybox", | ||
"imagePullPolicy": "Always", | ||
"name": "hello", | ||
"resources": {}, | ||
"securityContext": { | ||
"capabilities": { | ||
"add": [ | ||
"CHOWN" | ||
] | ||
} | ||
} | ||
|
||
} | ||
] | ||
} | ||
"metadata": { | ||
"name": "hello" | ||
}, | ||
"spec": { | ||
"containers": [ | ||
{ | ||
"command": [ | ||
"sh", | ||
"-c", | ||
"echo 'Hello!' && sleep 1h" | ||
], | ||
"image": "busybox", | ||
"imagePullPolicy": "Always", | ||
"name": "hello", | ||
"resources": {}, | ||
"securityContext": { | ||
"capabilities": { | ||
"add": [ | ||
"CHOWN" | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"operation": "CREATE", | ||
"requestKind": { | ||
"kind": "Pod", | ||
"version": "v1" | ||
"group": "", | ||
"kind": "Pod", | ||
"version": "v1" | ||
}, | ||
"userInfo": { | ||
"groups": [ | ||
"system:masters", | ||
"system:authenticated" | ||
], | ||
"username": "shiva" | ||
"groups": [ | ||
"system:masters", | ||
"system:authenticated" | ||
], | ||
"username": "shiva" | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,47 +1,53 @@ | ||
{ | ||
"uid": "f0b8fba3-4f4f-465b-af8c-84d0326a2dc2", | ||
"kind": { | ||
"kind": "Pod", | ||
"version": "v1" | ||
"uid": "f0b8fba3-4f4f-465b-af8c-84d0326a2dc2", | ||
"kind": { | ||
"group": "", | ||
"kind": "Pod", | ||
"version": "v1" | ||
}, | ||
"resource": { | ||
"group": "", | ||
"version": "v1", | ||
"resource": "pods" | ||
}, | ||
"object": { | ||
"metadata": { | ||
"name": "hello" | ||
}, | ||
"object": { | ||
"metadata": { | ||
"name": "hello" | ||
}, | ||
"spec": { | ||
"containers": [ | ||
{ | ||
"command": [ | ||
"sh", | ||
"-c", | ||
"echo 'Hello!' && sleep 1h" | ||
], | ||
"image": "busybox", | ||
"imagePullPolicy": "Always", | ||
"name": "hello", | ||
"resources": {}, | ||
"securityContext": { | ||
"capabilities": { | ||
"add": [ | ||
"BPF" | ||
] | ||
} | ||
} | ||
|
||
} | ||
] | ||
"spec": { | ||
"containers": [ | ||
{ | ||
"command": [ | ||
"sh", | ||
"-c", | ||
"echo 'Hello!' && sleep 1h" | ||
], | ||
"image": "busybox", | ||
"imagePullPolicy": "Always", | ||
"name": "hello", | ||
"resources": {}, | ||
"securityContext": { | ||
"capabilities": { | ||
"add": [ | ||
"BPF" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"operation": "CREATE", | ||
"requestKind": { | ||
"kind": "Pod", | ||
"version": "v1" | ||
}, | ||
"userInfo": { | ||
"groups": [ | ||
"system:masters", | ||
"system:authenticated" | ||
], | ||
"username": "shiva" | ||
] | ||
} | ||
} | ||
}, | ||
"operation": "CREATE", | ||
"requestKind": { | ||
"group": "", | ||
"kind": "Pod", | ||
"version": "v1" | ||
}, | ||
"userInfo": { | ||
"groups": [ | ||
"system:masters", | ||
"system:authenticated" | ||
], | ||
"username": "shiva" | ||
} | ||
} |
92 changes: 49 additions & 43 deletions
92
test_data/req_pod_with_capabilities_in_required_drop_capabilities.json
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 |
---|---|---|
@@ -1,47 +1,53 @@ | ||
{ | ||
"uid": "f0b8fba3-4f4f-465b-af8c-84d0326a2dc2", | ||
"kind": { | ||
"kind": "Pod", | ||
"version": "v1" | ||
"uid": "f0b8fba3-4f4f-465b-af8c-84d0326a2dc2", | ||
"kind": { | ||
"group": "", | ||
"kind": "Pod", | ||
"version": "v1" | ||
}, | ||
"resource": { | ||
"group": "", | ||
"version": "v1", | ||
"resource": "pods" | ||
}, | ||
"object": { | ||
"metadata": { | ||
"name": "hello" | ||
}, | ||
"object": { | ||
"metadata": { | ||
"name": "hello" | ||
}, | ||
"spec": { | ||
"containers": [ | ||
{ | ||
"command": [ | ||
"sh", | ||
"-c", | ||
"echo 'Hello!' && sleep 1h" | ||
], | ||
"image": "busybox", | ||
"imagePullPolicy": "Always", | ||
"name": "hello", | ||
"resources": {}, | ||
"securityContext": { | ||
"capabilities": { | ||
"add": [ | ||
"NET_ADMIN" | ||
] | ||
} | ||
} | ||
|
||
} | ||
] | ||
"spec": { | ||
"containers": [ | ||
{ | ||
"command": [ | ||
"sh", | ||
"-c", | ||
"echo 'Hello!' && sleep 1h" | ||
], | ||
"image": "busybox", | ||
"imagePullPolicy": "Always", | ||
"name": "hello", | ||
"resources": {}, | ||
"securityContext": { | ||
"capabilities": { | ||
"add": [ | ||
"NET_ADMIN" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"operation": "CREATE", | ||
"requestKind": { | ||
"kind": "Pod", | ||
"version": "v1" | ||
}, | ||
"userInfo": { | ||
"groups": [ | ||
"system:masters", | ||
"system:authenticated" | ||
], | ||
"username": "shiva" | ||
] | ||
} | ||
} | ||
}, | ||
"operation": "CREATE", | ||
"requestKind": { | ||
"group": "", | ||
"kind": "Pod", | ||
"version": "v1" | ||
}, | ||
"userInfo": { | ||
"groups": [ | ||
"system:masters", | ||
"system:authenticated" | ||
], | ||
"username": "shiva" | ||
} | ||
} |
Oops, something went wrong.