test

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package test contains helper functions for unit testing.

Index

Constants

This section is empty.

Variables

View Source
var (
	Resource1 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "pFlpMtkWqCPXVue",
			Type:       "Asset",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource2 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "pFlpMtkWqCPXVue",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource3 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "pFlpMtkWqCPXVue",
			Type:       "Asset",
			Actions:    []string{"DEMANDS"},
		},
	}

	Resource4 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "QovektcrVBbNmFj",
			Type:       "Asset",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource5 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "HQKzkgPnGJDiaGo",
			Type:       "Asset",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource6 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "XcbZruEzGNYHLic",
			Type:       "Asset",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource7 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "zIDegSbXcRlBeFZ",
			Type:       "Asset",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource8 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "paLtQSpEcTvzeuC",
			Type:       "Asset",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	Resource9 = []*authorizationpb.IsAuthorizedRequest_Resource{
		{
			ExternalId: "pFlpMtkWqCPXVue",
			Type:       "Asset",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
		{
			ExternalId: "HQKzkgPnGJDiaGo",
			Type:       "Asset",
			Actions:    []string{"SUBSCRIBES_TO"},
		},
	}

	ResourceType1 = []*authorizationpb.WhatAuthorizedRequest_ResourceType{
		{Type: "Asset", Actions: []string{"SUBSCRIBES_TO"}},
	}

	ResourceType2 = []*authorizationpb.WhatAuthorizedRequest_ResourceType{
		{Actions: []string{"SUBSCRIBES_TO", "OWNS"}},
	}

	ResourceType3 = []*authorizationpb.WhatAuthorizedRequest_ResourceType{
		{Type: "Asset", Actions: []string{"DEMANDS"}},
	}

	ResourceWho1 = []*authorizationpb.WhoAuthorizedRequest_Resource{
		{ExternalId: "pFlpMtkWqCPXVue", Type: "Asset", Actions: []string{"SUBSCRIBES_TO", "OWNS"}},
	}

	ResourceWho2 = []*authorizationpb.WhoAuthorizedRequest_Resource{
		{Type: "Asset", Actions: []string{"SUBSCRIBES_TO", "OWNS"}},
	}

	ResourceWho3 = []*authorizationpb.WhoAuthorizedRequest_Resource{
		{ExternalId: "pFlpMtkWqCPXVue", Type: "Asset", Actions: []string{"DEMANDS", "REPELS"}},
	}

	DigitalTwinBad     = "id"
	DigitalTwinNotInDB = "gid:AAAAGaiIPzg6L0DKkbIh22crsFg"
	DigitalTwin1       = "gid:AAAAFdrC00gBhkvelHM0OQO-u4U"
	DigitalTwin2       = "gid:AAAAFb3lFaaArUVYqk9VdY1Ct1Y"

	EmailBad   = "test@example.com"
	EmailGood  = "biche@yahoo.uk"
	EmailGood2 = "darna@yahoo.uk"

	ExternalIDGood = "TrSFiLuoSLGiCIo"

	Asset1 = "HQKzkgPnGJDiaGo"
	Asset2 = "pFlpMtkWqCPXVue"
	Asset3 = "zojWwtKbBLmAXCO"
	Asset4 = "paLtQSpEcTvzeuC"
	Asset5 = "dLZVTSllFCdZfXC"

	Subject1 = "dilZWYdFcmXiojC"
	Subject2 = "fVcaUxJqmOkyOTX"
	Subject3 = "lSPmCXIPRXppszf"
	Subject4 = "NACTFFKUCcceDIz"

	// TokenGoodFormat is a valid format for jwt.
	TokenGoodFormat = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9." +
		"eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9." +
		"dyt0CoTl4WoVjAHI9Q_CwSKhl6d_9rhM3NrXuJttkao" // #nosec G101
	TokenBad = "token_invalid_format"
)

Functions

func BeBase64

func BeBase64() types.GomegaMatcher

BeBase64 match string if it is Base64 Standard encoded.

func CreateRecordNoProperty added in v0.23.0

func CreateRecordNoProperty(externalID, nodeType string) *ingestpb.Record

func CreateRecordNodeIndividual added in v0.23.0

func CreateRecordNodeIndividual(
	role string) (*ingestpb.Record, string)

func CreateRecordRelationship added in v0.23.0

func CreateRecordRelationship(
	sourceExternalID string,
	sourceType string,
	targetExternalID string,
	targetType string,
	relationType string) *ingestpb.Record

func CreateRecordResourceNoProperty added in v0.23.0

func CreateRecordResourceNoProperty(externalID, nodeType string) *ingestpb.Record

func DeleteRecord added in v0.18.0

func DeleteRecord(externalID, nodeType string) *ingestpb.Record

func DeleteRecordRelationship added in v0.23.0

func DeleteRecordRelationship(relationship *ingestpb.Relationship) *ingestpb.Record

func DeleteRecordRelationshipProperty added in v0.23.0

func DeleteRecordRelationshipProperty(
	sourceExternalID string,
	sourceType string,
	targetExternalID string,
	targetType string,
	typeRelation string,
	propertyType string) *ingestpb.Record

func DeleteRecordWithProperty added in v0.23.0

func DeleteRecordWithProperty(externalID, nodeType, property string) *ingestpb.Record

func EqualAnyProto

func EqualAnyProto(expected protoreflect.ProtoMessage) types.GomegaMatcher

EqualAnyProto uses proto.Equal to compare actual with expected. Equal is strict about types when performing comparisons. It is an error for both actual and expected to be nil. Use BeNil() instead.

func EqualProto

func EqualProto(expected protoreflect.ProtoMessage) types.GomegaMatcher

