Documentation
¶
Overview ¶
Package fdotest contains test harnesses for the main fdo package.
Index ¶
- func ModuleNameOnlyRoutines(moduleName string) ...
- func RunClientTestSuite(t *testing.T, conf Config)
- func RunServerStateSuite(t *testing.T, state AllServerState)
- func TestingLog(t *testing.T) io.Writer
- type AllServerState
- type Config
- type MockDeviceModule
- type MockOwnerModule
- type MockPlugin
- type OwnerModulesFunc
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ModuleNameOnlyRoutines ¶
func ModuleNameOnlyRoutines(moduleName string) func() (func(context.Context, io.Writer) error, func(context.Context, io.Reader) error)
ModuleNameOnlyRoutines creates routines that only respond to module name commands.
func RunClientTestSuite ¶
RunClientTestSuite is used to test different implementations of server state methods at an almost end-to-end level (transport is mocked).
func RunServerStateSuite ¶
func RunServerStateSuite(t *testing.T, state AllServerState)
RunServerStateSuite is used to test different implementations of all server state methods.
Types ¶
type AllServerState ¶
type AllServerState interface { protocol.TokenService fdo.DISessionState fdo.TO0SessionState fdo.TO1SessionState fdo.TO2SessionState fdo.RendezvousBlobPersistentState fdo.ManufacturerVoucherPersistentState fdo.OwnerVoucherPersistentState fdo.OwnerKeyPersistentState ManufacturerKey(keyType protocol.KeyType) (crypto.Signer, []*x509.Certificate, error) }
AllServerState includes all server state interfaces and additional functions needed for testing.
type Config ¶
type Config struct { // If state is nil, then an in-memory implementation will be used. This is // useful for only testing service info modules. State AllServerState // If NewCredential is non-nil, then it will be used to create and format // the device credential. Otherwise the blob package will be used. NewCredential func(protocol.KeyType) (hmacSha256, hmacSha384 hash.Hash, key crypto.Signer, toDeviceCred func(fdo.DeviceCredential) any) // If NewTransport is non-nil, then it will be used in place of // fdo.Transport. NewTransport func(t *testing.T, tokens protocol.TokenService, di, to0, to1, to2 protocol.Responder) fdo.Transport // Use the Credential Reuse Protocol Reuse bool NoDebug bool DeviceModules map[string]serviceinfo.DeviceModule OwnerModules OwnerModulesFunc CustomExpect func(*testing.T, error) }
Config provides options to
type MockDeviceModule ¶
type MockDeviceModule struct { ActiveState bool TransitionFunc func(active bool) error ReceiveFunc func(ctx context.Context, messageName string, messageBody io.Reader, respond func(message string) io.Writer, yield func()) error YieldFunc func(ctx context.Context, respond func(message string) io.Writer, yield func()) error }
MockDeviceModule implements a trivial serviceinfo.DeviceModule.
func (*MockDeviceModule) Receive ¶
func (m *MockDeviceModule) Receive(ctx context.Context, messageName string, messageBody io.Reader, respond func(message string) io.Writer, yield func()) error
Receive implements serviceinfo.DeviceModule.
func (*MockDeviceModule) Transition ¶
func (m *MockDeviceModule) Transition(active bool) error
Transition implements serviceinfo.DeviceModule.
type MockOwnerModule ¶
type MockOwnerModule struct { HandleInfoFunc func(ctx context.Context, messageName string, messageBody io.Reader) error ProduceInfoFunc func(ctx context.Context, producer *serviceinfo.Producer) (blockPeer, moduleDone bool, _ error) }
MockOwnerModule implements a trivial serviceinfo.OwnerModule.
func (*MockOwnerModule) HandleInfo ¶
func (m *MockOwnerModule) HandleInfo(ctx context.Context, messageName string, messageBody io.Reader) error
HandleInfo implements serviceinfo.OwnerModule.
func (*MockOwnerModule) ProduceInfo ¶
func (m *MockOwnerModule) ProduceInfo(ctx context.Context, producer *serviceinfo.Producer) (blockPeer, moduleDone bool, _ error)
ProduceInfo implements serviceinfo.OwnerModule.
type MockPlugin ¶
type MockPlugin struct { Routines func() (func(context.Context, io.Writer) error, func(context.Context, io.Reader) error) Stopped chan struct{} GracefulStopped chan struct{} GracefulStopFunc func(context.Context) error // contains filtered or unexported fields }
MockPlugin implements a trivial plugin.Module.
func (*MockPlugin) GracefulStop ¶
func (m *MockPlugin) GracefulStop(ctx context.Context) error
GracefulStop implements plugin.Module.
type OwnerModulesFunc ¶
type OwnerModulesFunc func(ctx context.Context, replacementGUID protocol.GUID, info string, chain []*x509.Certificate, devmod serviceinfo.Devmod, supportedMods []string) iter.Seq2[string, serviceinfo.OwnerModule]
OwnerModulesFunc creates an iterator of service info modules for a given device.
type Transport ¶
type Transport struct { T *testing.T Tokens protocol.TokenService DIResponder *fdo.DIServer[custom.DeviceMfgInfo] TO0Responder *fdo.TO0Server TO1Responder *fdo.TO1Server TO2Responder *fdo.TO2Server // contains filtered or unexported fields }
Transport for tests, directly calling the server's responder. No encryption is used, but key exchange is still performed.
Directories
¶
Path | Synopsis |
---|---|
Package internal includes internal test helpers.
|
Package internal includes internal test helpers. |
memory
Package memory implements server state using non-persistent memory to complement internal/token.Service for state that must persist between protocol sessions.
|
Package memory implements server state using non-persistent memory to complement internal/token.Service for state that must persist between protocol sessions. |
token
Package token implements all server state interfaces possible using a stateless token.
|
Package token implements all server state interfaces possible using a stateless token. |