fuzztesting

package
v1.154.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRegisteredFuzzers added in v1.153.0

func GetRegisteredFuzzers() []any

func RegisterFuzzer

func RegisterFuzzer(fuzzer FuzzFn)

func RegisterKRMFuzzer

func RegisterKRMFuzzer(fuzzer KRMFuzzer)

func RegisterKRMFuzzer_NoProto added in v1.134.0

func RegisterKRMFuzzer_NoProto(fuzzer KRMFuzzer_NoProto)

func RegisterKRMSpecFuzzer added in v1.129.2

func RegisterKRMSpecFuzzer(fuzzer KRMFuzzer)

func RegisterKRMSpecFuzzer_NoProto added in v1.134.0

func RegisterKRMSpecFuzzer_NoProto(fuzzer KRMFuzzer_NoProto)

func VisitValues added in v1.141.0

VisitValues is a helper function that visits all values in a proto message, calling the provided function for each value. It is useful for applying filters.

Types

type FuzzFn

type FuzzFn func(t *testing.T, seed int64)

func ChooseFuzzer

func ChooseFuzzer(n int64) FuzzFn

type FuzzTest

type FuzzTest[ProtoT proto.Message, KRMType any] struct {
	ProtoType ProtoT

	FromProto func(ctx *direct.MapContext, in ProtoT) *KRMType
	ToProto   func(ctx *direct.MapContext, in *KRMType) ProtoT

	UnimplementedFields sets.Set[string]
	IgnoreFields        sets.Set[string]

	Filter func(in ProtoT)
}

func NewFuzzTest

func NewFuzzTest[ProtoT proto.Message, KRMType any](protoType ProtoT, fromProto func(ctx *direct.MapContext, in ProtoT) *KRMType, toProto func(ctx *direct.MapContext, in *KRMType) ProtoT) *FuzzTest[ProtoT, KRMType]

func (*FuzzTest[ProtoT, KRMType]) Fuzz

func (f *FuzzTest[ProtoT, KRMType]) Fuzz(t *testing.T, seed int64)

type FuzzTest_NoProto added in v1.134.0

type FuzzTest_NoProto[APIType any, KRMType any] struct {
	APIType APIType

	FromAPI func(ctx *direct.MapContext, in APIType) *KRMType
	ToAPI   func(ctx *direct.MapContext, in *KRMType) APIType

	UnimplementedFields sets.Set[string]
	IgnoreFields        sets.Set[string]

	Filter func(in APIType)
}

func NewFuzzTest_NoProto added in v1.134.0

func NewFuzzTest_NoProto[APIType any, KRMType any](apiType APIType, fromAPI func(ctx *direct.MapContext, in APIType) *KRMType, toAPI func(ctx *direct.MapContext, in *KRMType) APIType) *FuzzTest_NoProto[APIType, KRMType]

func (*FuzzTest_NoProto[APIType, KRMType]) Fuzz added in v1.134.0

func (f *FuzzTest_NoProto[APIType, KRMType]) Fuzz(t *testing.T, seed int64)

type KRMFuzzer

type KRMFuzzer interface {
	FuzzSpec(t *testing.T, seed int64)
	FuzzStatus(t *testing.T, seed int64)
}

type KRMFuzzer_NoProto added in v1.134.0

type KRMFuzzer_NoProto interface {
	FuzzSpec(t *testing.T, seed int64)
	FuzzStatus(t *testing.T, seed int64)
}

type KRMTypedFuzzer

type KRMTypedFuzzer[ProtoT proto.Message, SpecType any, StatusType any] struct {
	ProtoType ProtoT

	SpecFromProto func(ctx *direct.MapContext, in ProtoT) *SpecType
	SpecToProto   func(ctx *direct.MapContext, in *SpecType) ProtoT

	StatusFromProto func(ctx *direct.MapContext, in ProtoT) *StatusType
	StatusToProto   func(ctx *direct.MapContext, in *StatusType) ProtoT

	UnimplementedFields sets.Set[string]
	SpecFields          sets.Set[string]
	StatusFields        sets.Set[string]

	FilterSpec   func(in ProtoT)
	FilterStatus func(in ProtoT)
}

func NewKRMTypedFuzzer

