Skip to content

Commit

Permalink
tests: ensure that we fail if Tags > 16
Browse files Browse the repository at this point in the history
Signed-off-by: Djalal Harouni <tixxdz@gmail.com>
  • Loading branch information
tixxdz committed Mar 12, 2024
1 parent bc99e40 commit 400895e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/sensors/tracing/kprobe_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,22 @@ spec:
assert.Error(t, err)
}
}

// Test that tracing policy max tags
func TestTracingPolicyTagsMax(t *testing.T) {
// Ensure that CRD fail if tags > 16
crd := `
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
name: "file-install"
spec:
kprobes:
- call: "fd_install"
syscall: false
tags: [ "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17" ]
`

err := checkCrd(t, crd)
assert.Error(t, err)
}
4 changes: 4 additions & 0 deletions pkg/sensors/tracing/tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ func TestGetPolicyTags(t *testing.T) {
tags, err = getPolicyTags(input)
require.NoError(t, err)
require.Equal(t, 3, len(tags))

input = []string{"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17"}
tags, err = getPolicyTags(input)

Check failure on line 37 in pkg/sensors/tracing/tags_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

ineffectual assignment to tags (ineffassign)
require.Error(t, err)
}

0 comments on commit 400895e

Please sign in to comment.