seedtest

package
v0.0.0-...-4c8c240 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SampleSnapYaml = map[string]string{
	"core": `name: core
type: os
version: 1.0
`,
	"pc-kernel": `name: pc-kernel
type: kernel
version: 1.0
`,
	"pc": `name: pc
type: gadget
version: 1.0
`,
	"classic-gadget": `name: classic-gadget
version: 1.0
type: gadget
`,
	"required": `name: required
type: app
version: 1.0
`,
	"classic-snap": `name: classic-snap
type: app
confinement: classic
version: 1.0
`,
	"snapd": `name: snapd
type: snapd
version: 1.0
`,
	"core18": `name: core18
type: base
version: 1.0
`,
	"pc-kernel=18": `name: pc-kernel
type: kernel
version: 1.0
`,
	"pc=18": `name: pc
type: gadget
base: core18
version: 1.0
`,
	"classic-gadget18": `name: classic-gadget18
version: 1.0
base: core18
type: gadget
`,
	"required18": `name: required18
type: app
base: core18
version: 1.0
`,
	"core20": `name: core20
type: base
version: 1.0
`,
	"pc-kernel=20": `name: pc-kernel
type: kernel
version: 1.0
`,
	"pc=20": `name: pc
type: gadget
base: core20
version: 1.0
`,
	"required20": `name: required20
type: app
base: core20
version: 1.0
components:
  comp1:
    type: standard
  comp2:
    type: standard
`,
	"required20+comp1": `component: required20+comp1
type: standard
version: 1.0
`,
	"required20+comp1_kernel": `component: required20+comp1
type: kernel-modules
version: 1.0
`,
	"required20+comp2": `component: required20+comp2
type: standard
version: 2.0
`,
	"required20+unknown": `component: required20+unknown
type: standard
version: 2.0
`,
	"aux-info-test": `name: aux-info-test
type: app
base: core20
version: 1.0
links:
  contact:
    - mailto:author@example.com
`,
	"component-test": `name: component-test
type: app
base: core20
version: 1.0
components:
  comp1:
    type: standard
  comp2:
    type: standard
  comp3:
    type: standard
`,
	"component-test+comp1": `component: component-test+comp1
type: standard
version: 1.0
`,
	"component-test+comp2": `component: component-test+comp2
type: standard
version: 2.0
`,
	"component-test+comp3": `component: component-test+comp3
type: standard
version: 2.0
`,
	"local-component-test": `name: local-component-test
type: app
base: core20
version: 1.0
components:
  comp4:
    type: standard
`,
	"local-component-test+comp4": `component: local-component-test+comp4
type: standard
version: 1.0
`,
	"optional20-a": `name: optional20-a
type: app
base: core20
version: 1.0
`,
	"optional20-b": `name: optional20-b
type: app
base: core20
version: 1.0`,
	"uboot-gadget=20": `name: uboot-gadget
type: gadget
base: core20
version: 1.0
`,
	"arm-kernel=20": `name: arm-kernel
type: kernel
version: 1.0
`,
	"test-devmode=20": `name: test-devmode
type: app
base: core20
version: 1.0
confinement: devmode
`,
	"core22": `name: core22
type: base
version: 1.0
`,
	"core24": `name: core24
type: base
version: 1.0
`,
	"pc-kernel=22": `name: pc-kernel
type: kernel
version: 1.0
`,
	"pc-kernel=24": `name: pc-kernel
type: kernel
version: 1.0
`,
	"pc-kernel=22+kmods": `name: pc-kernel
type: kernel
version: 1.0
components:
  kcomp1:
    type: kernel-modules
  kcomp2:
    type: kernel-modules
`,
	"pc-kernel=24+kmods": `name: pc-kernel
type: kernel
version: 1.0
components:
  kcomp1:
    type: kernel-modules
  kcomp2:
    type: kernel-modules
  kcomp3:
    type: kernel-modules
`,
	"pc-kernel+kcomp1": `component: pc-kernel+kcomp1
type: kernel-modules
version: 1.0
`,
	"pc-kernel+kcomp2": `component: pc-kernel+kcomp2
type: kernel-modules
version: 1.0
`,
	"pc-kernel+kcomp3": `component: pc-kernel+kcomp3
type: kernel-modules
version: 1.0
`,
	"pc=22": `name: pc
type: gadget
base: core22
version: 1.0
`,
	"pc=24": `name: pc
type: gadget
base: core24
version: 1.0
`,
	"optional22": `name: optional22
type: app
base: core22
version: 1.0
components:
  comp1:
    type: standard
`,
	"optional22+comp1": `component: optional22+comp1
type: standard
version: 1.0
`,
	"optional24": `name: optional24
type: app
base: core24
version: 1.0
components:
  comp1:
    type: standard
`,
	"optional24+comp1": `component: optional24+comp1
type: standard
version: 1.0
`,
}

Functions

func MergeSampleSnapYaml

func MergeSampleSnapYaml(snapYaml ...map[string]string) map[string]string

func ReadAssertions

func ReadAssertions(c *C, fn string) []asserts.Assertion

func ValidateSeed

func ValidateSeed(c *C, root, label string, usesSnapd bool, trusted []asserts.Assertion) seed.Seed

func WriteAssertions

func WriteAssertions(fn string, assertions ...asserts.Assertion)

func WriteValidAutoImportAssertion

func WriteValidAutoImportAssertion(c *C, brands *assertstest.SigningAccounts, seedDir, sysLabel string, perm os.FileMode)

Types

type SeedSnaps

