From 062922151ef95c6cd9248814a143f26fc9e84f41 Mon Sep 17 00:00:00 2001 From: Binbin Li Date: Mon, 6 May 2024 12:09:36 +0000 Subject: [PATCH] test: add a fuzz test --- pkg/utils/utils_fuzz_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 pkg/utils/utils_fuzz_test.go diff --git a/pkg/utils/utils_fuzz_test.go b/pkg/utils/utils_fuzz_test.go new file mode 100644 index 000000000..58b13e96c --- /dev/null +++ b/pkg/utils/utils_fuzz_test.go @@ -0,0 +1,31 @@ +/* +Copyright The Ratify Authors. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package utils + +import "testing" + +func FuzzParseSubjectReference(f *testing.F) { + testcases := []string{"localhost:5000/net&monitor:v1", "prom/prometheus", "net-monitor@sha256:a0fc570a245b09ed752c42d600ee3bb5b4f77bbd70d8898780b7ab43454530eb"} + for _, tc := range testcases { + f.Add(tc) + } + f.Fuzz(func(t *testing.T, input string) { + _, err := ParseSubjectReference(input) + if err != nil { + return + } + }) +}