devicestatetest

package
v0.0.0-...-20647f5 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReqIDFailID501          = "REQID-FAIL-ID-501"
	ReqIDBadRequest         = "REQID-BAD-REQ"
	ReqIDPoll               = "REQID-POLL"
	ReqIDSerialWithBadModel = "REQID-SERIAL-W-BAD-MODEL"
)

Request IDs for hard-coded behaviors.

Variables

This section is empty.

Functions

func Device

func Device(st *state.State) (*auth.DeviceState, error)

func MarkInitialized

func MarkInitialized(st *state.State)

MarkInitialized flags the state as seeded and the device registered to avoid running the seeding code etc in tests, it also tries to sets the model to generic-classic. If the initial model is imporant this cannot be used.

func MockDeviceService

func MockDeviceService(c *C, bhv *DeviceServiceBehavior) (mockServer *httptest.Server, extraPemEncodedCerts []byte)

func MockGadget

func MockGadget(c *C, st *state.State, name string, revision snap.Revision, pDBhv *PrepareDeviceBehavior) (restore func())

func SetDevice

func SetDevice(st *state.State, device *auth.DeviceState) error

Types

type DeviceServiceBehavior

type DeviceServiceBehavior struct {
	ReqID string

	RequestIDURLPath     string
	SerialURLPath        string
	ExpectedCapabilities string

	Head          func(c *C, bhv *DeviceServiceBehavior, w http.ResponseWriter, r *http.Request)
	PostPreflight func(c *C, bhv *DeviceServiceBehavior, w http.ResponseWriter, r *http.Request)

	SignSerial func(c *C, bhv *DeviceServiceBehavior, headers map[string]interface{}, body []byte) (serial asserts.Assertion, ancillary []asserts.Assertion, err error)
}

type PrepareDeviceBehavior

type PrepareDeviceBehavior struct {
	DeviceSvcURL   string
	Headers        map[string]string
	RegBody        map[string]string
	ProposedSerial string
}

Jump to

Keyboard shortcuts

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