Documentation
¶
Overview ¶
Package testfixture implements the three controlled REST APIs that sit behind the gateway in its security, proxy, concurrency and crash regressions: orders, inventory and reports. Each serves synthetic data held in memory and records independent request receipts. Once its receipt log is full it refuses further operations. Receipts, state and reset use a control listener that requires a secret. The orders API also enforces object ownership with the subject and roles that the gateway forwards. Fetch's application services are implemented by the parent services package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Catalogue ¶
type Catalogue struct {
Version string `json:"version"`
Roles []string `json:"roles"`
Fixtures []struct {
Service string `json:"service"`
Version string `json:"version"`
SeedSHA256 string `json:"seed_sha256"`
} `json:"fixtures"`
Operations []struct {
ID string `json:"id"`
API string `json:"api"`
Method string `json:"method"`
Target string `json:"target"`
Auth string `json:"auth"`
Body bool `json:"body"`
Roles []string `json:"roles"`
} `json:"operations"`
Subjects []Subject `json:"subjects"`
Scenarios []Scenario `json:"scenarios"`
}
Catalogue is the decoded truth catalogue.
func LoadCatalogue ¶
LoadCatalogue decodes the embedded catalogue, rejecting unknown fields.
type Receipt ¶
type Receipt struct {
Seq int `json:"seq"`
Time time.Time `json:"time"`
RequestID string `json:"request_id"`
Generation string `json:"generation"`
Method string `json:"method"`
Target string `json:"target"`
Operation string `json:"operation"`
Status int `json:"status"`
Effect string `json:"effect,omitempty"`
Authorization bool `json:"authorization"`
Subject string `json:"subject,omitempty"` // X-Gateway-Subject as received
Roles string `json:"roles,omitempty"` // X-Gateway-Roles as received
BodyBytes int `json:"body_bytes"`
BodySHA256 string `json:"body_sha256,omitempty"`
}
Receipt is the fixture's own record of one request it received, written whether or not an operation matched.
type Scenario ¶
type Scenario struct {
Name string `json:"name"`
Subject string `json:"subject,omitempty"`
Operation string `json:"operation"`
Method string `json:"method"`
Path string `json:"path"`
Body json.RawMessage `json:"body,omitempty"`
GatewayStage string `json:"gateway_stage,omitempty"`
GatewayStatus int `json:"gateway_status,omitempty"`
Status int `json:"status"`
ChangesState bool `json:"changes_state"`
Effect string `json:"effect,omitempty"`
Response json.RawMessage `json:"response,omitempty"`
}
Scenario is one step of the replay sequence. Steps depend on the state left by earlier steps, so they run in order from the seed. Subject is the caller, empty for a public operation. Status and the fields after it are the fixture's own outcome. GatewayStage, when set, names the gateway stage that must refuse the step with GatewayStatus before it reaches any fixture.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is one running fixture API.
func (*Service) Control ¶
Control returns the privileged handler for receipts, state and reset. It must be served only on a listener that the gateway's clients cannot reach.
func (*Service) ServeHTTP ¶
func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP runs the matching operation and records the receipt. Every request is recorded unless the receipt log is full; then it is refused without a receipt. A missing receipt alone does not establish non-arrival.