...

Source file src/github.com/sigstore/rekor/pkg/sharding/shard_fuzz_test.go

Documentation: github.com/sigstore/rekor/pkg/sharding

     1  // Copyright 2022 The Sigstore Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //	http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  package sharding
    15  
    16  import "testing"
    17  
    18  func FuzzCreateEntryIDFromParts(f *testing.F) {
    19  	f.Fuzz(func(t *testing.T, treeID, uuid string) {
    20  		if _, err := CreateEntryIDFromParts(treeID, uuid); err != nil {
    21  			t.Skipf("failed to create entryID from %v + %v: %v", treeID, uuid, err)
    22  		}
    23  	})
    24  }
    25  
    26  func FuzzGetUUIDFromIDString(f *testing.F) {
    27  	f.Fuzz(func(t *testing.T, entryID string) {
    28  		if _, err := GetUUIDFromIDString(entryID); err != nil {
    29  			t.Skipf("error getting UUID from %v: %v", entryID, err)
    30  		}
    31  	})
    32  }
    33  
    34  func FuzzGetTreeIDFromIDString(f *testing.F) {
    35  	f.Fuzz(func(t *testing.T, entryID string) {
    36  		if _, err := GetTreeIDFromIDString(entryID); err != nil {
    37  			t.Skipf("error getting treeID from %v: %v", entryID, err)
    38  		}
    39  	})
    40  }
    41  
    42  func FuzzPadToTreeIDLen(f *testing.F) {
    43  	f.Fuzz(func(t *testing.T, treeID string) {
    44  		if _, err := PadToTreeIDLen(treeID); err != nil {
    45  			t.Skipf("error padding %v: %v", treeID, err)
    46  		}
    47  	})
    48  }
    49  
    50  func FuzzReturnEntryIDString(f *testing.F) {
    51  	f.Fuzz(func(t *testing.T, treeID, uuid string) {
    52  		if _, err := CreateEntryIDFromParts(treeID, uuid); err != nil {
    53  			t.Skipf("failed to create entryID from %s + %s: %s", treeID, uuid, err)
    54  		}
    55  	})
    56  }
    57  
    58  func FuzzTreeID(f *testing.F) {
    59  	f.Fuzz(func(t *testing.T, treeID string) {
    60  		if _, err := TreeID(treeID); err != nil {
    61  			t.Skipf("error creating treeID %v: %v", treeID, err)
    62  		}
    63  	})
    64  }
    65  
    66  func FuzzValidateUUID(f *testing.F) {
    67  	f.Fuzz(func(t *testing.T, uuid string) {
    68  		if err := ValidateUUID(uuid); err != nil {
    69  			t.Skipf("error validating UUID %v: %v", uuid, err)
    70  		}
    71  	})
    72  }
    73  
    74  func FuzzValidateTreeID(f *testing.F) {
    75  	f.Fuzz(func(t *testing.T, treeID string) {
    76  		if err := ValidateTreeID(treeID); err != nil {
    77  			t.Skipf("error validating treeID %v: %v", treeID, err)
    78  		}
    79  	})
    80  }
    81  
    82  func FuzzValidateEntryID(f *testing.F) {
    83  	f.Fuzz(func(t *testing.T, entryID string) {
    84  		if err := ValidateEntryID(entryID); err != nil {
    85  			t.Skipf("error validating entryID %v: %v", entryID, err)
    86  		}
    87  	})
    88  }
    89  

View as plain text