func NewKRMTypedFuzzer[ProtoT proto.Message, SpecType any, StatusType any](
	protoType ProtoT,
	specFromProto func(ctx *direct.MapContext, in ProtoT) *SpecType, specToProto func(ctx *direct.MapContext, in *SpecType) ProtoT,
	statusFromProto func(ctx *direct.MapContext, in ProtoT) *StatusType, statusToProto func(ctx *direct.MapContext, in *StatusType) ProtoT,
) *KRMTypedFuzzer[ProtoT, SpecType, StatusType]

func NewKRMTypedSpecFuzzer added in v1.129.2

func NewKRMTypedSpecFuzzer[ProtoT proto.Message, SpecType any](
	protoType ProtoT,
	specFromProto func(ctx *direct.MapContext, in ProtoT) *SpecType,
	specToProto func(ctx *direct.MapContext, in *SpecType) ProtoT,
) *KRMTypedFuzzer[ProtoT, SpecType, NoStatus]

NewKRMTypedSpecFuzzer is a convenience function for creating a fuzzer that only fuzzes the spec fields of a KRM type.

func (*KRMTypedFuzzer[ProtoT, SpecType, StatusType]) FuzzSpec

func (f *KRMTypedFuzzer[ProtoT, SpecType, StatusType]) FuzzSpec(t *testing.T, seed int64)

func (*KRMTypedFuzzer[ProtoT, SpecType, StatusType]) FuzzStatus

func (f *KRMTypedFuzzer[ProtoT, SpecType, StatusType]) FuzzStatus(t *testing.T, seed int64)

func (*KRMTypedFuzzer[ProtoT, SpecType, StatusType]) IdentityField added in v1.135.0

func (f *KRMTypedFuzzer[ProtoT, SpecType, StatusType]) IdentityField(fieldPath string)

IdentityField marks a field as not supported in the mapper, because it is part of the identity (URL) rather than being part of the object itself.

func (*KRMTypedFuzzer[ProtoT, SpecType, StatusType]) Ignore_JSONBookkeeping added in v1.152.0

func (f *KRMTypedFuzzer[ProtoT, SpecType, StatusType]) Ignore_JSONBookkeeping(fieldPath string)

Ignore_JSONBookkeeping marks the specified fieldPath as fields we expect to be missing, such as ServerResponse or ForceSendFields.

func (*KRMTypedFuzzer[ProtoT, SpecType, StatusType]) SpecField added in v1.135.0

func (f *KRMTypedFuzzer[ProtoT, SpecType, StatusType]) SpecField(fieldPath string)

SpecField marks the specified fieldPath as round-tripping to/from the Spec

func (*KRMTypedFuzzer[ProtoT, SpecType, StatusType]) StatusField added in v1.135.0

func (f *KRMTypedFuzzer[ProtoT, SpecType, StatusType]) StatusField(fieldPath string)

StatusField marks the specified fieldPath as round-tripping to/from the Status

func (*KRMTypedFuzzer[ProtoT, SpecType, StatusType]) Unimplemented_Etag added in v1.136.0

func (f *KRMTypedFuzzer[ProtoT, SpecType, StatusType]) Unimplemented_Etag()

Unimplemented_Etag marks the 'etag' field as not round-tripped.

func (*KRMTypedFuzzer[ProtoT, SpecType, StatusType]) Unimplemented_Identity added in v1.137.0

func (f *KRMTypedFuzzer[ProtoT, SpecType, StatusType]) Unimplemented_Identity(fieldPath string)

Unimplemented_Identity marks the specified fieldPath as not round-tripped, and should be used for fields that are considered identity (URL) rather than being part of the object itself.

func (*KRMTypedFuzzer[ProtoT, SpecType, StatusType]) Unimplemented_Internal added in v1.135.0

func (f *KRMTypedFuzzer[ProtoT, SpecType, StatusType]) Unimplemented_Internal(fieldPath string)

Unimplemented_Internal marks the specified fieldPath as not round-tripped, and should be used for fields that are considered internal implementation details of the service

func (*KRMTypedFuzzer[ProtoT, SpecType, StatusType]) Unimplemented_LabelsAnnotations added in v1.135.0

func (f *KRMTypedFuzzer[ProtoT, SpecType, StatusType]) Unimplemented_LabelsAnnotations(fieldPath string)

Unimplemented_LabelsAnnotations marks the specified fieldPath as not round-tripped, and should be used for fields that are either labels or annotations

