bddtests

package
v0.4.33 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: Apache-2.0 Imports: 54 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ADMIN = "admin"

ADMIN type

View Source
var USER = "user"

USER type

Functions

func FindPKCS11Lib added in v0.1.9

func FindPKCS11Lib(configuredLib string) string

FindPKCS11Lib find lib based on configuration

func GenerateRandomID

func GenerateRandomID() string

GenerateRandomID generates random ID

func GetByteArgs added in v0.1.2

func GetByteArgs(argsArray []string) [][]byte

GetByteArgs is a utility which converts []string to [][]bytes

func GetChannelAnchorTxPath

func GetChannelAnchorTxPath(channelID, orgName string) string

GetChannelAnchorTxPath returns path to the channel anchor tx file for the given channel

func GetChannelTxPath

func GetChannelTxPath(channelID string) string

GetChannelTxPath returns path to the channel tx file for the given channel

func GetVar added in v0.4.3

func GetVar(varName string) (string, bool)

GetVar gets the value for the given variable Returns true if the variable exists; false otherwise

func HasPrimaryPeerJoinedChannel

func HasPrimaryPeerJoinedChannel(channelID string, client *resmgmt.Client, orgUser mspApi.Identity, peer fabApi.Peer) (bool, error)

HasPrimaryPeerJoinedChannel checks whether the primary peer of a channel has already joined the channel. It returns true if it has, false otherwise, or an error

func IsChaincodeInstalled

func IsChaincodeInstalled(client *resmgmt.Client, peer fabApi.Peer, name string) (bool, error)

IsChaincodeInstalled Helper function to check if chaincode has been deployed

func NewChaincodePolicy added in v0.4.3

func NewChaincodePolicy(bddCtx *BDDContext, ccPolicy, channelID string) (*fabricCommon.SignaturePolicyEnvelope, error)

NewChaincodePolicy parses the policy string and returns the chaincode policy

func NewCollectionConfig added in v0.1.9

func NewCollectionConfig(collName string, requiredPeerCount, maxPeerCount int32, blocksToLive uint64, policy *common.SignaturePolicyEnvelope) *common.CollectionConfig

NewCollectionConfig return CollectionConfig

func Resolve added in v0.4.3

func Resolve(vars map[string]string, arg string) (string, error)

Resolve resolves all variables within the given arg

Example 1: Simple variable

Given:
	vars = {
		"var1": "value1",
		"var2": "value2",
		}
Then:
	"${var1}" = "value1"
	"X_${var1}_${var2} = "X_value1_value2

Example 2: Array variable

Given:
	vars = {
		"arr1": "value1,value2,value3",
		}
Then:
	"${arr1[0]_arr1[1]_arr1[2]}" = "value1_value2_value3"

func ResolveAll added in v0.4.3

func ResolveAll(vars map[string]string, args []string) ([]string, error)

func SetVar added in v0.4.3

func SetVar(varName, value string)

SetVar sets the value for the given variable

Types

type BDDContext

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

BDDContext ...

func NewBDDContext

func NewBDDContext(orgs []string, ordererOrgID string, clientConfigFilePath string, clientConfigFileName string,
	snapsConfigFilePath string, peersMspID map[string]string, testCCPath string, cliPath string) (*BDDContext, error)

NewBDDContext create new BDDContext

func (*BDDContext) AddPeerConfigToChannel added in v0.1.9

func (b *BDDContext) AddPeerConfigToChannel(pconfig *PeerConfig, channelID string)

AddPeerConfigToChannel adds a peer to a channel

func (*BDDContext) AfterScenario added in v0.1.9

func (b *BDDContext) AfterScenario(interface{}, error)

AfterScenario execute code after bdd scenario

func (*BDDContext) BeforeScenario added in v0.1.9

func (b *BDDContext) BeforeScenario(scenarioOrScenarioOutline interface{})

BeforeScenario execute code before bdd scenario

func (*BDDContext) ChannelCreated added in v0.1.11

func (b *BDDContext) ChannelCreated(channelID string) bool

ChannelCreated returns true if channel already created

func (*BDDContext) ClientConfig added in v0.1.9

func (b *BDDContext) ClientConfig() fabApi.EndpointConfig

ClientConfig returns client config

func (*BDDContext) CollectionConfig added in v0.1.9

