inventorytest

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0, Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Facts

type Facts struct {
	*httptest.Server
	Identity oidc.ValidatorConfig
}

func ServeFacts

func ServeFacts(t *testing.T, inv *Static, issuer string, key sshcert.RawPublicKey) *Facts

func ServeFactsWithConfig

func ServeFactsWithConfig(t *testing.T, inv *Static, cfg oidc.ValidatorConfig, key sshcert.RawPublicKey) *Facts

func ServeFactsWithSources

func ServeFactsWithSources(t *testing.T, users directory.Directory, hosts inventory.Hosts, cfg oidc.ValidatorConfig, key sshcert.RawPublicKey) *Facts

func (*Facts) CAOption

func (f *Facts) CAOption() ca.Option

type Static

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

Static is a combined YAML fact fixture for integration tests: directory users and hosts loaded once at startup. Reload is a process restart, like the policy itself.

inventory.Host entries come in two forms. An exact entry (`names:`) is one registered host. A pattern entry (`pattern:`) uses the same DNS-label-aware hostname patterns as Writ host selectors. Exact entries expose all their names; pattern entries adopt the requested name. Principal realms are separate issuance metadata and never replace host names. Patterns are the escape hatch for fleets of short-lived hosts (VM pools, CI runners) that follow a naming pattern but cannot be enumerated in a file.

func NewStatic

func NewStatic(paths []string, options ...StaticOption) (*Static, error)

NewStatic loads an inventory from one or more YAML files. Files concatenate; a missing id, duplicate id/userName, or duplicate exact host name across the set is a load error. All IDs belong to the inventory service's single configured provider/tenant. Decoding is strict — an unknown field is an error, not a silently ignored typo.

func (*Static) DirectoryRevision

func (s *Static) DirectoryRevision() string

func (*Static) InventoryRevision

func (s *Static) InventoryRevision() string

func (*Static) ListUserFacts

func (s *Static) ListUserFacts(ctx context.Context) ([]directory.User, directory.Revision, error)

func (*Static) LookupHost

func (s *Static) LookupHost(_ context.Context, name string) (*inventory.ResolvedHost, string, error)

LookupHost implements Hosts: exact entries first, then pattern entries in file order, first match wins.

func (*Static) LookupUser

func (s *Static) LookupUser(ctx context.Context, id string) (*directory.User, directory.Revision, error)

LookupUser delegates directory semantics to the production static loader.

type StaticOption

type StaticOption func(*staticOptions) error

StaticOption configures static inventory loading.

func WithDefaultPrincipalMode

func WithDefaultPrincipalMode(mode inventory.PrincipalMode) StaticOption

WithDefaultPrincipalMode sets the mode inherited by host entries that omit principal-mode. The default is inventory.AccountNamePrincipals.

func WithoutHosts

func WithoutHosts() StaticOption

WithoutHosts loads only directory facts, independently of host configuration.

func WithoutUsers

func WithoutUsers() StaticOption

WithoutUsers loads only host facts; user records cannot become a fallback.

Jump to

Keyboard shortcuts

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