mocks

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatsContentKey = "StatsContentKey"
)

Variables

View Source
var (
	// Client errors
	ErrInvalidDeviceRequest = errors.New("unable to parse device, is invalid")    //400
	ErrInvalidDMSId         = errors.New("unable to parse DMS ID, is invalid")    //400
	ErrInvalidDeviceId      = errors.New("unable to parse Device ID, is invalid") //400
	ErrIncorrectType        = errors.New("unsupported media type")                //415
	ErrEmptyBody            = errors.New("empty body")

	//Server errors
	ErrInvalidOperation = errors.New("invalid operation")
	ErrActiveCert       = errors.New("can't isuee certificate. The device has a valid cert")
	ErrResponseEncode   = errors.New("error encoding response")
	ErrInsertLog        = errors.New("Could not insert log")
	ErrInsertDevice     = errors.New("Could not insert device")
	ErrDeviceById       = errors.New("Could not find device by Id")
	ErrSerialNumber     = errors.New("No Serial Number")
)

Functions

func CreateTestCA

func CreateTestCA(SerialNumber string, dmsenroller bool) caDTO.Cert

func NewInMemoryMockDB

func NewInMemoryMockDB() (store.StatsDB, error)

func NewLamassuCaClientMock

func NewLamassuCaClientMock(logger log.Logger) (lamassuca.LamassuCaClient, error)

Types

type BadgerMockDB

type BadgerMockDB struct {
	// contains filtered or unexported fields
}

func (*BadgerMockDB) GetStats

func (b *BadgerMockDB) GetStats(ctx context.Context) (dto.Stats, time.Time, error)

func (*BadgerMockDB) UpdateStats

func (b *BadgerMockDB) UpdateStats(ctx context.Context, stats dto.Stats) error

type DmsDB

type DmsDB struct {
	*sql.DB
	// contains filtered or unexported fields
}

func NewDmsDBMock

func NewDmsDBMock(t *testing.T) (*DmsDB, error)

func (*DmsDB) SelectByDMSIDAuthorizedCAs

func (db *DmsDB) SelectByDMSIDAuthorizedCAs(ctx context.Context, dmsid string) ([]dms.AuthorizedCAs, error)

func (*DmsDB) SelectBySerialNumber

func (db *DmsDB) SelectBySerialNumber(ctx context.Context, SerialNumber string) (string, error)

type LamassuCaClientConfig

type LamassuCaClientConfig struct {
	// contains filtered or unexported fields
}

func (*LamassuCaClientConfig) CreateCA

func (c *LamassuCaClientConfig) CreateCA(ctx context.Context, caType dto.CAType, caName string, privateKeyMetadata dto.PrivateKeyMetadata, subject dto.Subject, caTTL time.Duration, enrollerTTL time.Duration) (dto.Cert, error)

func (*LamassuCaClientConfig) DeleteCA

func (c *LamassuCaClientConfig) DeleteCA(ctx context.Context, caType dto.CAType, caName string) error

func (*LamassuCaClientConfig) GetCAs

func (*LamassuCaClientConfig) GetCert

func (c *LamassuCaClientConfig) GetCert(ctx context.Context, caType caDTO.CAType, caName string, SerialNumber string) (caDTO.Cert, error)

func (*LamassuCaClientConfig) GetIssuedCerts

func (c *LamassuCaClientConfig) GetIssuedCerts(ctx context.Context, caType caDTO.CAType, caName string, queryParameters filters.QueryParameters) (caDTO.IssuedCertsResponse, error)

func (*LamassuCaClientConfig) ImportCA

func (c *LamassuCaClientConfig) ImportCA(ctx context.Context, caType dto.CAType, caName string, certificate x509.Certificate, privateKey dto.PrivateKey, enrollerTTL time.Duration) (dto.Cert, error)

func (*LamassuCaClientConfig) RevokeCert

func (c *LamassuCaClientConfig) RevokeCert(ctx context.Context, caType caDTO.CAType, caName string, serialNumberToRevoke string) error

func (*LamassuCaClientConfig) SignCertificateRequest