func (b *BDDContext) CollectionConfig(coll string) CollectionConfigCreator

CollectionConfig returns the private data collection configuration creator for the given collection name. If the collection configuration does not exist then nil is returned.

func (*BDDContext) DefineCollectionConfig added in v0.1.9

func (b *BDDContext) DefineCollectionConfig(id string, creator CollectionConfigCreator)

DefineCollectionConfig defines a new collection configuration

func (*BDDContext) OrdererOrgID added in v0.1.10

func (b *BDDContext) OrdererOrgID() string

OrdererOrgID returns orderer org id

func (*BDDContext) OrgChannelClient added in v0.1.11

func (b *BDDContext) OrgChannelClient(org, userType, channelID string) (*channel.Client, error)

OrgChannelClient returns the org channel client

func (*BDDContext) OrgIDForChannel added in v0.1.10

func (b *BDDContext) OrgIDForChannel(channelID string) (string, error)

OrgIDForChannel returns a single org ID for the given channel or an error if no orgs are configured for the channel

func (*BDDContext) OrgUserContext added in v0.1.11

func (b *BDDContext) OrgUserContext(org, userType string) contextApi.Client

OrgUserContext returns the org user context

func (*BDDContext) Orgs added in v0.1.9

func (b *BDDContext) Orgs() []string

Orgs returns the orgs

func (*BDDContext) OrgsByChannel added in v0.1.9

func (b *BDDContext) OrgsByChannel(channelID string) []string

OrgsByChannel returns the orgs for the given channel

func (*BDDContext) PeerConfigForChannel added in v0.1.10

func (b *BDDContext) PeerConfigForChannel(channelID string) *PeerConfig

PeerConfigForChannel returns a single peer for the given channel or nil if no peers are configured for the channel

func (*BDDContext) PeerConfigForChannelAndMsp added in v0.2.0

func (b *BDDContext) PeerConfigForChannelAndMsp(channelID string, mspID string) *PeerConfig

PeerConfigForChannelAndMsp returns a single peer for the given channel and msp or nil if no peers are configured for the channel and msp

func (*BDDContext) PeerConfigForURL added in v0.2.0

func (b *BDDContext) PeerConfigForURL(url string) *PeerConfig

PeerConfigForURL returns the peer config for the given URL or nil if not found

func (*BDDContext) PeersByChannel added in v0.1.9

func (b *BDDContext) PeersByChannel(channelID string) []*PeerConfig

PeersByChannel returns the peers for the given channel

func (*BDDContext) ResMgmtClient added in v0.1.11

func (b *BDDContext) ResMgmtClient(org, userType string) *resmgmt.Client

ResMgmtClient returns the res mgmt client

func (*BDDContext) Sdk

func (b *BDDContext) Sdk() *fabsdk.FabricSDK

Sdk return sdk instance

func (*BDDContext) SetServiceProviderFactory added in v0.2.0

func (b *BDDContext) SetServiceProviderFactory(factory sdkApi.ServiceProviderFactory)

SetServiceProviderFactory sets the service provider factory for the test

type CollectionConfig added in v0.1.9

type CollectionConfig struct {
	Name              string
	Policy            string
	RequiredPeerCount int32
	MaxPeerCount      int32
	BlocksToLive      uint64
}

CollectionConfig contains the private data collection config

type CollectionConfigCreator added in v0.4.3

type CollectionConfigCreator func(channelID string) (*common.CollectionConfig, error)

CollectionConfigCreator creates a collection config for the given channel

type CommonSteps

type CommonSteps struct {
	BDDContext *BDDContext
}

CommonSteps contain BDDContext

func NewCommonSteps

func NewCommonSteps(context *BDDContext) *CommonSteps

NewCommonSteps create new CommonSteps struct

func (*CommonSteps) DefineCollectionConfig added in v0.4.3

func (d *CommonSteps) DefineCollectionConfig(id, name, policy string, requiredPeerCount, maxPeerCount int32, blocksToLive uint64)

DefineCollectionConfig defines a new private data collection configuration

func (*CommonSteps) InvokeCCWithArgs added in v0.1.9

func (d *CommonSteps) InvokeCCWithArgs(ccID, channelID string, targets []*PeerConfig, args []string, transientData map[string][]byte) (channel.Response, error)