type SeedSnaps struct {
	StoreSigning *assertstest.StoreStack
	Brands       *assertstest.SigningAccounts

	// TamperWithResourceRevisions can be set to modify resource revision
	// assertions before they get committed to the database. Mostly useful for
	// forcing some consistency check errors.
	TamperWithResourceRevisions func(headers map[string]interface{})
	// contains filtered or unexported fields
}

SeedSnaps helps creating snaps for a seed.

func (*SeedSnaps) AssertedComponentInfos

func (ss *SeedSnaps) AssertedComponentInfos(snapName string) []*snap.ComponentInfo

func (*SeedSnaps) AssertedResourcePair

func (ss *SeedSnaps) AssertedResourcePair(snapName string) []*asserts.SnapResourcePair

func (*SeedSnaps) AssertedResourceRevision

func (ss *SeedSnaps) AssertedResourceRevision(snapName string) []*asserts.SnapResourceRevision

func (*SeedSnaps) AssertedSnap

func (ss *SeedSnaps) AssertedSnap(snapName string) (snapFile string)

func (*SeedSnaps) AssertedSnapComponents

func (ss *SeedSnaps) AssertedSnapComponents(snapName string) []store.SnapResourceResult

func (*SeedSnaps) AssertedSnapID

func (ss *SeedSnaps) AssertedSnapID(snapName string) string

func (*SeedSnaps) AssertedSnapInfo

func (ss *SeedSnaps) AssertedSnapInfo(snapName string) *snap.Info

func (*SeedSnaps) AssertedSnapRevision

func (ss *SeedSnaps) AssertedSnapRevision(snapName string) *asserts.SnapRevision

func (*SeedSnaps) MakeAssertedDelegatedSnap

func (ss *SeedSnaps) MakeAssertedDelegatedSnap(
	c *C,
	snapYaml string,
	files [][]string,
	revision snap.Revision,
	developerID, delegateID, revProvenance, resourceProvenance string,
	revisionAuthority map[string]interface{},
	dbs ...*asserts.Database,
) (*asserts.SnapDeclaration, *asserts.SnapRevision)

func (*SeedSnaps) MakeAssertedDelegatedSnapWithComps

func (ss *SeedSnaps) MakeAssertedDelegatedSnapWithComps(
	c *C,
	snapYaml string,
	files [][]string,
	revision snap.Revision,
	compRevisions map[string]snap.Revision,
	developerID, delegateID, revProvenance, resourceRevProvenance string,
	revisionAuthority map[string]interface{},
	dbs ...*asserts.Database,
) (*asserts.SnapDeclaration, *asserts.SnapRevision)

func (*SeedSnaps) MakeAssertedSnap

func (ss *SeedSnaps) MakeAssertedSnap(c *C, snapYaml string, files [][]string, revision snap.Revision, developerID string, dbs ...*asserts.Database) (*asserts.SnapDeclaration, *asserts.SnapRevision)

func (*SeedSnaps) MakeAssertedSnapWithComps

func (ss *SeedSnaps) MakeAssertedSnapWithComps(c *C, snapYaml string, files [][]string, revision snap.Revision, compRevisions map[string]snap.Revision, developerID string, dbs ...*asserts.Database) (*asserts.SnapDeclaration, *asserts.SnapRevision)

func (*SeedSnaps) SetSnapAssertionNow

func (ss *SeedSnaps) SetSnapAssertionNow(t time.Time)

func (*SeedSnaps) SetupAssertSigning

func (ss *SeedSnaps) SetupAssertSigning(storeBrandID string)

SetupAssertSigning initializes StoreSigning for storeBrandID and Brands.

type TestingSeed16

type TestingSeed16 struct {
	SeedSnaps

	SeedDir string
}

TestingSeed16 helps setting up a populated Core 16/18 testing seed.

func (*TestingSeed16) AssertsDir

func (s *TestingSeed16) AssertsDir() string

func (*TestingSeed16) MakeAssertedSnap

func (s *TestingSeed16) MakeAssertedSnap(c *C, snapYaml string, files [][]string, revision snap.Revision, developerID string) (snapFname string, snapDecl *asserts.SnapDeclaration, snapRev *asserts.SnapRevision)

func (*TestingSeed16) MakeModelAssertionChain

func (s *TestingSeed16) MakeModelAssertionChain(brandID, model string, extras ...map[string]interface{}) []asserts.Assertion

func (*TestingSeed16) SnapsDir

func (s *TestingSeed16) SnapsDir() string

func (*TestingSeed16) WriteAssertions

func (s *TestingSeed16) WriteAssertions(fn string, assertions ...asserts.Assertion)

type TestingSeed20

type TestingSeed20 struct {
	SeedSnaps

	SeedDir string
}

TestingSeed20 helps setting up a populated Core 20 testing seed directory.

func (*TestingSeed20) MakeSeed

func (s *TestingSeed20) MakeSeed(c *C, label, brandID, modelID string, modelHeaders map[string]interface{}, optSnaps []*seedwriter.OptionsSnap) *asserts.Model

MakeSeed creates the seed with given label and generates model assertions

func (*TestingSeed20) MakeSeedWithLocalComponents

func (s *TestingSeed20) MakeSeedWithLocalComponents(c *C, label, brandID, modelID string, modelHeaders map[string]interface{}, optSnaps []*seedwriter.OptionsSnap, compPathsBySnap map[string][]string) *asserts.Model

func (*TestingSeed20) MakeSeedWithModel

func (s *TestingSeed20) MakeSeedWithModel(c *C, label string, model *asserts.Model, optSnaps []*seedwriter.OptionsSnap, compPathsBySnap map[string][]string)

MakeSeedWithModel creates the seed with given label for a given model

Jump to

Keyboard shortcuts

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