controller

package
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2020 License: MPL-2.0 Imports: 67 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTestAuthMethodId = "ampw_1234567890"
	DefaultTestLoginName    = "user"
	DefaultTestPassword     = "passpass"
)

Variables

View Source
var RecoveryNonceCleanupInterval = 2 * time.Minute

This is exported so it can be tweaked in tests

Functions

This section is empty.

Types

type Config

type Config struct {
	// The base Server object, containing things shared between Controllers and
	// Workers
	*base.Server
	// The underlying configuration, passed in here to avoid duplicating values
	// everywhere
	RawConfig *config.Config
	// If set, authorization checking occurrs but failures are ignored
	DisableAuthorizationFailures bool
}

type Controller

type Controller struct {

	// Repo factory methods
	AuthTokenRepoFn    common.AuthTokenRepoFactory
	IamRepoFn          common.IamRepoFactory
	PasswordAuthRepoFn common.PasswordAuthRepoFactory
	ServersRepoFn      common.ServersRepoFactory
	SessionRepoFn      common.SessionRepoFactory
	StaticHostRepoFn   common.StaticRepoFactory
	TargetRepoFn       common.TargetRepoFactory
	// contains filtered or unexported fields
}

func New

func New(conf *Config) (*Controller, error)

func (*Controller) Shutdown

func (c *Controller) Shutdown(serversOnly bool) error

func (*Controller) Start

func (c *Controller) Start() error

func (*Controller) WorkerStatusUpdateTimes

func (c *Controller) WorkerStatusUpdateTimes() *sync.Map

WorkerStatusUpdateTimes returns the map, which specifically is held in _this_ controller, not the DB. It's used in tests to verify that a given controller is receiving updates from an expected set of workers, to test out balancing and auto reconnection.

type HandlerProperties

type HandlerProperties struct {
	ListenerConfig *configutil.Listener
	CancelCtx      context.Context
}

type TestController

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

TestController wraps a base.Server and Controller to provide a fully-programmatic controller for tests. Error checking (for instance, for valid config) is not stringent at the moment.

func NewTestController

func NewTestController(t *testing.T, opts *TestControllerOpts) *TestController

func (*TestController) AddClusterControllerMember

func (tc *TestController) AddClusterControllerMember(t *testing.T, opts *TestControllerOpts) *TestController

func (*TestController) ApiAddrs

func (tc *TestController) ApiAddrs() []string

func (*TestController) AuthTokenRepo

func (tc *TestController) AuthTokenRepo() *authtoken.Repository

func (*TestController) Cancel

func (tc *TestController) Cancel()

func (*TestController) Client

func (tc *TestController) Client() *api.Client

func (*TestController) ClusterAddrs

func (tc *TestController) ClusterAddrs() []string

func (*TestController) Config

func (tc *TestController) Config() *Config

func (*TestController) Context

func (tc *TestController) Context() context.Context

func (*TestController) Controller

func (tc *TestController) Controller() *Controller

Controller returns the underlying controller

func (*TestController) DbConn

func (tc *TestController) DbConn() *gorm.DB

func (*TestController) IamRepo

func (tc *TestController) IamRepo() *iam.Repository

func (*TestController) Kms

func (tc *TestController) Kms() *kms.Kms

func (*TestController) Logger

func (tc *TestController) Logger() hclog.Logger

func (*TestController) Name

func (tc *TestController) Name() string

func (*TestController) ServersRepo

func (tc *TestController) ServersRepo() *servers.Repository

func (*TestController) Shutdown

func (tc *TestController) Shutdown()

Shutdown runs any cleanup functions; be sure to run this after your test is done

func (*TestController) Token

func (tc *TestController) Token() *authtokens.AuthToken

type TestControllerOpts

type TestControllerOpts struct {
	// Config; if not provided a dev one will be created
	Config *config.Config

	// DefaultAuthMethodId is the default auth method ID to use, if set.
	DefaultAuthMethodId string

	// DefaultLoginName is the login name used when creating the default account.
	DefaultLoginName string

	// DefaultPassword is the password used when creating the default account.
	DefaultPassword string

	// DisableAuthMethodCreation can be set true to disable creating an auth
	// method automatically.
	DisableAuthMethodCreation bool

	// DisableScopesCreation can be set true to disable creating scopes
	// automatically.
	DisableScopesCreation bool

	// DisableHostResourcesCreation can be set true to disable creating a host
	// catalog and related resources automatically.
	DisableHostResourcesCreation bool

	// DisableTargetCreation can be set true to disable creating a target
	// automatically.
	DisableTargetCreation bool

	// DisableDatabaseCreation can be set true to disable creating a dev
	// database
	DisableDatabaseCreation bool

	// DisableDatabaseDestruction can be set true to allow a database to be
	// created but examined after-the-fact
	DisableDatabaseDestruction bool

	// If set, instead of creating a dev database, it will connect to an
	// existing database given the url
	DatabaseUrl string

	// If true, the controller will not be started
	DisableAutoStart bool

	// DisableAuthorizationFailures will still cause authz checks to be
	// performed but they won't cause 403 Forbidden. Useful for API-level
	// testing to avoid a lot of faff.
	DisableAuthorizationFailures bool

	// The controller KMS to use, or one will be created
	RootKms wrapping.Wrapper

	// The worker auth KMS to use, or one will be created
	WorkerAuthKms wrapping.Wrapper

	// The recovery KMS to use, or one will be created
	RecoveryKms wrapping.Wrapper

	// Disables KMS key creation. Only valid when a database url is specified,
	// at the moment.
	DisableKmsKeyCreation bool

	// The name to use for the controller, otherwise one will be randomly
	// generated, unless provided in a non-nil Config
	Name string

	// The logger to use, or one will be created
	Logger hclog.Logger
}

Directories

Path Synopsis
Package common contains types and helper functions that are used across the different packages under internal/server/controller.
Package common contains types and helper functions that are used across the different packages under internal/server/controller.

Jump to

Keyboard shortcuts

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