InvokeCCWithArgs invoke cc with args as regular user

func (*CommonSteps) InvokeCCWithArgsAsAdmin added in v0.2.5

func (d *CommonSteps) InvokeCCWithArgsAsAdmin(ccID, channelID string, targets []*PeerConfig, args []string, transientData map[string][]byte) (channel.Response, error)

InvokeCCWithArgsAsAdmin invoke cc with args as admin user type

func (*CommonSteps) InvokeCConOrg added in v0.1.9

func (d *CommonSteps) InvokeCConOrg(ccID, args, orgIDs, channelID string) error

InvokeCConOrg invoke cc on org

func (*CommonSteps) OrgPeers added in v0.1.9

func (d *CommonSteps) OrgPeers(orgIDs, channelID string) []*PeerConfig

OrgPeers return array of PeerConfig

func (*CommonSteps) QueryCCWithArgs added in v0.1.9

func (d *CommonSteps) QueryCCWithArgs(systemCC bool, ccID, channelID string, args []string, transientData map[string][]byte, targets ...*PeerConfig) (string, error)

QueryCCWithArgs ...

func (*CommonSteps) QueryCCWithOpts added in v0.1.11

func (d *CommonSteps) QueryCCWithOpts(systemCC bool, ccID, channelID string, args []string, timeout time.Duration, concurrent bool, interval time.Duration, transientData map[string][]byte, targets ...*PeerConfig) (string, error)

QueryCCWithOpts ...

func (*CommonSteps) RegisterSteps added in v0.1.9

func (d *CommonSteps) RegisterSteps(s *godog.Suite)

RegisterSteps register steps

type Composition

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

Composition represents a docker-compose execution and management

func NewComposition

func NewComposition(projectName string, composeFilesYaml string, dir string) (composition *Composition, err error)

NewComposition create a new Composition specifying the project name (for isolation) and the compose files.

func (*Composition) Decompose

func (c *Composition) Decompose(dir string) (output string, err error)

Decompose decompose the composition. Will also remove any containers with the same projectName prefix (eg. chaincode containers)

func (*Composition) GenerateLogs

func (c *Composition) GenerateLogs(dir string) error

GenerateLogs to file

func (*Composition) GetAPIContainerForComposeService

func (c *Composition) GetAPIContainerForComposeService(composeService string) (apiContainer *docker.APIContainers, err error)

GetAPIContainerForComposeService return the docker.APIContainers with the supplied composeService name.

func (*Composition) GetContainerIDs

func (c *Composition) GetContainerIDs(dir string) (containerIDs []string, err error)

GetContainerIDs returns the container IDs for the composition (NOTE: does NOT include those defined outside composition, eg. chaincode containers)

func (*Composition) GetIPAddressForComposeService

func (c *Composition) GetIPAddressForComposeService(composeService string) (ipAddress string, err error)

GetIPAddressForComposeService returns the IPAddress of the container with the supplied composeService name.

type ConfigCLI added in v0.2.0

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

ConfigCLI is used to invoke the Config CLI command-line tool

func NewConfigCLI added in v0.2.0

func NewConfigCLI(binaryPath, clientconfig, user string) *ConfigCLI

NewConfigCLI returns a new NewConfigCLI

func (*ConfigCLI) Exec added in v0.2.0

func (cli *ConfigCLI) Exec(action, channelID, mspID, peerID, appName, appVersion, compName, compVersion string) (string, error)

Exec executes the config-cli action with the given args and returns a response

func (*ConfigCLI) ExecUpdate added in v0.2.0

func (cli *ConfigCLI) ExecUpdate(channelID, mspID, org, configFile, peers string) (string, error)

ExecUpdate executes config-cli update with the given args and returns a response

type ConfigCLISteps added in v0.2.0

type ConfigCLISteps struct {
	BDDContext *BDDContext
}

ConfigCLISteps config cli BDD test steps

func NewConfigCLISteps added in v0.2.0

func NewConfigCLISteps(context *BDDContext) *ConfigCLISteps

NewConfigCLISteps new config cli steps

func (*ConfigCLISteps) RegisterSteps added in v0.2.0

func (c *ConfigCLISteps) RegisterSteps(s *godog.Suite)

RegisterSteps register steps

func (*ConfigCLISteps) UpdateConfig added in v0.2.0