EqualProto uses proto.Equal to compare actual with expected. Equal is strict about types when performing comparisons. It is an error for both actual and expected to be nil. Use BeNil() instead.

func GenerateRandomString added in v0.18.0

func GenerateRandomString(length int) string

func GetRelationship added in v0.23.0

func GetRelationship(
	sourceExternalID string,
	sourceType string,
	targetExternalID string,
	targetType string,
	relationType string) *ingestpb.Relationship

func InitConfigAuthorization added in v0.18.0

func InitConfigAuthorization() (*authorization.Client, error)

InitConfigAuthorization reads in config file and ENV variables if set.

func InitConfigConfig added in v0.25.0

func InitConfigConfig() (*config.Client, error)

InitConfigConfig file and ENV variables if set.

func InitConfigIngest added in v0.18.0

func InitConfigIngest() (*ingest.Client, error)

InitConfigIngest reads in ingest file and ENV variables if set.

func InitConfigIngestRetry added in v0.18.0

func InitConfigIngestRetry() (*ingest.RetryClient, error)

InitConfigIngestRetry reads in ingest file and ENV variables if set.

func MatchErrorCode

func MatchErrorCode(errorCode codes.Code) types.GomegaMatcher

MatchErrorCode succeeds if actual is a non-nil error that has the code the passed in error.

Error must be google.golang.org/grpc/status.Error It is an error for err to be nil or an object that does not implement the Error interface.

func MatchJSON

func MatchJSON(expected any) types.GomegaMatcher

MatchJSON uses the expected value to build a value matcher.

func MatchProtoMessage

func MatchProtoMessage(message proto.Message) types.GomegaMatcher

MatchProtoMessage succeeds if.

func MatchStatusError

func MatchStatusError(errorCode codes.Code, msg any) types.GomegaMatcher

MatchStatusError succeeds if actual is a non-nil error that has the code the passed in error.

Error must be google.golang.org/grpc/status.Error It is an error for err to be nil or an object that does not implement the Error interface.

func UpsertRecordNodeAsset added in v0.23.0

func UpsertRecordNodeAsset() (*ingestpb.Record, string)

func WrapMatcher added in v0.14.0

func WrapMatcher(matcher types.GomegaMatcher) gomock.Matcher

Types

type EqualAnyProtoMatcher

type EqualAnyProtoMatcher struct {
	Expected proto.Message
	// contains filtered or unexported fields
}

func (*EqualAnyProtoMatcher) FailureMessage

func (matcher *EqualAnyProtoMatcher) FailureMessage(any) string

func (*EqualAnyProtoMatcher) Match

func (matcher *EqualAnyProtoMatcher) Match(actual any) (bool, error)

func (*EqualAnyProtoMatcher) NegatedFailureMessage

func (matcher *EqualAnyProtoMatcher) NegatedFailureMessage(any) string

type EqualProtoMatcher

type EqualProtoMatcher struct {
	Expected proto.Message
}

func (*EqualProtoMatcher) FailureMessage

func (matcher *EqualProtoMatcher) FailureMessage(actual any) string

func (*EqualProtoMatcher) GomegaString

func (matcher *EqualProtoMatcher) GomegaString() string

func (*EqualProtoMatcher) Match

func (matcher *EqualProtoMatcher) Match(actual any) (bool, error)

func (*EqualProtoMatcher) NegatedFailureMessage

func (matcher *EqualProtoMatcher) NegatedFailureMessage(actual any) string

type MatchJSONMatcher

type MatchJSONMatcher struct {
	types.GomegaMatcher
}

func (*MatchJSONMatcher) Match

func (matcher *MatchJSONMatcher) Match(actual any) (bool, error)

type MatchProtoMessageMatcher

type MatchProtoMessageMatcher struct {
	Expected proto.Message
}

func (*MatchProtoMessageMatcher) FailureMessage

func (matcher *MatchProtoMessageMatcher) FailureMessage(actual any) string

func (*MatchProtoMessageMatcher) Match

func (matcher *MatchProtoMessageMatcher) Match(actual any) (bool, error)

func (*MatchProtoMessageMatcher) NegatedFailureMessage

func (matcher *MatchProtoMessageMatcher) NegatedFailureMessage(actual any) string

type MatchSDKStatusErrorMatcher

type MatchSDKStatusErrorMatcher struct {
	Expected codes.Code
	// contains filtered or unexported fields
}

func (*MatchSDKStatusErrorMatcher) FailureMessage

func (matcher *MatchSDKStatusErrorMatcher) FailureMessage(actual any) string

func (*MatchSDKStatusErrorMatcher) Match

func (matcher *MatchSDKStatusErrorMatcher) Match(actual any) (bool, error)

func (*MatchSDKStatusErrorMatcher) NegatedFailureMessage

func (matcher *MatchSDKStatusErrorMatcher) NegatedFailureMessage(actual any) string

Directories

Path Synopsis
authorization
v1beta1
Package authorization is a generated GoMock package.
Package authorization is a generated GoMock package.
config
v1beta1
Package config is a generated GoMock package.
Package config is a generated GoMock package.
identity
v1beta2
Package identity is a generated GoMock package.
Package identity is a generated GoMock package.
ingest
v1beta2
Package ingest is a generated GoMock package.
Package ingest is a generated GoMock package.
v1beta3
Package ingest is a generated GoMock package.
Package ingest is a generated GoMock package.
knowledge
v1beta1
Package knowledge is a generated GoMock package.
Package knowledge is a generated GoMock package.
v1beta2
Package knowledge is a generated GoMock package.
Package knowledge is a generated GoMock package.
tda
v1beta1
Package tda is a generated GoMock package.
Package tda is a generated GoMock package.

Jump to

Keyboard shortcuts

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