testutil

package
v0.96.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSampleFileRelationships

func AddSampleFileRelationships(s *sbom.SBOM)

func AssertEncoderAgainstGoldenImageSnapshot

func AssertEncoderAgainstGoldenImageSnapshot(t *testing.T, imgCfg ImageSnapshotTestConfig, cfg EncoderSnapshotTestConfig)

func AssertEncoderAgainstGoldenSnapshot

func AssertEncoderAgainstGoldenSnapshot(t *testing.T, cfg EncoderSnapshotTestConfig)

func DirectoryInput

func DirectoryInput(t testing.TB, dir string) sbom.SBOM

func DirectoryInputWithAuthorField

func DirectoryInputWithAuthorField(t testing.TB) sbom.SBOM

func ImageInput

func ImageInput(t testing.TB, testImage string, options ...ImageOption) sbom.SBOM

Types

type EncoderSnapshotTestConfig

type EncoderSnapshotTestConfig struct {
	Subject                     sbom.SBOM
	Format                      sbom.FormatEncoder
	UpdateSnapshot              bool
	PersistRedactionsInSnapshot bool
	IsJSON                      bool
	Redactor                    Redactor
}

type ImageOption

type ImageOption func(cfg *imageCfg)

func FromSnapshot

func FromSnapshot() ImageOption

type ImageSnapshotTestConfig

type ImageSnapshotTestConfig struct {
	Image               string
	UpdateImageSnapshot bool
}

type PatternReplacement

type PatternReplacement struct {
	Search  *regexp.Regexp
	Replace string
}

func NewPatternReplacement

func NewPatternReplacement(r *regexp.Regexp) PatternReplacement

func (PatternReplacement) Redact

func (p PatternReplacement) Redact(b []byte) []byte

type Redactions

type Redactions struct {
	// contains filtered or unexported fields
}

func NewRedactions

func NewRedactions(redactors ...Redactor) *Redactions

func (Redactions) Redact

func (r Redactions) Redact(b []byte) []byte

func (*Redactions) WithFunctions

func (r *Redactions) WithFunctions(values ...func([]byte) []byte) *Redactions

func (*Redactions) WithPatternRedactors

func (r *Redactions) WithPatternRedactors(values map[string]string) *Redactions

func (*Redactions) WithPatternsRedacted

func (r *Redactions) WithPatternsRedacted(values ...string) *Redactions

func (*Redactions) WithRedactors

func (r *Redactions) WithRedactors(rs ...Redactor) *Redactions

func (*Redactions) WithValueRedactors

func (r *Redactions) WithValueRedactors(values map[string]string) *Redactions

func (*Redactions) WithValuesRedacted

func (r *Redactions) WithValuesRedacted(values ...string) *Redactions

type Redactor

type Redactor interface {
	Redact([]byte) []byte
}

type RedactorFn

type RedactorFn func([]byte) []byte

func (RedactorFn) Redact

func (r RedactorFn) Redact(b []byte) []byte

type ValueReplacement

type ValueReplacement struct {
	Search  string
	Replace string
}

func NewValueReplacement

func NewValueReplacement(v string) ValueReplacement

func (ValueReplacement) Redact

func (v ValueReplacement) Redact(b []byte) []byte

Jump to

Keyboard shortcuts

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