test

package
v2.7.15 Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestResourceSwitchesHref = "/switches"
)

Variables

View Source
var (
	CertIdentity = "00000000-0000-0000-0000-000000000001"

	MfgCert = []byte(`-----BEGIN CERTIFICATE-----
MIIB9zCCAZygAwIBAgIRAOwIWPAt19w7DswoszkVIEIwCgYIKoZIzj0EAwIwEzER
MA8GA1UEChMIVGVzdCBPUkcwHhcNMTkwNTAyMjAwNjQ4WhcNMjkwMzEwMjAwNjQ4
WjBHMREwDwYDVQQKEwhUZXN0IE9SRzEyMDAGA1UEAxMpdXVpZDpiNWEyYTQyZS1i
Mjg1LTQyZjEtYTM2Yi0wMzRjOGZjOGVmZDUwWTATBgcqhkjOPQIBBggqhkjOPQMB
BwNCAAQS4eiM0HNPROaiAknAOW08mpCKDQmpMUkywdcNKoJv1qnEedBhWne7Z0jq
zSYQbyqyIVGujnI3K7C63NRbQOXQo4GcMIGZMA4GA1UdDwEB/wQEAwIDiDAzBgNV
HSUELDAqBggrBgEFBQcDAQYIKwYBBQUHAwIGCCsGAQUFBwMBBgorBgEEAYLefAEG
MAwGA1UdEwEB/wQCMAAwRAYDVR0RBD0wO4IJbG9jYWxob3N0hwQAAAAAhwR/AAAB
hxAAAAAAAAAAAAAAAAAAAAAAhxAAAAAAAAAAAAAAAAAAAAABMAoGCCqGSM49BAMC
A0kAMEYCIQDuhl6zj6gl2YZbBzh7Th0uu5izdISuU/ESG+vHrEp7xwIhANCA7tSt
aBlce+W76mTIhwMFXQfyF3awWIGjOcfTV8pU
-----END CERTIFICATE-----
`)

	MfgKey = []byte(`-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIMPeADszZajrkEy4YvACwcbR0pSdlKG+m8ALJ6lj/ykdoAoGCCqGSM49
AwEHoUQDQgAEEuHojNBzT0TmogJJwDltPJqQig0JqTFJMsHXDSqCb9apxHnQYVp3
u2dI6s0mEG8qsiFRro5yNyuwutzUW0Dl0A==
-----END EC PRIVATE KEY-----
`)

	MfgTrustedCA = []byte(`-----BEGIN CERTIFICATE-----
MIIBaTCCAQ+gAwIBAgIQR33gIB75I7Vi/QnMnmiWvzAKBggqhkjOPQQDAjATMREw
DwYDVQQKEwhUZXN0IE9SRzAeFw0xOTA1MDIyMDA1MTVaFw0yOTAzMTAyMDA1MTVa
MBMxETAPBgNVBAoTCFRlc3QgT1JHMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE
xbwMaS8jcuibSYJkCmuVHfeV3xfYVyUq8Iroz7YlXaTayspW3K4hVdwIsy/5U+3U
vM/vdK5wn2+NrWy45vFAJqNFMEMwDgYDVR0PAQH/BAQDAgEGMBMGA1UdJQQMMAoG
CCsGAQUFBwMBMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0RBAQwAoIAMAoGCCqGSM49
BAMCA0gAMEUCIBWkxuHKgLSp6OXDJoztPP7/P5VBZiwLbfjTCVRxBvwWAiEAnzNu
6gKPwtKmY0pBxwCo3NNmzNpA6KrEOXE56PkiQYQ=
-----END CERTIFICATE-----
`)
	MfgTrustedCAKey = []byte(`-----BEGIN EC PRIVATE KEY-----
MHcCAQEEICzfC16AqtSv3wt+qIbrgM8dTqBhHANJhZS5xCpH6P2roAoGCCqGSM49
AwEHoUQDQgAExbwMaS8jcuibSYJkCmuVHfeV3xfYVyUq8Iroz7YlXaTayspW3K4h
VdwIsy/5U+3UvM/vdK5wn2+NrWy45vFAJg==
-----END EC PRIVATE KEY-----
`)
)
View Source
var (
	TestDeviceName                     string
	TestDeviceNameWithOicResObservable string

	TestDevsimResources        []schema.ResourceLink
	TestDevsimBackendResources []schema.ResourceLink
)

Functions

func AddDeviceSwitchResources

func AddDeviceSwitchResources(ctx context.Context, t *testing.T, deviceID string, c pb.GrpcGatewayClient, resourceIDs ...string) []schema.ResourceLink

func AssertToCheckFunc