func (*KRMTypedFuzzer[ProtoT, SpecType, StatusType]) Unimplemented_NotYetTriaged added in v1.135.0

func (f *KRMTypedFuzzer[ProtoT, SpecType, StatusType]) Unimplemented_NotYetTriaged(fieldPath string)

Unimplemented_NotYetTriaged marks the specified fieldPath as not round-tripped, and should be used for fields that are added by the service and where we haven't decided whether or not to implement them. This should be the "starting point" for new fields added by services.

type KRMTypedFuzzer_NoProto added in v1.134.0

type KRMTypedFuzzer_NoProto[APIType any, SpecType any, StatusType any] struct {
	APIType APIType

	SpecFromAPI func(ctx *direct.MapContext, in APIType) *SpecType
	SpecToAPI   func(ctx *direct.MapContext, in *SpecType) APIType

	StatusFromAPI func(ctx *direct.MapContext, in APIType) *StatusType
	StatusToAPI   func(ctx *direct.MapContext, in *StatusType) APIType

	UnimplementedFields sets.Set[string]
	SpecFields          sets.Set[string]
	StatusFields        sets.Set[string]

	FilterSpec   func(in APIType)
	FilterStatus func(in APIType)
}

func NewKRMTypedFuzzer_NoProto added in v1.134.0

func NewKRMTypedFuzzer_NoProto[APIType any, SpecType any, StatusType any](
	apiType APIType,
	specFromAPI func(ctx *direct.MapContext, in APIType) *SpecType, specToAPI func(ctx *direct.MapContext, in *SpecType) APIType,
	statusFromAPI func(ctx *direct.MapContext, in APIType) *StatusType, statusToAPI func(ctx *direct.MapContext, in *StatusType) APIType,
) *KRMTypedFuzzer_NoProto[APIType, SpecType, StatusType]

func (*KRMTypedFuzzer_NoProto[APIType, SpecType, StatusType]) FuzzSpec added in v1.134.0

func (f *KRMTypedFuzzer_NoProto[APIType, SpecType, StatusType]) FuzzSpec(t *testing.T, seed int64)

func (*KRMTypedFuzzer_NoProto[APIType, SpecType, StatusType]) FuzzStatus added in v1.134.0

func (f *KRMTypedFuzzer_NoProto[APIType, SpecType, StatusType]) FuzzStatus(t *testing.T, seed int64)

func (*KRMTypedFuzzer_NoProto[APIType, SpecType, StatusType]) IdentityField added in v1.152.0

func (f *KRMTypedFuzzer_NoProto[APIType, SpecType, StatusType]) IdentityField(fieldPath string)

IdentityField marks the specified fieldPath as round-tripping to/from the resource Identity

func (*KRMTypedFuzzer_NoProto[APIType, SpecType, StatusType]) Ignore_JSONBookkeeping added in v1.152.0

func (f *KRMTypedFuzzer_NoProto[APIType, SpecType, StatusType]) Ignore_JSONBookkeeping(fieldPath string)

Ignore_JSONBookkeeping marks the specified fieldPath as fields we expect to be missing, such as ServerResponse or ForceSendFields.

func (*KRMTypedFuzzer_NoProto[APIType, SpecType, StatusType]) SpecField added in v1.145.0

func (f *KRMTypedFuzzer_NoProto[APIType, SpecType, StatusType]) SpecField(fieldPath string)

SpecField marks the specified fieldPath as round-tripping to/from the Spec

func (*KRMTypedFuzzer_NoProto[APIType, SpecType, StatusType]) StatusField added in v1.145.0

func (f *KRMTypedFuzzer_NoProto[APIType, SpecType, StatusType]) StatusField(fieldPath string)

StatusField marks the specified fieldPath as round-tripping to/from the Status

func (*KRMTypedFuzzer_NoProto[APIType, SpecType, StatusType]) Unimplemented_NotYetTriaged added in v1.145.0

func (f *KRMTypedFuzzer_NoProto[APIType, SpecType, StatusType]) Unimplemented_NotYetTriaged(fieldPath string)

Unimplemented_NotYetTriaged marks the specified fieldPath as not round-tripped, and should be used for fields that are added by the service and where we haven't decided whether or not to implement them.

type NoStatus added in v1.129.2

type NoStatus struct{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL