test

package
v2.24.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DPSHost              = "127.0.0.1:20130"
	DPSHTTPHost          = "127.0.0.1:20131"
	DPSEnrollmentGroupID = "6aa1aa8e-2b91-48ee-bfbc-a4e22d8e20d8"
	DPSOwner             = "1"
)
View Source
const (
	TestResourceSwitchesHref = "/switches"
	ResourcePlgdDpsHref      = "/plgd/dps"
	ResourcePlgdDpsType      = "x.plgd.dps.conf"
)

Variables

View Source
var (
	TestDockerContainerName             string
	TestDeviceName                      string
	TestDockerObtContainerName          string
	TestDeviceObtName                   string
	TestDeviceObtSupportsTestProperties bool

	TestDevsimResources []schema.ResourceLink
)

Functions

func CleanUpDpsResource

func CleanUpDpsResource(dps *ResourcePlgdDps)

func ClearDB

func ClearDB(t require.TestingT)

func ForceReprovision

func ForceReprovision(ctx context.Context, c pb.GrpcGatewayClient, deviceID string) error

func LightResourceInstanceHref

func LightResourceInstanceHref(id string) string

func MakeAPIsConfig

func MakeAPIsConfig() service.APIsConfig

func MakeAuthorizationConfig

func MakeAuthorizationConfig() service.AuthorizationConfig

func MakeConfig

func MakeConfig(t require.TestingT) service.Config

func MakeEnrollmentGroup

func MakeEnrollmentGroup() service.EnrollmentGroupConfig

func MakeHTTPConfig

func MakeHTTPConfig() service.HTTPConfig

func MakeHubConfig

func MakeHubConfig(hubID string, gateways ...string) service.HubConfig

func MakeStorageConfig

func MakeStorageConfig() service.StorageConfig

func New

func New(t *testing.T, cfg service.Config, opts ...service.Option) func()

func NewEnrollmentGroup

func NewEnrollmentGroup(t *testing.T, id, owner string) *pb.EnrollmentGroup

func NewHTTPService

func NewHTTPService(ctx context.Context, t *testing.T, store *storeMongo.Store) (*http.Service, func())

func NewHub

func NewHub(id, owner string) *pb.Hub

func NewMongoStore

func NewMongoStore(t require.TestingT) (*storeMongo.Store, func())

func NewWithContext

func NewWithContext(ctx context.Context, t *testing.T, cfg service.Config, opts ...service.Option) func()

New creates test dps-gateway.

func OnboardDpsSim

func OnboardDpsSim(ctx context.Context, t *testing.T, gc pb.GrpcGatewayClient, deviceID, dpsEndpoint string, expectedResources []schema.ResourceLink, opts ...Option) (string, func())

func OnboardDpsSimDevice

func OnboardDpsSimDevice(ctx context.Context, t *testing.T, gc pb.GrpcGatewayClient, d device.Device, dpsEndpoint string, expectedResources []schema.ResourceLink, opts ...Option) func()

func RestartDockerContainer

func RestartDockerContainer(dockerName string) error

func SendSignalToDocker

func SendSignalToDocker(dockerName, signal string) error

func SendSignalToProcess

func SendSignalToProcess(pid, signal string) error

func SetUp

func SetUp(t *testing.T) (tearDown func())

func SubscribeToAllEvents

func SubscribeToAllEvents(ctx context.Context, t *testing.T, c pb.GrpcGatewayClient, correllationID string) (pb.GrpcGateway_SubscribeToEventsClient, string)

func ToJSON

func ToJSON(v interface{}) ([]byte, error)

func WaitForDeviceStatus

func WaitForDeviceStatus(t *testing.T, client pb.GrpcGateway_SubscribeToEventsClient, deviceID, subID, correlationID string, status commands.Connection_Status) error

func WaitForRegistered

func WaitForRegistered(t *testing.T, client pb.GrpcGateway_SubscribeToEventsClient, deviceID, subID, correlationID string) error

Types

type CheckCountFn

type CheckCountFn func(h HandlerID, count uint64) codes.Code

type CheckFinalCountsFn

type CheckFinalCountsFn func(defaultHandlerCount, processTimeCount, processOwnershipCount, processCredentialsCount,
	processACLsCount, processCloudConfigurationCount uint64) (bool, error)

type DpsEndpoint

type DpsEndpoint struct {
	URI  string `json:"uri,omitempty"`
	Name string `json:"name,omitempty"`
}

type HandlerID

type HandlerID int
const (
	HandlerIDDefault HandlerID = iota
	HandlerIDTime
	HandlerIDOwnership
	HandlerIDCredentials
	HandlerIDACLs
	HandlerIDCloudConfiguration
)

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option interface used for setting optional onboardConfig properties.

func WithConfigureDevice

func WithConfigureDevice(configureDevice configureDpsDevice) Option

WithConfigureDevice sets a function that will be called after the device is owned, but before the device is onboarded.

func WithSdkID

func WithSdkID(id string) Option

WithSdkID creates Option that overrides the default device ID used by the SDK client.

func WithSdkRootCA

func WithSdkRootCA(certificate, key []byte) Option

WithSdkRootCA creates Option that overrides the certificate authority used by the SDK client.

