Documentation ¶
Index ¶
- Constants
- type CertificateWriter
- type CertificateWriterMock
- type ConfigurationReader
- type ConfigurationReaderMock
- type DeviceReader
- type DeviceReaderWriter
- type DeviceReaderWriterMock
- func (mock *DeviceReaderWriterMock) CreateDevice(ctx context.Context, device entity.Device) error
- func (mock *DeviceReaderWriterMock) CreateDeviceCalls() []struct{ ... }
- func (mock *DeviceReaderWriterMock) GetDevice(ctx context.Context, id string) (entity.Device, error)
- func (mock *DeviceReaderWriterMock) GetDeviceCalls() []struct{ ... }
- func (mock *DeviceReaderWriterMock) UpdateDevice(ctx context.Context, device entity.Device) error
- func (mock *DeviceReaderWriterMock) UpdateDeviceCalls() []struct{ ... }
- type DeviceWriter
- type Service
- func (s *Service) Enrol(ctx context.Context, deviceID string) (status entity.EnrolStatus, err error)
- func (s *Service) GetConfiguration(ctx context.Context, deviceID string) (entity.DeviceConfiguration, error)
- func (s *Service) Heartbeat(ctx context.Context, heartbeat entity.Heartbeat) error
- func (s *Service) IsEnroled(ctx context.Context, deviceID string) (bool, error)
- func (s *Service) IsRegistered(ctx context.Context, deviceID string) (bool, error)
- func (s *Service) Register(ctx context.Context, deviceID string, csr string) (entity.CertificateGroup, error)
Constants ¶
const ( DefaultCertificateTTL = 3600 * 24 * 365 * time.Second BaseDomain = "home.net" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CertificateWriter ¶
type CertificateWriterMock ¶
type CertificateWriterMock struct { // SignCSRFunc mocks the SignCSR method. SignCSRFunc func(ctx context.Context, csr []byte, cn string, ttl time.Duration) (entity.CertificateGroup, error) // contains filtered or unexported fields }
CertificateWriterMock is a mock implementation of CertificateWriter.
func TestSomethingThatUsesCertificateWriter(t *testing.T) { // make and configure a mocked CertificateWriter mockedCertificateWriter := &CertificateWriterMock{ SignCSRFunc: func(ctx context.Context, csr []byte, cn string, ttl time.Duration) (entity.CertificateGroup, error) { panic("mock out the SignCSR method") }, } // use mockedCertificateWriter in code that requires CertificateWriter // and then make assertions. }
func (*CertificateWriterMock) SignCSR ¶
func (mock *CertificateWriterMock) SignCSR(ctx context.Context, csr []byte, cn string, ttl time.Duration) (entity.CertificateGroup, error)
SignCSR calls SignCSRFunc.
func (*CertificateWriterMock) SignCSRCalls ¶
func (mock *CertificateWriterMock) SignCSRCalls() []struct { Ctx context.Context Csr []byte Cn string TTL time.Duration }
SignCSRCalls gets all the calls that were made to SignCSR. Check the length with:
len(mockedCertificateWriter.SignCSRCalls())
type ConfigurationReader ¶
type ConfigurationReaderMock ¶
type ConfigurationReaderMock struct { // GetDeviceConfigurationFunc mocks the GetDeviceConfiguration method. GetDeviceConfigurationFunc func(ctx context.Context, id string) (entity.DeviceConfiguration, error) // contains filtered or unexported fields }
ConfigurationReaderMock is a mock implementation of ConfigurationReader.
func TestSomethingThatUsesConfigurationReader(t *testing.T) { // make and configure a mocked ConfigurationReader mockedConfigurationReader := &ConfigurationReaderMock{ GetDeviceConfigurationFunc: func(ctx context.Context, id string) (entity.ConfigurationResponse, error) { panic("mock out the GetDeviceConfiguration method") }, } // use mockedConfigurationReader in code that requires ConfigurationReader // and then make assertions. }
func (*ConfigurationReaderMock) GetDeviceConfiguration ¶
func (mock *ConfigurationReaderMock) GetDeviceConfiguration(ctx context.Context, id string) (entity.DeviceConfiguration, error)
GetDeviceConfiguration calls GetDeviceConfigurationFunc.
func (*ConfigurationReaderMock) GetDeviceConfigurationCalls ¶
func (mock *ConfigurationReaderMock) GetDeviceConfigurationCalls() []struct { Ctx context.Context ID string }
GetDeviceConfigurationCalls gets all the calls that were made to GetDeviceConfiguration. Check the length with:
len(mockedConfigurationReader.GetDeviceConfigurationCalls())
type DeviceReader ¶
DeviceReader is an interface that groups all the methods allowing to query/get devices.
type DeviceReaderWriter ¶
type DeviceReaderWriter interface { DeviceReader DeviceWriter }
type DeviceReaderWriterMock ¶
type DeviceReaderWriterMock struct { // CreateDeviceFunc mocks the CreateDevice method. CreateDeviceFunc func(ctx context.Context, device entity.Device) error // GetDeviceFunc mocks the GetDevice method. GetDeviceFunc func(ctx context.Context, id string) (entity.Device, error) // UpdateDeviceFunc mocks the UpdateDevice method. UpdateDeviceFunc func(ctx context.Context, device entity.Device) error // contains filtered or unexported fields }
DeviceReaderWriterMock is a mock implementation of DeviceReaderWriter.
func TestSomethingThatUsesDeviceReaderWriter(t *testing.T) { // make and configure a mocked DeviceReaderWriter mockedDeviceReaderWriter := &DeviceReaderWriterMock{ CreateDeviceFunc: func(ctx context.Context, device entity.Device) error { panic("mock out the CreateDevice method") }, GetDeviceFunc: func(ctx context.Context, id string) (entity.Device, error) { panic("mock out the GetDevice method") }, UpdateDeviceFunc: func(ctx context.Context, device entity.Device) error { panic("mock out the UpdateDevice method") }, } // use mockedDeviceReaderWriter in code that requires DeviceReaderWriter // and then make assertions. }
func (*DeviceReaderWriterMock) CreateDevice ¶
CreateDevice calls CreateDeviceFunc.
func (*DeviceReaderWriterMock) CreateDeviceCalls ¶
func (mock *DeviceReaderWriterMock) CreateDeviceCalls() []struct { Ctx context.Context Device entity.Device }
CreateDeviceCalls gets all the calls that were made to CreateDevice. Check the length with:
len(mockedDeviceReaderWriter.CreateDeviceCalls())
func (*DeviceReaderWriterMock) GetDevice ¶
func (mock *DeviceReaderWriterMock) GetDevice(ctx context.Context, id string) (entity.Device, error)
GetDevice calls GetDeviceFunc.
func (*DeviceReaderWriterMock) GetDeviceCalls ¶
func (mock *DeviceReaderWriterMock) GetDeviceCalls() []struct { Ctx context.Context ID string }
GetDeviceCalls gets all the calls that were made to GetDevice. Check the length with:
len(mockedDeviceReaderWriter.GetDeviceCalls())
func (*DeviceReaderWriterMock) UpdateDevice ¶
UpdateDevice calls UpdateDeviceFunc.
func (*DeviceReaderWriterMock) UpdateDeviceCalls ¶
func (mock *DeviceReaderWriterMock) UpdateDeviceCalls() []struct { Ctx context.Context Device entity.Device }
UpdateDeviceCalls gets all the calls that were made to UpdateDevice. Check the length with:
len(mockedDeviceReaderWriter.UpdateDeviceCalls())
type DeviceWriter ¶
type DeviceWriter interface { CreateDevice(ctx context.Context, device entity.Device) error UpdateDevice(ctx context.Context, device entity.Device) error }
DeviceWriter allows creating a device.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func New ¶
func New(dr DeviceReaderWriter, confReader ConfigurationReader, certWriter CertificateWriter) *Service
func (*Service) Enrol ¶
func (s *Service) Enrol(ctx context.Context, deviceID string) (status entity.EnrolStatus, err error)
Enrol tries to enrol a device. If enable-auto-enrolment is true then the device is automatically enrolled. If false, the device is created but not enroled yet.