func (c *ConfigCLISteps) UpdateConfig(configFile, mspID, orgID, channelID string) error

UpdateConfig update config using config cli

func (*ConfigCLISteps) UpdateConfigWithExceptions added in v0.4.3

func (c *ConfigCLISteps) UpdateConfigWithExceptions(configFile, mspID, orgID, channelID, blackListRegex string) error

UpdateConfigWithExceptions updates config using config cli

type ConfigurationsSnapSteps added in v0.1.9

type ConfigurationsSnapSteps struct {
	BDDContext *BDDContext
}

ConfigurationsSnapSteps ...

func NewConfigurationsSnapSteps added in v0.1.9

func NewConfigurationsSnapSteps(context *BDDContext) *ConfigurationsSnapSteps

NewConfigurationsSnapSteps ...

type CustomEndorsementHandler added in v0.1.11

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

CustomEndorsementHandler ignores the channel in the ClientContext and instead sends the proposal to the given channel

func NewCustomEndorsementHandler added in v0.1.11

func NewCustomEndorsementHandler(context contextApi.Client, next invoke.Handler) *CustomEndorsementHandler

NewCustomEndorsementHandler creates a new instance of CustomEndorsementHandler

func (*CustomEndorsementHandler) Handle added in v0.1.11

func (h *CustomEndorsementHandler) Handle(requestContext *invoke.RequestContext, clientContext *invoke.ClientContext)

Handle handles an endorsement proposal

type DockerHelper

type DockerHelper interface {
	GetIPAddress(containerID string) (string, error)
	RemoveContainersWithNamePrefix(namePrefix string) error
}

DockerHelper helper for docker specific functions

func NewDockerCmdlineHelper

func NewDockerCmdlineHelper() (DockerHelper, error)

NewDockerCmdlineHelper returns a new command line DockerHelper instance

type EventSnapSteps added in v0.1.2

type EventSnapSteps struct {
	BDDContext *BDDContext
}

EventSnapSteps ...

func NewEventSnapSteps added in v0.1.2

func NewEventSnapSteps(context *BDDContext) *EventSnapSteps

NewEventSnapSteps ...

type FabCLI added in v0.1.10

type FabCLI struct {
}

FabCLI is used to invoke the Fabric CLI command-line tool

func NewFabCLI added in v0.1.10

func NewFabCLI() *FabCLI

NewFabCLI returns a new FabCLI

func (*FabCLI) Exec added in v0.1.10

func (cli *FabCLI) Exec(args ...string) (string, error)

Exec executes the fabric-cli with the given args and returns a response

func (*FabCLI) GetJSON added in v0.1.10

func (cli *FabCLI) GetJSON(args ...string) (string, error)

GetJSON executes the fabric-cli with the given args and returns a JSON response

type PeerConfig added in v0.1.9

type PeerConfig struct {
	OrgID  string
	Config fabApi.PeerConfig
	MspID  string
	PeerID string
}

PeerConfig holds the peer configuration and org ID

type StaticSelectionProviderFactory added in v0.2.0

type StaticSelectionProviderFactory struct {
	defsvc.ProviderFactory
}

StaticSelectionProviderFactory uses a static selection service that doesn't use CC policies. (Required for System CC invocations.)

func (*StaticSelectionProviderFactory) CreateChannelProvider added in v0.2.0

func (f *StaticSelectionProviderFactory) CreateChannelProvider(config fabApi.EndpointConfig, opts ...options.Opt) (fabApi.ChannelProvider, error)

CreateChannelProvider creates a mock ChannelProvider

type UnsafeQuerySteps added in v0.1.11

type UnsafeQuerySteps struct {
	BDDContext *BDDContext
}

UnsafeQuerySteps unsafe query BDD test steps

func NewUnsafeQuerySteps added in v0.1.11

func NewUnsafeQuerySteps(context *BDDContext) *UnsafeQuerySteps

NewUnsafeQuerySteps new unsafe query steps

func (*UnsafeQuerySteps) InvokeCCVerifyResponse added in v0.1.11

func (u *UnsafeQuerySteps) InvokeCCVerifyResponse(ccID, userArgs, orgIDs, channelID, expectedResponse string) error

InvokeCCVerifyResponse invoke CC and verify unsafe query operation

Jump to

Keyboard shortcuts

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