clients

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

package clients helps set up the graphql backend for testing graphql clients

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ingest

func Ingest(ctx context.Context, t *testing.T, gqlClient graphql.Client, data GuacData) nounIds

func SetupTest

func SetupTest(t *testing.T) graphql.Client

SetupTest starts the graphql server and returns a client for it. The parameter t is used to register a function to close the server and to fail the test upon any errors.

Types

type GuacData

type GuacData struct {
	/** the nouns need to be specified here in order to be referenced from a verb **/
	Packages  []string // packages are specified by purl
	Artifacts []string // artifacts are specified by digest
	Sources   []string // sources are specified by the name in the SourceName node
	Builders  []string // builders are specified by URI

	/** verbs **/
	HasSboms       []HasSbom
	IsOccurrences  []IsOccurrence
	IsDependencies []IsDependency
	HashEquals     []HashEqual
	HasSlsas       []HasSlsa
}

Defines the Guac graph, to test clients of the Graphql server.

This type, along with the Ingest function, is similar to the backend IngestPredicates type and the corresponding assembler function, but allows for significantly less verbose tests by specifying each noun with a single string and making the various InputSpec structs optional. Additionally, t.Fatalf is called upon any errors. However, this also means that a few inputs aren't supported, such as finer-grained definition of nouns.

All verbs are currently attached to packge version nodes, but a configuration for this could be added if needed.

type HasSbom

type HasSbom struct {
	Subject                string   // a previously ingested purl or digest
	IncludedSoftware       []string // a list of previously ingested purls and digests
	IncludedIsDependencies []IsDependency
	IncludedIsOccurrences  []IsOccurrence
	Spec                   *gql.HasSBOMInputSpec // if nil, a default will be used
}

type HasSlsa

type HasSlsa struct {
	Subject   string             // a previously ingested digest
	BuiltFrom []string           // a list of previously ingested digests
	BuiltBy   string             // a previously ingested builder
	Spec      *gql.SLSAInputSpec // if nil, a default will be used
}

type HashEqual

type HashEqual struct {
	ArtifactA string                  // a previously ingested digest
	ArtifactB string                  // a previously ingested digest
	Spec      *gql.HashEqualInputSpec // if nil, a default will be used
}

type IsDependency

type IsDependency struct {
	DependentPkg  string                     // a previously ingested purl
	DependencyPkg string                     // a previously ingested purl
	Spec          *gql.IsDependencyInputSpec // if nil, a default will be used
}

type IsOccurrence

type IsOccurrence struct {
	Subject  string                     // a previously ingested purl or source
	Artifact string                     // a previously ingested digest
	Spec     *gql.IsOccurrenceInputSpec // if nil, a default will be used
}

Jump to

Keyboard shortcuts

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