func (c *LamassuCaClientConfig) SignCertificateRequest(ctx context.Context, caType caDTO.CAType, caName string, csr *x509.CertificateRequest, signVerbatim bool, cn string) (*x509.Certificate, *x509.Certificate, error)

type MockDB

type MockDB struct {
	*sql.DB
	// contains filtered or unexported fields
}

func NewDevicedDBMock

func NewDevicedDBMock(t *testing.T) (*MockDB, error)

func (*MockDB) DeleteDevice

func (db *MockDB) DeleteDevice(ctx context.Context, id string) error

func (*MockDB) GetStats

func (db *MockDB) GetStats(ctx context.Context) (dto.Stats, time.Time)

func (*MockDB) InsertDevice

func (db *MockDB) InsertDevice(ctx context.Context, alias string, deviceID string, dmsID string, description string, tags []string, iconName string, iconColor string) error

func (*MockDB) InsertDeviceCertHistory

func (db *MockDB) InsertDeviceCertHistory(ctx context.Context, l dto.DeviceCertHistory) error

func (*MockDB) InsertLog

func (db *MockDB) InsertLog(ctx context.Context, l dto.DeviceLog) error

func (*MockDB) SelectAllDevices

func (db *MockDB) SelectAllDevices(ctx context.Context, queryParameters filters.QueryParameters) ([]dto.Device, int, error)

func (*MockDB) SelectAllDevicesByDmsId

func (db *MockDB) SelectAllDevicesByDmsId(ctx context.Context, dms_id string, queryParameters filters.QueryParameters) ([]dto.Device, error)

func (*MockDB) SelectByDMSIDAuthorizedCAs

func (db *MockDB) SelectByDMSIDAuthorizedCAs(ctx context.Context, dmsid string) ([]dms.AuthorizedCAs, error)

func (*MockDB) SelectBySerialNumber

func (db *MockDB) SelectBySerialNumber(ctx context.Context, SerialNumber string) (string, error)

func (*MockDB) SelectDeviceById

func (db *MockDB) SelectDeviceById(ctx context.Context, id string) (dto.Device, error)

func (*MockDB) SelectDeviceCertHistory

func (db *MockDB) SelectDeviceCertHistory(ctx context.Context, deviceId string) ([]dto.DeviceCertHistory, error)

func (*MockDB) SelectDeviceCertHistoryBySerialNumber

func (db *MockDB) SelectDeviceCertHistoryBySerialNumber(ctx context.Context, serialNumber string) (dto.DeviceCertHistory, error)

func (*MockDB) SelectDeviceCertHistoryLastThirtyDays

func (db *MockDB) SelectDeviceCertHistoryLastThirtyDays(ctx context.Context, queryParameters filters.QueryParameters) ([]dto.DeviceCertHistory, error)

func (*MockDB) SelectDeviceLogs

func (db *MockDB) SelectDeviceLogs(ctx context.Context, deviceId string) ([]dto.DeviceLog, error)

func (*MockDB) SelectDmssLastIssuedCert

func (db *MockDB) SelectDmssLastIssuedCert(ctx context.Context, queryParameters filters.QueryParameters) ([]dto.DMSLastIssued, error)

func (*MockDB) SetKeyAndSubject

func (db *MockDB) SetKeyAndSubject(ctx context.Context, keyMetadate dto.PrivateKeyMetadataWithStregth, subject dto.Subject, deviceId string) error

func (*MockDB) UpdateByID

func (db *MockDB) UpdateByID(ctx context.Context, alias string, deviceID string, dmsID string, description string, tags []string, iconName string, iconColor string) error

func (*MockDB) UpdateDeviceCertHistory

func (db *MockDB) UpdateDeviceCertHistory(ctx context.Context, deviceId string, serialNumber string, newStatus string) error

func (*MockDB) UpdateDeviceCertificateSerialNumberByID

func (db *MockDB) UpdateDeviceCertificateSerialNumberByID(ctx context.Context, id string, serialNumber string) error

func (*MockDB) UpdateDeviceStatusByID

func (db *MockDB) UpdateDeviceStatusByID(ctx context.Context, id string, newStatus string) error

type StatsMockContent

type StatsMockContent struct {
	Stats    dto.Stats
	ScanDate time.Time
}

Jump to

Keyboard shortcuts

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