mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-29 10:55:05 +00:00
add test scenario - missing image tag
This commit is contained in:
parent
38bf4d6055
commit
eb8bd71ac2
3 changed files with 36 additions and 0 deletions
|
@ -64,6 +64,10 @@ func Test_validate_require_image_tag_not_latest_deny(t *testing.T) {
|
|||
testScenario(t, "test/scenarios/test/scenario_valiadate_require_image_tag_not_latest_deny.yaml")
|
||||
}
|
||||
|
||||
func Test_validate_require_image_tag_not_latest_notag(t *testing.T) {
|
||||
testScenario(t, "test/scenarios/test/scenario_valiadate_require_image_tag_not_latest_notag.yaml")
|
||||
}
|
||||
|
||||
func Test_validate_require_image_tag_not_latest_pass(t *testing.T) {
|
||||
testScenario(t, "test/scenarios/test/scenario_valiadate_require_image_tag_not_latest_pass.yaml")
|
||||
}
|
||||
|
|
10
test/manifest/require_image_tag_not_latest_notag.yaml
Normal file
10
test/manifest/require_image_tag_not_latest_notag.yaml
Normal file
|
@ -0,0 +1,10 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: myapp-pod
|
||||
labels:
|
||||
app: myapp
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx
|
|
@ -0,0 +1,22 @@
|
|||
# file path relative to project root
|
||||
input:
|
||||
policy: samples/best_practices/require_image_tag_not_latest.yaml
|
||||
resource: test/manifest/require_image_tag_not_latest_notag.yaml
|
||||
expected:
|
||||
validation:
|
||||
policyresponse:
|
||||
policy: validate-image-tag
|
||||
resource:
|
||||
kind: Pod
|
||||
apiVersion: v1
|
||||
namespace: ''
|
||||
name: myapp-pod
|
||||
rules:
|
||||
- name: image-tag-notspecified
|
||||
type: Validation
|
||||
message: Validation rule 'image-tag-notspecified' failed at '/spec/containers/0/image/' for resource Pod//myapp-pod. image tag not specified
|
||||
success: false
|
||||
- name: image-tag-not-latest
|
||||
type: Validation
|
||||
message: Validation rule 'image-tag-not-latest' succesfully validated
|
||||
success: true
|
Loading…
Add table
Reference in a new issue