test

package
v1.4.21 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenDuplicatePackages

func GenDuplicatePackages(n int) ([]*claircore.Package, error)

GenDuplicatePackages creates an array of packages with duplicates. the array will will take n/2 and use this is a mod operand along with the current index in the for loop. it is an error to set n to 0 or 1

func GenUniqueDistributionScanners

func GenUniqueDistributionScanners(n int) indexer.VersionedScanners

GenUniqueDistributionScanners creates n number of unique DistributionScanners. the array is gauranteed to not have any scanner fields be duplicates

func GenUniqueDistributions

func GenUniqueDistributions(n int) []*claircore.Distribution

GenUniqueDistributions creates an array of unique distributions. the array is guaranteed not to have any duplicately named dist fields.

func GenUniquePackageScanners

func GenUniquePackageScanners(n int) indexer.VersionedScanners

GenUniquePackageScanners creates n number of unique PackageScanners. the array is gauranteed to not have any scanner fields be duplicates

func GenUniquePackages

func GenUniquePackages(n int) []*claircore.Package

GenUniquePackages creates an array of unique packages. the array is guaranteed not to have any duplicately named package fields. source packages are given an n + 1 ID to avoid duplicate primary key on insert.

func GenUniqueRepositories

func GenUniqueRepositories(n int, opts ...GenRepoOption) []*claircore.Repository

GenUniqueRepositories creates an array of unique repositories. the array is guaranteed not to have any duplicately named repo fields.

func GenUniqueRepositoryScanners

func GenUniqueRepositoryScanners(n int) indexer.VersionedScanners

GenUniqueRepositoryScanners creates n number of unique RepositoryScanners. the array is gauranteed to not have any scanner fields be duplicates

func GenUniqueVulnerabilities

func GenUniqueVulnerabilities(n int, updater string) []*claircore.Vulnerability

func NewRoundTripper

func NewRoundTripper(fn RoundTripFunc) http.RoundTripper

NewRoundTripper creates a http.RoundTripper with the provided RoundTripFunc. RountTripFunc should validate the incoming request is what's expected

func RandomSHA256Digest added in v0.0.14

func RandomSHA256Digest(t testing.TB) claircore.Digest

RandomHash returns a random Digest.

func RealizeLayers added in v0.0.13

func RealizeLayers(ctx context.Context, t *testing.T, spec ...LayerSpec) []claircore.Layer

RealizeLayers uses fetch.Layer to populate a directory and returns a slice of Layers describing them.

func ServeLayers added in v0.0.13

func ServeLayers(t *testing.T, n int) (*http.Client, []*claircore.Layer)

ServeLayers constructs "n" random layers, arranges to serve them, and returns a slice of filled Layer structs.

func Updater added in v0.0.8

func Updater(file string) (driver.Updater, error)

func WFN added in v0.0.24

func WFN(i int) cpe.WFN

Types

type GenRepoOption added in v0.0.13

type GenRepoOption func(*claircore.Repository)

type LayerSpec added in v0.0.13

type LayerSpec struct {
	Domain, Repo string
	ID           claircore.Digest
}

type RoundTripFunc

type RoundTripFunc func(req *http.Request) (*http.Response, error)

type ScannerTestcase added in v0.0.16

type ScannerTestcase struct {
	Domain  string
	Name    string
	Hash    string
	Want    []*claircore.Package
	Scanner indexer.PackageScanner
}

ScannerTestcase can be used for testing layers found in the wild against a scanner.

Tests that use this struct should not be marked as integration tests, as the Run method does that internally if it needs to talk to the network.

func (ScannerTestcase) Digest added in v0.0.16

func (tc ScannerTestcase) Digest() claircore.Digest

Digest reports the digest in the Hash member.

Panics if an error is returned from ParseDigest.

func (ScannerTestcase) Run added in v0.0.16

func (tc ScannerTestcase) Run(ctx context.Context) func(*testing.T)

Run returns a function suitable for using with (*testing.T).Run.

This function assumes the returned values must exactly match tc.Want. If tc.Want only covers a subset of potential returned values, then use RunSubset.

func (ScannerTestcase) RunSubset added in v1.4.20

func (tc ScannerTestcase) RunSubset(ctx context.Context, n int) func(*testing.T)

RunSubset returns a function suitable for using with (*testing.T).Run.

This function is similar to except it assumes tc.Want is a subset of all potential values. n is the total number of expected packages, ie len(got).

Directories

Path Synopsis
Bisect is a git bisect helper.
Bisect is a git bisect helper.
Package integration is a helper for running integration tests.
Package integration is a helper for running integration tests.
mock
driver
Package mock_driver is a generated GoMock package.
Package mock_driver is a generated GoMock package.
indexer
Package mock_indexer is a generated GoMock package.
Package mock_indexer is a generated GoMock package.
updater
Package mock_updater is a generated GoMock package.
Package mock_updater is a generated GoMock package.
updater/driver/v1
Package mock_driver is a generated GoMock package.
Package mock_driver is a generated GoMock package.
Ovaldebug is a helper for debugging the ovalutil package.
Ovaldebug is a helper for debugging the ovalutil package.
Package periodic contains tests meant to be run periodically in CI.
Package periodic contains tests meant to be run periodically in CI.

Jump to

Keyboard shortcuts

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