func AssertToCheckFunc(checFunc func(t assert.TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool) func(t *testing.T, expected interface{}, actual interface{}, msgAndArgs ...interface{})

func CheckProtobufs

func CheckProtobufs(t *testing.T, expected interface{}, actual interface{}, checkFunc func(t *testing.T, expected interface{}, actual interface{}, msgAndArgs ...interface{}))

func CheckResource

func CheckResource(ctx context.Context, t *testing.T, deviceID, resourceURI, resourceType string, checkFn func(schema.ResourceLink) bool) bool

func CleanUpResourcesArray

func CleanUpResourcesArray(resources []*commands.Resource) []*commands.Resource

func DecodeCbor

func DecodeCbor(t *testing.T, data []byte) interface{}
func DefaultSwitchResourceLink(deviceID, id string) schema.ResourceLink

func EncodeToCbor

func EncodeToCbor(t *testing.T, v interface{}) []byte

func FieldJsonTag

func FieldJsonTag(v interface{}, fieldName string) string

Get json tag of field with given name in struct v

func FilterResourceLink(filter func(schema.ResourceLink) bool, links []schema.ResourceLink) []schema.ResourceLink

func FindDeviceByName

func FindDeviceByName(ctx context.Context, name string) (deviceID string, _ error)
func GetAllBackendResourceLinks() []schema.ResourceLink

func GetRootCertificateAuthorities

func GetRootCertificateAuthorities(t *testing.T) []*x509.Certificate

func GetRootCertificatePool

func GetRootCertificatePool(t *testing.T) *x509.CertPool

func IsDiscoveryResourceBatchObservable added in v2.3.7

func IsDiscoveryResourceBatchObservable(ctx context.Context, t *testing.T, deviceID string) bool

func MakeSwitchResourceData

func MakeSwitchResourceData(overrides map[string]interface{}) map[string]interface{}

func MakeSwitchResourceDefaultData

func MakeSwitchResourceDefaultData() map[string]interface{}

func MustFindDeviceByName

func MustFindDeviceByName(name string) (deviceID string)

func MustGetHostname

func MustGetHostname() string

func NATSSStart

func NATSSStart(ctx context.Context, t *testing.T)

func NATSSStop

func NATSSStop(ctx context.Context, t *testing.T)

func NewSDKClient

func NewSDKClient(opts ...Option) (*client.Client, error)

func OffBoardDevSim added in v2.7.8

func OffBoardDevSim(ctx context.Context, t *testing.T, deviceID string)

func OnboardDevSim

func OnboardDevSim(ctx context.Context, t *testing.T, c pb.GrpcGatewayClient, deviceID, hubEndpoint string, expectedResources []schema.ResourceLink) (string, func())

func OnboardDevSimForClient

func OnboardDevSimForClient(ctx context.Context, t *testing.T, c pb.GrpcGatewayClient, clientID, deviceID, hubEndpoint string, expectedResources []schema.ResourceLink) (string, func())

func ProtobufToInterface

func ProtobufToInterface(t *testing.T, val interface{}) interface{}

func RequireToCheckFunc

func RequireToCheckFunc(checFunc func(t require.TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{})) func(t *testing.T, expected interface{}, actual interface{}, msgAndArgs ...interface{})

func ResourceIsBatchObservable

func ResourceIsBatchObservable(ctx context.Context, t *testing.T, deviceID, resourceURI, resourceType string) bool

func ResourceLinksToResourceIds

func ResourceLinksToResourceIds(deviceID string, s []schema.ResourceLink) []*commands.ResourceId

func ResourceLinksToResources

func ResourceLinksToResources(deviceID string, s []schema.ResourceLink) []*commands.Resource

func ResourceLinksToResources2

func ResourceLinksToResources2(deviceID string, s []schema.ResourceLink) []*pb.Resource

func SortResources

func SortResources(s commands.Resources) commands.Resources

func StringToApplicationProtocol added in v2.7.0

func StringToApplicationProtocol(p string) commands.Connection_Protocol

func TestResourceLightInstanceHref

func TestResourceLightInstanceHref(id string) string

func TestResourceSwitchesInstanceHref

func TestResourceSwitchesInstanceHref(id string) string

func WaitForDevice added in v2.3.1

func WaitForDevice(t *testing.T, client pb.GrpcGateway_SubscribeToEventsClient, deviceID, subID, correlationID string, expectedResources []schema.ResourceLink)

Types

type Option added in v2.5.0

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

Option interface used for setting optional sdkConfig properties.

func WithID added in v2.5.0

func WithID(id string) Option

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

func WithRootCA added in v2.6.0

func WithRootCA(certificate, key []byte) Option

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

func WithValidity added in v2.7.14

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.

Directories

Path Synopsis
coap-gateway
iotivity-lite
oauth-server
uri
pb
cmd
cmd

Jump to

Keyboard shortcuts

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