Documentation ¶
Index ¶
- Constants
- Variables
- func AlreadyExistsError(what string) *params.Error
- func AssertPrincipalApplicationDeployed(c *gc.C, st *state.State, applicationName string, curl string, forced bool, ...) *state.Application
- func AssertResponse(c *gc.C, resp *http.Response, expHTTPStatus int, expContentType string) []byte
- func CheckMethodCalls(c *gc.C, stub *testing.Stub, calls ...StubMethodCall)
- func EncodedJWT(params JWTParams, jwkSet jwk.Set, signingKey jwk.Key) ([]byte, error)
- func NewJWKSet() (jwk.Set, jwk.Key, error)
- func NewJWT(params JWTParams) (jwt.Token, error)
- func NotAssignedError(unitName string) *params.Error
- func NotFoundError(prefixMessage string) *params.Error
- func NotProvisionedError(machineId string) *params.Error
- func NotSupportedError(prefixMessage string) *params.Error
- func PrefixedError(prefix, message string) *params.Error
- func ResetStub(stub *testing.Stub)
- func SendHTTPRequest(c *gc.C, p HTTPRequestParams) *http.Response
- func ServerError(message string) *params.Error
- type FakeAuditLog
- type FakeAuthorizer
- func (fa FakeAuthorizer) AuthApplicationAgent() bool
- func (fa FakeAuthorizer) AuthClient() bool
- func (fa FakeAuthorizer) AuthController() bool
- func (fa FakeAuthorizer) AuthMachineAgent() bool
- func (fa FakeAuthorizer) AuthModelAgent() bool
- func (fa FakeAuthorizer) AuthOwner(tag names.Tag) bool
- func (fa FakeAuthorizer) AuthUnitAgent() bool
- func (fa FakeAuthorizer) ConnectedModel() string
- func (fa FakeAuthorizer) EntityHasPermission(entity names.Tag, operation permission.Access, _ names.Tag) error
- func (fa FakeAuthorizer) GetAuthTag() names.Tag
- func (fa FakeAuthorizer) HasPermission(operation permission.Access, target names.Tag) error
- type FakeNotifyWatcher
- type FakeSpace
- func (f *FakeSpace) EnsureDead() error
- func (f *FakeSpace) GoString() string
- func (f *FakeSpace) Id() string
- func (f *FakeSpace) Life() (life life.Value)
- func (f *FakeSpace) Name() string
- func (f *FakeSpace) NetworkSpace() (network.SpaceInfo, error)
- func (f *FakeSpace) ProviderId() (netID network.Id)
- func (f *FakeSpace) Remove() error
- func (f *FakeSpace) Zones() []string
- type FakeSubnet
- func (f *FakeSubnet) AvailabilityZones() []string
- func (f *FakeSubnet) CIDR() string
- func (f *FakeSubnet) GoString() string
- func (f *FakeSubnet) ID() string
- func (f *FakeSubnet) Life() state.Life
- func (f *FakeSubnet) ProviderId() network.Id
- func (f *FakeSubnet) ProviderNetworkId() network.Id
- func (f *FakeSubnet) SpaceID() string
- func (f *FakeSubnet) SpaceName() string
- func (f *FakeSubnet) VLANTag() int
- type FakeZone
- type HTTPRequestParams
- type JWTParams
- type Server
- type SetUpFlag
- type StubBacking
- func (sb *StubBacking) AddSpace(name string, providerId network.Id, subnets []string, public bool) (networkingcommon.BackingSpace, error)
- func (sb *StubBacking) AddSubnet(subnetInfo networkingcommon.BackingSubnetInfo) (networkingcommon.BackingSubnet, error)
- func (sb *StubBacking) AdditionalSubnets()
- func (sb *StubBacking) AllEndpointBindingsSpaceNames() (set.Strings, error)
- func (sb *StubBacking) AllSpaces() ([]networkingcommon.BackingSpace, error)
- func (sb *StubBacking) AllSubnets() ([]networkingcommon.BackingSubnet, error)
- func (sb *StubBacking) AvailabilityZones() (network.AvailabilityZones, error)
- func (sb *StubBacking) CloudSpec() (environscloudspec.CloudSpec, error)
- func (sb *StubBacking) DefaultEndpointBindingSpace() (string, error)
- func (sb *StubBacking) GoString() string
- func (sb *StubBacking) ModelConfig() (*config.Config, error)
- func (sb *StubBacking) ModelTag() names.ModelTag
- func (sb *StubBacking) SaveProviderSubnets(subnets []network.SubnetInfo, spaceID string) error
- func (sb *StubBacking) SetAvailabilityZones(zones network.AvailabilityZones) error
- func (sb *StubBacking) SetUp(c *gc.C, envName string, withZones, withSpaces, withSubnets SetUpFlag)
- func (sb *StubBacking) SubnetByCIDR(cidr string) (networkingcommon.BackingSubnet, error)
- type StubEnviron
- type StubLeaseManager
- type StubLeasePinner
- type StubLeaseReader
- type StubMethodCall
- func BackingCall(name string, args ...interface{}) StubMethodCall
- func NetworkingEnvironCall(name string, args ...interface{}) StubMethodCall
- func ProviderCall(name string, args ...interface{}) StubMethodCall
- func ZonedEnvironCall(name string, args ...interface{}) StubMethodCall
- func ZonedNetworkingEnvironCall(name string, args ...interface{}) StubMethodCall
- type StubNetwork
- type StubNetworkingEnviron
- type StubPoolHelper
- type StubProvider
- type StubZonedEnviron
- type StubZonedNetworkingEnviron
- func (se *StubZonedNetworkingEnviron) AvailabilityZones(ctx context.ProviderCallContext) (network.AvailabilityZones, error)
- func (se *StubZonedNetworkingEnviron) GoString() string
- func (se *StubZonedNetworkingEnviron) Subnets(ctx context.ProviderCallContext, instId instance.Id, subIds []network.Id) ([]network.SubnetInfo, error)
- func (se *StubZonedNetworkingEnviron) SupportsSpaceDiscovery(ctx context.ProviderCallContext) (bool, error)
- func (se *StubZonedNetworkingEnviron) SupportsSpaces(ctx context.ProviderCallContext) (bool, error)
Constants ¶
const ( StubProviderType = "stub-provider" StubEnvironName = "stub-environ" StubZonedEnvironName = "stub-zoned-environ" StubNetworkingEnvironName = "stub-networking-environ" StubZonedNetworkingEnvironName = "stub-zoned-networking-environ" )
Variables ¶
var ( testing.Stub{} BackingInstance = &StubBacking{Stub: SharedStub} ProviderInstance = &StubProvider{Stub: SharedStub} EnvironInstance = &StubEnviron{Stub: SharedStub} ZonedEnvironInstance = &StubZonedEnviron{Stub: SharedStub} NetworkingEnvironInstance = &StubNetworkingEnviron{Stub: SharedStub} ZonedNetworkingEnvironInstance = &StubZonedNetworkingEnviron{Stub: SharedStub} )SharedStub = &
params.CodeUnauthorized, }Message: "permission denied", Code:
Functions ¶
func AlreadyExistsError ¶
func AssertResponse ¶
func CheckMethodCalls ¶
func CheckMethodCalls(c *gc.C, stub *testing.Stub, calls ...StubMethodCall)
CheckMethodCalls works like testing.Stub.CheckCalls, but also checks the receivers.
func EncodedJWT ¶
EncodedJWT returns jwt as bytes signed by the specified key.
func NotAssignedError ¶
func NotFoundError ¶
func NotProvisionedError ¶
func NotSupportedError ¶
func PrefixedError ¶
func SendHTTPRequest ¶
func SendHTTPRequest(c *gc.C, p HTTPRequestParams) *http.Response
func ServerError ¶
Types ¶
type FakeAuditLog ¶
FakeAuditLog implements auditlog.AuditLog.
func (*FakeAuditLog) AddConversation ¶
func (l *FakeAuditLog) AddConversation(m auditlog.Conversation) error
func (*FakeAuditLog) AddRequest ¶
func (l *FakeAuditLog) AddRequest(m auditlog.Request) error
func (*FakeAuditLog) AddResponse ¶
func (l *FakeAuditLog) AddResponse(m auditlog.ResponseErrors) error
func (*FakeAuditLog) Close ¶
func (l *FakeAuditLog) Close() error
type FakeAuthorizer ¶
type FakeAuthorizer struct { Tag names.Tag Controller bool ModelUUID string AdminTag names.UserTag HasConsumeTag names.UserTag HasWriteTag names.UserTag }
FakeAuthorizer implements the facade.Authorizer interface.
func (FakeAuthorizer) AuthApplicationAgent ¶
func (fa FakeAuthorizer) AuthApplicationAgent() bool
AuthApplicationAgent returns whether the current client is an application operator.
func (FakeAuthorizer) AuthClient ¶
func (fa FakeAuthorizer) AuthClient() bool
AuthClient returns whether the authenticated entity is a client user.
func (FakeAuthorizer) AuthController ¶
func (fa FakeAuthorizer) AuthController() bool
func (FakeAuthorizer) AuthMachineAgent ¶
func (fa FakeAuthorizer) AuthMachineAgent() bool
AuthMachineAgent returns whether the current client is a machine agent.
func (FakeAuthorizer) AuthModelAgent ¶
func (fa FakeAuthorizer) AuthModelAgent() bool
AuthModelAgent returns true if the authenticated entity is a model agent
func (FakeAuthorizer) AuthOwner ¶
func (fa FakeAuthorizer) AuthOwner(tag names.Tag) bool
func (FakeAuthorizer) AuthUnitAgent ¶
func (fa FakeAuthorizer) AuthUnitAgent() bool
AuthUnitAgent returns whether the current client is a unit agent.
func (FakeAuthorizer) ConnectedModel ¶
func (fa FakeAuthorizer) ConnectedModel() string
ConnectedModel returns the UUID of the model the current client is connected to.
func (FakeAuthorizer) EntityHasPermission ¶
func (fa FakeAuthorizer) EntityHasPermission(entity names.Tag, operation permission.Access, _ names.Tag) error
EntityHasPermission returns true if the passed entity is admin or has a name equal to the pre-set admin tag.
func (FakeAuthorizer) GetAuthTag ¶
func (fa FakeAuthorizer) GetAuthTag() names.Tag
func (FakeAuthorizer) HasPermission ¶
func (fa FakeAuthorizer) HasPermission(operation permission.Access, target names.Tag) error
HasPermission returns true if the logged in user is admin or has a name equal to the pre-set admin tag.
type FakeNotifyWatcher ¶
type FakeNotifyWatcher struct { worker.Worker C chan struct{} }
FakeNotifyWatcher is an implementation of state.NotifyWatcher which is useful in tests.
func NewFakeNotifyWatcher ¶
func NewFakeNotifyWatcher() *FakeNotifyWatcher
func (*FakeNotifyWatcher) Changes ¶
func (w *FakeNotifyWatcher) Changes() <-chan struct{}
Changes is part of the state.NotifyWatcher interface.
func (*FakeNotifyWatcher) Err ¶
func (w *FakeNotifyWatcher) Err() error
Err is part of the state.NotifyWatcher interface.
func (*FakeNotifyWatcher) Stop ¶
func (w *FakeNotifyWatcher) Stop() error
Stop is part of the state.NotifyWatcher interface.
type FakeSpace ¶
type FakeSpace struct { SpaceId string SpaceName string SubnetIds []string Public bool NextErr errReturner }
FakeSpace implements networkingcommon.BackingSpace for testing.
func (*FakeSpace) EnsureDead ¶
func (*FakeSpace) ProviderId ¶
type FakeSubnet ¶
type FakeSubnet struct { Info networkingcommon.BackingSubnetInfo // contains filtered or unexported fields }
FakeSubnet implements networkingcommon.BackingSubnet for testing.
func (*FakeSubnet) AvailabilityZones ¶
func (f *FakeSubnet) AvailabilityZones() []string
func (*FakeSubnet) CIDR ¶
func (f *FakeSubnet) CIDR() string
func (*FakeSubnet) GoString ¶
func (f *FakeSubnet) GoString() string
GoString implements fmt.GoStringer.
func (*FakeSubnet) ID ¶
func (f *FakeSubnet) ID() string
func (*FakeSubnet) Life ¶
func (f *FakeSubnet) Life() state.Life
func (*FakeSubnet) ProviderId ¶
func (f *FakeSubnet) ProviderId() network.Id
func (*FakeSubnet) ProviderNetworkId ¶
func (f *FakeSubnet) ProviderNetworkId() network.Id
func (*FakeSubnet) SpaceID ¶
func (f *FakeSubnet) SpaceID() string
func (*FakeSubnet) SpaceName ¶
func (f *FakeSubnet) SpaceName() string
func (*FakeSubnet) VLANTag ¶
func (f *FakeSubnet) VLANTag() int
type FakeZone ¶
FakeZone implements providercommon.AvailabilityZone for testing.
type HTTPRequestParams ¶
type HTTPRequestParams struct { // do is used to make the HTTP request. // If it is nil, utils.GetNonValidatingHTTPClient().Do will be used. // If the body reader implements io.Seeker, // req.Body will also implement that interface. Do func(req *http.Request) (*http.Response, error) // expectError holds the error regexp to match // against the error returned from the HTTP Do // request. If it is empty, the error is expected to be // nil. ExpectError string // ExpectStatus holds the expected HTTP status code. // http.StatusOK is assumed if this is zero. ExpectStatus int // tag holds the tag to authenticate as. Tag string // password holds the password associated with the tag. Password string // method holds the HTTP method to use for the request. Method string // url holds the URL to send the HTTP request to. URL string // contentType holds the content type of the request. ContentType string // body holds the body of the request. Body io.Reader // extra headers are added to the http header ExtraHeaders map[string]string // jsonBody holds an object to be marshaled as JSON // as the body of the request. If this is specified, body will // be ignored and the Content-Type header will // be set to application/json. JSONBody interface{} // nonce holds the machine nonce to provide in the header. Nonce string }
httpRequestParams holds parameters for the sendHTTPRequest methods.
type Server ¶
type Server struct { // Addrs holds the address used for the // server, suitable for including in api.Info.Addrs Addrs []string *httptest.Server // contains filtered or unexported fields }
Server represents a fake API server. It must be closed after use.
func NewAPIServer ¶
NewAPIServer serves RPC methods on a localhost HTTP server. When a connection is made to the API, the newRoot function is called with the requested model UUID and the returned value defines the API (see the juju/rpc package).
Note that the root value accepts any facade version number - it is not currently possible to use this to serve several different facade versions.
The server uses testing.ServerCert and testing.ServerKey to host the server.
The returned server must be closed after use.
type StubBacking ¶
type StubBacking struct { *testing.Stub EnvConfig *config.Config Cloud environscloudspec.CloudSpec Zones network.AvailabilityZones Spaces []networkingcommon.BackingSpace Subnets []networkingcommon.BackingSubnet }
StubBacking implements networkingcommon.NetworkBacking and records calls to its methods.
func (*StubBacking) AddSpace ¶
func (sb *StubBacking) AddSpace(name string, providerId network.Id, subnets []string, public bool) (networkingcommon.BackingSpace, error)
func (*StubBacking) AddSubnet ¶
func (sb *StubBacking) AddSubnet(subnetInfo networkingcommon.BackingSubnetInfo) (networkingcommon.BackingSubnet, error)
func (*StubBacking) AdditionalSubnets ¶
func (sb *StubBacking) AdditionalSubnets()
func (*StubBacking) AllEndpointBindingsSpaceNames ¶
func (sb *StubBacking) AllEndpointBindingsSpaceNames() (set.Strings, error)
func (*StubBacking) AllSpaces ¶
func (sb *StubBacking) AllSpaces() ([]networkingcommon.BackingSpace, error)
func (*StubBacking) AllSubnets ¶
func (sb *StubBacking) AllSubnets() ([]networkingcommon.BackingSubnet, error)
func (*StubBacking) AvailabilityZones ¶
func (sb *StubBacking) AvailabilityZones() (network.AvailabilityZones, error)
func (*StubBacking) CloudSpec ¶
func (sb *StubBacking) CloudSpec() (environscloudspec.CloudSpec, error)
func (*StubBacking) DefaultEndpointBindingSpace ¶
func (sb *StubBacking) DefaultEndpointBindingSpace() (string, error)
func (*StubBacking) GoString ¶
func (sb *StubBacking) GoString() string
GoString implements fmt.GoStringer.
func (*StubBacking) ModelConfig ¶
func (sb *StubBacking) ModelConfig() (*config.Config, error)
func (*StubBacking) ModelTag ¶
func (sb *StubBacking) ModelTag() names.ModelTag
func (*StubBacking) SaveProviderSubnets ¶
func (sb *StubBacking) SaveProviderSubnets(subnets []network.SubnetInfo, spaceID string) error
func (*StubBacking) SetAvailabilityZones ¶
func (sb *StubBacking) SetAvailabilityZones(zones network.AvailabilityZones) error
func (*StubBacking) SetUp ¶
func (sb *StubBacking) SetUp(c *gc.C, envName string, withZones, withSpaces, withSubnets SetUpFlag)
func (*StubBacking) SubnetByCIDR ¶
func (sb *StubBacking) SubnetByCIDR(cidr string) (networkingcommon.BackingSubnet, error)
type StubEnviron ¶
type StubEnviron struct { *testing.Stub environs.Environ // panic on any not implemented method call }
StubEnviron is used in tests where environs.Environ is needed.
func (*StubEnviron) GoString ¶
func (se *StubEnviron) GoString() string
GoString implements fmt.GoStringer.
type StubLeaseManager ¶
StubLeaseManager pretends to implement lease.Manager. The only method called in this package should be Reader(), implemented below.
type StubLeasePinner ¶
StubLeasePinner pretends to implement lease.Pinner. The non-implemented methods should not be called by tests in the base apiserver package.
type StubLeaseReader ¶
StubLeaseReader pretends to implement lease.Reader. The non-implemented Leases() method should not be called by tests in the base apiserver package.
type StubMethodCall ¶
type StubMethodCall struct { Receiver interface{} FuncName string Args []interface{} }
StubMethodCall is like testing.StubCall, but includes the receiver as well.
func BackingCall ¶
func BackingCall(name string, args ...interface{}) StubMethodCall
BackingCall makes it easy to check method calls on BackingInstance.
func NetworkingEnvironCall ¶
func NetworkingEnvironCall(name string, args ...interface{}) StubMethodCall
NetworkingEnvironCall makes it easy to check method calls on NetworkingEnvironInstance.
func ProviderCall ¶
func ProviderCall(name string, args ...interface{}) StubMethodCall
ProviderCall makes it easy to check method calls on ProviderInstance.
func ZonedEnvironCall ¶
func ZonedEnvironCall(name string, args ...interface{}) StubMethodCall
ZonedEnvironCall makes it easy to check method calls on ZonedEnvironInstance.
func ZonedNetworkingEnvironCall ¶
func ZonedNetworkingEnvironCall(name string, args ...interface{}) StubMethodCall
ZonedNetworkingEnvironCall makes it easy to check method calls on ZonedNetworkingEnvironInstance.
type StubNetwork ¶
type StubNetwork struct { }
func (StubNetwork) SetUpSuite ¶
func (s StubNetwork) SetUpSuite(c *gc.C)
type StubNetworkingEnviron ¶
type StubNetworkingEnviron struct { *testing.Stub environs.NetworkingEnviron // panic on any not implemented method call }
StubNetworkingEnviron is used in tests where environs.NetworkingEnviron is needed.
func (*StubNetworkingEnviron) GoString ¶
func (se *StubNetworkingEnviron) GoString() string
GoString implements fmt.GoStringer.
func (*StubNetworkingEnviron) Subnets ¶
func (se *StubNetworkingEnviron) Subnets( ctx context.ProviderCallContext, instId instance.Id, subIds []network.Id, ) ([]network.SubnetInfo, error)
func (*StubNetworkingEnviron) SupportsSpaces ¶
func (se *StubNetworkingEnviron) SupportsSpaces(ctx context.ProviderCallContext) (bool, error)
type StubPoolHelper ¶
type StubPoolHelper struct {
StubRelease func() bool
}
StubPoolHelper implements state.PoolHelper
func (StubPoolHelper) Annotate ¶
func (s StubPoolHelper) Annotate(_ string)
func (StubPoolHelper) Release ¶
func (s StubPoolHelper) Release() bool
type StubProvider ¶
type StubProvider struct { *testing.Stub Zones network.AvailabilityZones Subnets []network.SubnetInfo environs.EnvironProvider // panic on any not implemented method call. }
StubProvider implements a subset of environs.EnvironProvider methods used in tests.
func (*StubProvider) GoString ¶
func (se *StubProvider) GoString() string
GoString implements fmt.GoStringer.
func (*StubProvider) Open ¶
func (sp *StubProvider) Open(_ stdcontext.Context, args environs.OpenParams) (environs.Environ, error)
type StubZonedEnviron ¶
type StubZonedEnviron struct { *testing.Stub providercommon.ZonedEnviron // panic on any not implemented method call }
StubZonedEnviron is used in tests where providercommon.ZonedEnviron is needed.
func (*StubZonedEnviron) AvailabilityZones ¶
func (se *StubZonedEnviron) AvailabilityZones(ctx context.ProviderCallContext) (network.AvailabilityZones, error)
func (*StubZonedEnviron) GoString ¶
func (se *StubZonedEnviron) GoString() string
GoString implements fmt.GoStringer.
type StubZonedNetworkingEnviron ¶
type StubZonedNetworkingEnviron struct { *testing.Stub // panic on any not implemented method call providercommon.ZonedEnviron environs.Networking }
StubZonedNetworkingEnviron is used in tests where features from both environs.Networking and providercommon.ZonedEnviron are needed.
func (*StubZonedNetworkingEnviron) AvailabilityZones ¶
func (se *StubZonedNetworkingEnviron) AvailabilityZones(ctx context.ProviderCallContext) (network.AvailabilityZones, error)
func (*StubZonedNetworkingEnviron) GoString ¶
func (se *StubZonedNetworkingEnviron) GoString() string
GoString implements fmt.GoStringer.
func (*StubZonedNetworkingEnviron) Subnets ¶
func (se *StubZonedNetworkingEnviron) Subnets( ctx context.ProviderCallContext, instId instance.Id, subIds []network.Id, ) ([]network.SubnetInfo, error)
func (*StubZonedNetworkingEnviron) SupportsSpaceDiscovery ¶
func (se *StubZonedNetworkingEnviron) SupportsSpaceDiscovery(ctx context.ProviderCallContext) (bool, error)
func (*StubZonedNetworkingEnviron) SupportsSpaces ¶
func (se *StubZonedNetworkingEnviron) SupportsSpaces(ctx context.ProviderCallContext) (bool, error)