func WithValidity

func WithValidity(validFrom, validFor string) Option

WithValidity creates Option that overrides the ValidFrom timestamp and CertExpiry interval used by the SDK client when generating certificates.

type RequestHandlerWithCounter

type RequestHandlerWithCounter struct {
	RequestHandlerWithDps
	// contains filtered or unexported fields
}

func NewRequestHandlerWithCounter

func NewRequestHandlerWithCounter(t *testing.T, dpsCfg service.Config, checkCount CheckCountFn, checkFinalCounts CheckFinalCountsFn) *RequestHandlerWithCounter

func NewRequestHandlerWithExpectedCounters

func NewRequestHandlerWithExpectedCounters(t *testing.T, failLimit uint64, failCode codes.Code, expectedTimeCount, expectedOwnershipCount,
	expectedCloudConfigurationCount, expectedCredentialsCount, expectedACLsCount uint64,
) *RequestHandlerWithCounter

we know the counter is invalid when the value is higher

func (*RequestHandlerWithCounter) DefaultHandler

func (h *RequestHandlerWithCounter) DefaultHandler(ctx context.Context, req *mux.Message, session *service.Session, linkedHubs []*service.LinkedHub, group *service.EnrollmentGroup) (*pool.Message, error)

func (*RequestHandlerWithCounter) ProcessACLs

func (h *RequestHandlerWithCounter) ProcessACLs(ctx context.Context, req *mux.Message, session *service.Session, linkedHubs []*service.LinkedHub, group *service.EnrollmentGroup) (*pool.Message, error)

func (*RequestHandlerWithCounter) ProcessCloudConfiguration

func (h *RequestHandlerWithCounter) ProcessCloudConfiguration(ctx context.Context, req *mux.Message, session *service.Session, linkedHubs []*service.LinkedHub, group *service.EnrollmentGroup) (*pool.Message, error)

func (*RequestHandlerWithCounter) ProcessCredentials

func (h *RequestHandlerWithCounter) ProcessCredentials(ctx context.Context, req *mux.Message, session *service.Session, linkedHubs []*service.LinkedHub, group *service.EnrollmentGroup) (*pool.Message, error)

func (*RequestHandlerWithCounter) ProcessOwnership

func (h *RequestHandlerWithCounter) ProcessOwnership(ctx context.Context, req *mux.Message, session *service.Session, linkedHubs []*service.LinkedHub, group *service.EnrollmentGroup) (*pool.Message, error)

func (*RequestHandlerWithCounter) ProcessPlgdTime

func (h *RequestHandlerWithCounter) ProcessPlgdTime(ctx context.Context, req *mux.Message, session *service.Session, linkedHubs []*service.LinkedHub, group *service.EnrollmentGroup) (*pool.Message, error)

func (*RequestHandlerWithCounter) Verify

type RequestHandlerWithDps

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

func MakeRequestHandlerWithDps

func MakeRequestHandlerWithDps(t *testing.T, dpsCfg service.Config) RequestHandlerWithDps

func (*RequestHandlerWithDps) Cfg

func (*RequestHandlerWithDps) IsStarted

func (h *RequestHandlerWithDps) IsStarted() bool

func (*RequestHandlerWithDps) Logf

func (h *RequestHandlerWithDps) Logf(template string, args ...interface{})

func (*RequestHandlerWithDps) RestartDps

func (h *RequestHandlerWithDps) RestartDps(opts ...service.Option)

func (*RequestHandlerWithDps) StartDps

func (h *RequestHandlerWithDps) StartDps(opts ...service.Option)

func (*RequestHandlerWithDps) StopDps

func (h *RequestHandlerWithDps) StopDps()

func (*RequestHandlerWithDps) T

type ResourcePlgdDps

type ResourcePlgdDps struct {
	Endpoint         *string             `json:"endpoint,omitempty"`
	EndpointName     *string             `json:"endpointName,omitempty"`
	Endpoints        []DpsEndpoint       `json:"endpoints,omitempty"`
	LastError        uint64              `json:"lastErrorCode,omitempty"`
	ProvisionStatus  string              `json:"provisionStatus,omitempty"`
	ForceReprovision bool                `json:"forceReprovision,omitempty"`
	Interfaces       []string            `json:"if,omitempty"`
	ResourceTypes    []string            `json:"rt,omitempty"`
	TestProperties   ResourcePlgdDpsTest `json:"test,omitempty"`
}

type ResourcePlgdDpsTest

type ResourcePlgdDpsTest struct {
	CloudStatusObserver ResourcePlgdDpsTestCloudStatusObserver `json:"cloudStatusObserver,omitempty"`
	Iotivity            ResourcePlgdDpsTestIotivity            `json:"iotivity,omitempty"`
}

type ResourcePlgdDpsTestCloudStatusObserver

type ResourcePlgdDpsTestCloudStatusObserver struct {
	MaxCount int64 `json:"maxCount,omitempty"`
}

type ResourcePlgdDpsTestIotivity

type ResourcePlgdDpsTestIotivity struct {
	Retry []int64 `json:"retry,omitempty"`
}

Jump to

Keyboard shortcuts

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