Documentation
¶
Overview ¶
Package openstacktest provides a minimal fake OpenStack control plane for tests: a Keystone v3 endpoint that authenticates the service's own user (password or application credential), validates subject tokens issued by the test and serves project records, and a Nova compute endpoint, listed in the service catalog, that serves server records.
Index ¶
- Constants
- Variables
- type Instance
- type Project
- type Server
- func (s *Server) AddInstance(i Instance)
- func (s *Server) AddProject(p Project)
- func (s *Server) AppCredentialEnv() map[string]string
- func (s *Server) CAFile(t *testing.T) string
- func (s *Server) Env() map[string]string
- func (s *Server) IssueToken(u User, expires time.Time) string
- func (s *Server) LastComputeMicroversion() string
- func (s *Server) RevokeServiceTokens()
- func (s *Server) SetDown(down bool)
- type User
Constants ¶
const Region = "RegionOne"
Region is the region of the endpoints in the service catalog.
Variables ¶
var Service = User{ ID: "5e7a0c1d2b3f4a5e6d7c8b9a0f1e2d3c", Name: "spire-issuer", DomainID: "default", DomainName: "Default", Roles: []string{"service"}, }
Service is the service's own user, as authenticated through the OS_* variables returned by Env.
Functions ¶
This section is empty.
Types ¶
type Instance ¶
type Instance struct {
ID string
ProjectID string
UserID string
Status string
AvailabilityZone string
// FlavorName is the flavor's original_name, returned for compute
// microversions 2.47 and later.
FlavorName string
}
Instance is a Nova server record.
type Server ¶
type Server struct {
*httptest.Server
// Authentications counts successful POST /v3/auth/tokens.
Authentications atomic.Int32
// Validations counts GET /v3/auth/tokens requests.
Validations atomic.Int32
// ServerLookups counts GET /servers/{id} requests.
ServerLookups atomic.Int32
// ProjectLookups counts GET /v3/projects/{id} requests.
ProjectLookups atomic.Int32
// contains filtered or unexported fields
}
Server is a fake Keystone v3 and Nova control plane over TLS.
func (*Server) AddInstance ¶
AddInstance adds a server record to the fake Nova.
func (*Server) AddProject ¶
AddProject adds a project record to the fake Keystone.
func (*Server) AppCredentialEnv ¶
AppCredentialEnv returns the OS_* variables for authenticating with an application credential.
func (*Server) Env ¶
Env returns the OS_* variables of a typical openrc file for the service user, authenticating with a password and scoped to the service project.
func (*Server) IssueToken ¶
IssueToken returns a new subject token for the user, valid until expires.
func (*Server) LastComputeMicroversion ¶
LastComputeMicroversion returns the compute API microversion requested by the latest server lookup.
func (*Server) RevokeServiceTokens ¶
func (s *Server) RevokeServiceTokens()
RevokeServiceTokens invalidates every token issued to the service user, so that its next request must re-authenticate.