Skip to content

Commit 00292f5

Browse files
committed
fix spec fuzzer
1 parent 41d1acf commit 00292f5

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

pkg/controller/direct/bigtable/authorizedview_fuzzer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
func init() {
27-
fuzztesting.RegisterKRMFuzzer(bigtableAuthorizedViewFuzzer())
27+
fuzztesting.RegisterKRMSpecFuzzer(bigtableAuthorizedViewFuzzer())
2828
}
2929

3030
func bigtableAuthorizedViewFuzzer() fuzztesting.KRMFuzzer {

pkg/controller/direct/register/register.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,4 @@ import (
7070
_ "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/vmwareengine"
7171
_ "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/workflows"
7272
_ "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/workstations"
73-
_ "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/bigtable"
7473
)

pkg/test/fuzz/generate.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ func fillWithRandom0(t *testing.T, randStream *rand.Rand, msg protoreflect.Messa
100100
case protoreflect.Uint32Kind:
101101
// TODO: handle []uint32
102102

103+
case protoreflect.BytesKind:
104+
listVal := msg.Mutable(field).List()
105+
for j := 0; j < count; j++ {
106+
b := randomBytes(randStream)
107+
listVal.Append(protoreflect.ValueOf(b))
108+
}
109+
103110
default:
104111
t.Fatalf("unhandled field kind %v: %v", field.Kind(), field)
105112
}
@@ -312,6 +319,15 @@ func Visit(msgPath string, msg protoreflect.Message, setter func(v protoreflect.
312319
visitor.VisitPrimitive(path+"[]", el, setter)
313320
}
314321

322+
case protoreflect.BytesKind:
323+
for j := 0; j < count; j++ {
324+
el := listVal.Get(j)
325+
setter := func(v protoreflect.Value) {
326+
listVal.Set(j, v)
327+
}
328+
visitor.VisitPrimitive(path+"[]", el, setter)
329+
}
330+
315331
default:
316332
klog.Fatalf("unhandled field kind %v: %v", field.Kind(), field)
317333
}

0 commit comments

Comments
 (0)