test

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: Apache-2.0 Imports: 41 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, href, 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 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() (*client.Client, error)

func OnboardDevSim

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

func OnboardDevSimForClient

func OnboardDevSimForClient(ctx context.Context, t *testing.T, c pb.GrpcGatewayClient, clientID, deviceID, gwHost 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, href, 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.Resource) []*commands.Resource

func TestResourceLightInstanceHref

func TestResourceLightInstanceHref(id string) string

func TestResourceSwitchesInstanceHref

func TestResourceSwitchesInstanceHref(id string) string

Types

type SortResourcesByHref

type SortResourcesByHref []*commands.Resource

func (SortResourcesByHref) Len

func (a SortResourcesByHref) Len() int

func (SortResourcesByHref) Less

func (a SortResourcesByHref) Less(i, j int) bool

func (SortResourcesByHref) Swap

func (a SortResourcesByHref) Swap(i, j int)

Directories

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

Jump to

Keyboard shortcuts

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