def step_impl(context, userName, anchorSetName):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=userName)
    nodeAdminTuples = [directory.findNodeAdminTuple(row['User'], row['Peer'], row['Organization']) for row in
                       context.table.rows]
    user.setTagValue(anchorSetName,
                     bootstrap_util.getAnchorPeersConfigGroup(context=context, nodeAdminTuples=nodeAdminTuples))
def step_impl(context, userName, create_channel_config_update_name, consortium_name):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName)
    consortium_config_group = user.getTagValue(tagKey=consortium_name)

    peer_org_set = user.getTagValue(tagKey=context.table.rows[0]["PeerOrgSet"])
    peer_anchor_set_tag_key = context.table.rows[0]["[PeerAnchorSet]"]
    peer_anchor_config_group = None
    if peer_anchor_set_tag_key != "":
        peer_anchor_config_group = user.getTagValue(tagKey=peer_anchor_set_tag_key)

    channel_id = context.table.rows[0]["ChannelID"]
    # Loop through templates referenced orgs
    # mspOrgNames = [org.name for org in user.tags[templateName]]
    # TODO: Where does the system_channel_version come from?
    system_channel_version = 0
    channel_config_update = bootstrap_util.create_channel_config_update(system_channel_version, channel_id,
                                                                        consortium_config_group)

    # Add the anchors config group
    if peer_anchor_config_group:
        bootstrap_util.merge_config_groups(channel_config_update.write_set, peer_anchor_config_group)

    # Make sure orgs exist in consortium
    for orgName in peer_org_set:
        assert orgName in channel_config_update.write_set.groups[
            'Application'].groups.keys(), "PeerOrgSet entry {0} not found in consortium".format(orgName)

    # Strip out any organizations that are NOT referenced in peerOrgSet
    for orgName in channel_config_update.write_set.groups['Application'].groups.keys():
        if not orgName in peer_org_set:
            del (channel_config_update.read_set.groups['Application'].groups[orgName])
            del (channel_config_update.write_set.groups['Application'].groups[orgName])

    user.setTagValue(create_channel_config_update_name, channel_config_update)
Exemple #3
0
def step_impl(context, userName, createChannelSignedConfigEnvelope):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName)
    ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context)

    muralisRequiredSignedConfigItems = []

    channelID = context.table.rows[0]["ChannelID"]
    chainCreationPolicyName = context.table.rows[0][
        "Chain Creation Policy Name"]

    # Intermediate step until template tool is ready
    signedConfigItems = bootstrap_util.createSignedConfigItems(
        context,
        channelID,
        "solo",
        signedConfigItems=muralisRequiredSignedConfigItems)

    #NOTE: Conidered passing signing key for appDeveloper, but decided that the peer org signatures they need to collect subsequently should be proper way
    signedConfigEnvelope = bootstrap_util.signInitialChainConfig(
        signedConfigItems=signedConfigItems,
        chainId=channelID,
        chainCreationPolicyName=chainCreationPolicyName)

    user.tags[createChannelSignedConfigEnvelope] = ChannelCreationInfo(
        channelID, chainCreationPolicyName, signedConfigEnvelope)
Exemple #4
0
def step_impl(context, userName, createChannelSignedConfigEnvelope):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName)
    ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context)

    channelID = context.table.rows[0]["ChannelID"]
    chainCreationPolicyName = context.table.rows[0][
        "Chain Creation Policy Name"]
    templateName = context.table.rows[0]["Template"]
    # Loop through templates referenced orgs
    mspOrgNames = [org.name for org in user.tags[templateName]]
    signedMspConfigItems = bootstrap_util.getSignedMSPConfigItems(
        context=context, orgNames=mspOrgNames)

    # Add the anchors signed config Items
    anchorSignedConfigItemsName = context.table.rows[0]["Anchors"]
    signedAnchorsConfigItems = user.tags[anchorSignedConfigItemsName]

    # Intermediate step until template tool is ready
    channel_config_groups = bootstrap_util.createSignedConfigItems(
        directory,
        configGroups=signedMspConfigItems + signedAnchorsConfigItems)

    # bootstrap_util.setMetaPolicy(channelId=channelID, channgel_config_groups=channgel_config_groups)

    #NOTE: Conidered passing signing key for appDeveloper, but decided that the peer org signatures they need to collect subsequently should be proper way
    config_update_envelope = bootstrap_util.createConfigUpdateEnvelope(
        channelConfigGroup=channel_config_groups,
        chainId=channelID,
        chainCreationPolicyName=chainCreationPolicyName)

    user.setTagValue(createChannelSignedConfigEnvelope, config_update_envelope)
Exemple #5
0
def step_impl(context, userName, proposalResponseName, proposalResponseResultCode):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=userName)
    proposalResponse = user.tags[proposalResponseName]
    print("ProposalResponse: \n{0}\n".format(proposalResponse))
    print("")
    raise NotImplementedError(u'STEP: Then user "dev0Org0" expects result code for "joinChannelResult" of "200"')
Exemple #6
0
def step_impl(context, userName, chaincodeInvocationSpecName, templateSpecName):
    directory = bootstrap_util.getDirectory(context=context)
    user = directory.getUser(userName)
    args =  bootstrap_util.getArgsFromContextForUser(context, userName)
    template_chaincode_spec = user.tags[templateSpecName]
    cc_invocation_spec =  endorser_util.getChaincodeSpecUsingTemplate(template_chaincode_spec=template_chaincode_spec, args=bdd_grpc_util.toStringArray(args))
    user.setTagValue(chaincodeInvocationSpecName, cc_invocation_spec)
Exemple #7
0
def step_impl(context, ordererSystemChainIdName, mspConfigItemsName):
    assert 'table' in context, "Expected table of policy names"
    directory = bootstrap_util.getDirectory(context)
    ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context)
    ordererSystemChainIdGUUID = ordererBootstrapAdmin.tags[ordererSystemChainIdName]
    mspSignedConfigItems = bootstrap_util.getMspConfigItemsForPolicyNames(context, chainId=ordererSystemChainIdGUUID, policyNames=[row['PolicyName'] for row in context.table.rows])
    ordererBootstrapAdmin.tags[mspConfigItemsName] = mspSignedConfigItems
def step_impl(context, user_name, cert_alias, org_name, channel_id, compose_service):
    directory = bootstrap_util.getDirectory(context)
    requesting_config_admin = directory.getUser(userName=user_name)
    requesting_config_admin_nat = requesting_config_admin.tags[cert_alias]
    signing_nats = [directory.getUser(row['User']).getTagValue(row['Cert Alias']) for row in context.table.rows]
    bootstrap_util.add_org_to_channel(context, directory, requesting_config_admin_nat, signing_nats,
                                      directory.getOrganization(org_name), channel_id)
def step_impl(context, user_name, function, alias_target, alias_result):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=user_name)
    target = user.getTagValue(alias_target)
    result = None
    exec ('result = target.{0}'.format(function))
    user.setTagValue(tagKey=alias_result, tagValue=result)
Exemple #10
0
def step_impl(context, userName, transactionAlias, proposalAlias, proposalResponseAlias, channelId):
    directory = bootstrap_util.getDirectory(context=context)
    user = directory.getUser(userName)
    proposalResponsesDict = user.tags[proposalResponseAlias]
    proposal = user.tags[proposalAlias]
    signedTx = endorser_util.createSignedTx(user, proposal, proposalResponsesDict.values())
    user.setTagValue(transactionAlias, signedTx)
Exemple #11
0
def step_impl(context, userName, certAlias, proposalAlias, ccSpecAlias):
    channelName = ""
    directory = bootstrap_util.getDirectory(context=context)
    user = directory.getUser(userName=userName)
    assert ccSpecAlias in user.tags, "ChaincodeSpec alias '{0}' not found for user '{1}'".format(
        ccSpecAlias, userName)
    ccSpec = user.tags[ccSpecAlias]

    ccDeploymentSpec = endorser_util.createDeploymentSpec(context=context,
                                                          ccSpec=ccSpec)
    lcChaincodeSpec = endorser_util.createInstallChaincodeSpecForBDD(
        ccDeploymentSpec=ccDeploymentSpec, chainID=str(channelName))
    # Find the cert using the cert tuple information saved for the user under certAlias
    nodeAdminTuple = user.tags[certAlias]
    signersCert = directory.findCertForNodeAdminTuple(nodeAdminTuple)
    mspID = nodeAdminTuple.organization

    proposal = endorser_util.createInvokeProposalForBDD(
        context,
        ccSpec=lcChaincodeSpec,
        chainID=channelName,
        signersCert=signersCert,
        Mspid=mspID,
        type="ENDORSER_TRANSACTION")

    signedProposal = endorser_util.signProposal(proposal=proposal,
                                                entity=user,
                                                signersCert=signersCert)

    # proposal = endorser_util.createDeploymentProposalForBDD(ccDeploymentSpec)
    assert not proposalAlias in user.tags, "Proposal alias '{0}' already exists for '{1}'".format(
        proposalAlias, userName)
    user.setTagValue(proposalAlias, signedProposal)
Exemple #12
0
    def __init__(self, contextHelper, scenario):
        self.contextHelper = contextHelper
        self.directory = getDirectory(contextHelper.context)
        self.output = StringIO()
        self.currentStep = 0
        self.composition = None

        #Weave advices into contextHelper
        weave(target=self.contextHelper.before_step,
              advices=self.beforeStepAdvice)
        weave(target=self.contextHelper.after_step,
              advices=self.afterStepAdvice)
        weave(target=self.contextHelper.after_scenario,
              advices=self.afterScenarioAdvice)
        weave(target=self.contextHelper.getBootrapHelper,
              advices=self.getBootstrapHelperAdvice)
        weave(target=self.contextHelper.registerComposition,
              advices=self.registerCompositionAdvice)

        # Weave advices into Directory
        weave(target=self.directory._registerOrg,
              advices=self.registerOrgAdvice)
        weave(target=self.directory._registerUser,
              advices=self.registerUserAdvice)
        weave(target=self.directory.registerOrdererAdminTuple,
              advices=self.registerNamedNodeAdminTupleAdvice)
Exemple #13
0
def step_impl(context, userName, create_channel_config_update_name, consortium_name):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName)
    consortium_config_group = user.getTagValue(tagKey=consortium_name)

    peer_org_set = user.getTagValue(tagKey=context.table.rows[0]["PeerOrgSet"])
    peer_anchor_set_tag_key = context.table.rows[0]["[PeerAnchorSet]"]
    peer_anchor_config_group = None
    if peer_anchor_set_tag_key != "":
        peer_anchor_config_group = user.getTagValue(tagKey=peer_anchor_set_tag_key)

    channel_id = context.table.rows[0]["ChannelID"]
    # Loop through templates referenced orgs
    # mspOrgNames = [org.name for org in user.tags[templateName]]
    #TODO: Where does the system_channel_version come from?
    system_channel_version = 0
    channel_config_update = bootstrap_util.create_channel_config_update(system_channel_version, channel_id, consortium_config_group)

    # Add the anchors config group
    if peer_anchor_config_group:
        bootstrap_util.mergeConfigGroups(channel_config_update.write_set, peer_anchor_config_group)

    #Make sure orgs exist in consortium
    for orgName in peer_org_set:
        assert orgName in channel_config_update.write_set.groups['Application'].groups.keys(), "PeerOrgSet entry {0} not found in consortium".format(orgName)

    # Strip out any organizations that are NOT referenced in peerOrgSet
    for orgName in channel_config_update.write_set.groups['Application'].groups.keys():
        if not orgName in peer_org_set:
            del(channel_config_update.read_set.groups['Application'].groups[orgName])
            del(channel_config_update.write_set.groups['Application'].groups[orgName])

    user.setTagValue(create_channel_config_update_name, channel_config_update)
Exemple #14
0
def step_impl(context):
    assert 'table' in context, "Expected table with triplet of Developer/ChainCreationPolicyName/Organization"
    directory = bootstrap_util.getDirectory(context)
    for row in context.table.rows:
        directory.registerOrdererAdminTuple(row['Developer'],
                                            row['ChainCreationPolicyName'],
                                            row['Organization'])
Exemple #15
0
def step_impl(context, userName, configUpdateEnvelopeName, configUpdateName):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName)
    config_update_envelope = bootstrap_util.create_config_update_envelope(
        config_update=user.getTagValue(configUpdateName))
    user.setTagValue(tagKey=configUpdateEnvelopeName,
                     tagValue=config_update_envelope)
Exemple #16
0
def step_impl(context, certAlias, ordererGenesisBlockName, ordererSystemChainIdName, composeFile, consensusType, consortiumsModPolicy):
    directory = bootstrap_util.getDirectory(context=context)
    ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context)
    ordererSystemChainIdGUUID = ordererBootstrapAdmin.tags[ordererSystemChainIdName]
    # Now collect the named signed config items
    configGroups =[bootstrap_util.getDefaultConsortiumGroup(consortiumsModPolicy)]
    for row in context.table.rows:
        configGroupName = row['Consortium']
        configGroups += ordererBootstrapAdmin.tags[configGroupName]
    # Concatenate signedConfigItems

    service_names = compose.Composition(context, composeFilesYaml=composeFile, register_and_up=False).getServiceNames()

    # Construct block
    nodeAdminTuple = ordererBootstrapAdmin.tags[certAlias]
    bootstrapCert = directory.findCertForNodeAdminTuple(nodeAdminTuple=nodeAdminTuple)
    (genesisBlock, envelope, genesis_block_channel_config) = bootstrap_util.createGenesisBlock(context=context,
                                                                                               service_names=service_names,
                                                                                               chainId=ordererSystemChainIdGUUID,
                                                                                               consensusType=consensusType,
                                                                                               nodeAdminTuple=nodeAdminTuple,
                                                                                               signedConfigItems=configGroups)
    ordererBootstrapAdmin.setTagValue(ordererGenesisBlockName + "_genesis_channel_config", genesis_block_channel_config)
    ordererBootstrapAdmin.setTagValue(ordererGenesisBlockName, genesisBlock)
    ordererBootstrapAdmin.setTagValue("ConsensusType", consensusType)
    bootstrap_util.OrdererGensisBlockCompositionCallback(context, genesisBlock)
    bootstrap_util.PeerCompositionCallback(context)
Exemple #17
0
def step_impl(context, userName, latest_config_name, service_name, channel_id_name):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=userName)
    streamHelper = user.getDelivererStreamHelper(context, service_name)
    latest_config_block = bootstrap_util.get_latest_configuration_block(deliverer_stream_helper=streamHelper, channel_id=user.getTagValue(channel_id_name))
    channel_group = bootstrap_util.get_channel_group_from_config_block(latest_config_block)
    user.setTagValue(tagKey=latest_config_name, tagValue=channel_group)
def step_impl(context, userName, certAlias, composeService, port):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=userName)
    user.connectToDeliverFunction(context,
                                  composeService,
                                  nodeAdminTuple=user.tags[certAlias],
                                  port=port)
def step_impl(context, user_name, existing_channel_config_update_name,
              input_config_update_name):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(user_name)

    input_config_update = user.getTagValue(tagKey=input_config_update_name)

    channel_id = context.table.rows[0]["ChannelID"]

    peer_anchor_set_tag_key = context.table.rows[0]["[PeerAnchorSet]"]
    peer_anchor_config_group = None
    if peer_anchor_set_tag_key != "":
        peer_anchor_config_group = user.getTagValue(
            tagKey=peer_anchor_set_tag_key)

    assert peer_anchor_config_group != None, "Required to specify a PeerAnchorSet for now"
    #TODO: Where does the system_channel_version come from?
    system_channel_version = 0
    channel_config_update = bootstrap_util.create_existing_channel_config_update(
        system_channel_version=system_channel_version,
        channel_id=channel_id,
        input_config_update=input_config_update,
        config_groups=[peer_anchor_config_group])

    user.setTagValue(existing_channel_config_update_name,
                     channel_config_update)
Exemple #20
0
def step_impl(context, userName, certAlias, proposalAlias, timeout,
              proposalResponsesAlias):
    assert 'table' in context, "Expected table of endorsers"
    directory = bootstrap_util.getDirectory(context=context)
    user = directory.getUser(userName=userName)

    assert proposalAlias in user.tags, "Proposal alias '{0}' not found for user '{1}'".format(
        proposalAlias, userName)
    signedProposal = user.tags[proposalAlias]

    # Send proposal to each specified endorser, waiting 'timeout' seconds for response/error
    endorsers = [row['Endorser'] for row in context.table.rows]
    nodeAdminTuple = user.tags[certAlias]

    endorserStubs = endorser_util.getEndorserStubs(
        context,
        composeServices=endorsers,
        directory=directory,
        nodeAdminTuple=nodeAdminTuple)
    proposalResponseFutures = [
        endorserStub.ProcessProposal.future(signedProposal, int(timeout))
        for endorserStub in endorserStubs
    ]
    resultsDict = dict(
        zip(endorsers,
            [respFuture.result() for respFuture in proposalResponseFutures]))
    user.setTagValue(proposalResponsesAlias, resultsDict)
def step_impl(context, user_name, serialized_identity_name, cert_alias):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=user_name)
    nat = user.getTagValue(cert_alias)
    signers_cert = directory.findCertForNodeAdminTuple(nat)
    serialized_identity = endorser_util.create_serialized_identity(msp_id=nat.organization, signers_cert=signers_cert)
    user.setTagValue(tagKey=serialized_identity_name, tagValue=serialized_identity)
Exemple #22
0
def step_impl(context, certAlias, ordererGenesisBlockName,
              ordererSystemChainIdName, networkConfigPolicy, consensusType):
    directory = bootstrap_util.getDirectory(context=context)
    ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context)
    ordererSystemChainIdGUUID = ordererBootstrapAdmin.tags[
        ordererSystemChainIdName]
    # Now collect the named signed config items
    configGroups = []
    for row in context.table.rows:
        configGroupName = row['ConfigGroup Names']
        configGroups += ordererBootstrapAdmin.tags[configGroupName]
    # Concatenate signedConfigItems

    # Construct block
    nodeAdminTuple = ordererBootstrapAdmin.tags[certAlias]
    bootstrapCert = directory.findCertForNodeAdminTuple(
        nodeAdminTuple=nodeAdminTuple)
    (genesisBlock, envelope) = bootstrap_util.createGenesisBlock(
        context,
        ordererSystemChainIdGUUID,
        consensusType,
        nodeAdminTuple=nodeAdminTuple,
        signedConfigItems=configGroups)
    ordererBootstrapAdmin.setTagValue(ordererGenesisBlockName, genesisBlock)
    bootstrap_util.OrdererGensisBlockCompositionCallback(context, genesisBlock)
    bootstrap_util.PeerCompositionCallback(context)
Exemple #23
0
def step_impl(context, userName, proposalResponseName, proposalResponseResultCode):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=userName)
    peerToProposalResponseDict = user.tags[proposalResponseName]
    unexpectedResponses = [(composeService,proposalResponse) for composeService, proposalResponse in peerToProposalResponseDict.items() if proposalResponse.response.payload != proposalResponseResultCode]
    print("ProposalResponse: \n{0}\n".format(proposalResponse))
    print("")
Exemple #24
0
def step_impl(context, userName, certAlias, genisisBlockName,
              joinChannelResult):
    timeout = 10
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName)
    # Find the cert using the cert tuple information saved for the user under certAlias
    signersCert = directory.findCertForNodeAdminTuple(user.tags[certAlias])

    # Retrieve the genesis block from the returned value of deliver (Will be list with first block as genesis block)
    genesisBlock = user.tags[genisisBlockName][0]
    ccSpec = endorser_util.getChaincodeSpec(
        "GOLANG", "", "cscc",
        ["JoinChain", genesisBlock.SerializeToString()])
    proposal = endorser_util.createInvokeProposalForBDD(
        ccSpec=ccSpec,
        chainID="",
        signersCert=signersCert,
        Mspid="DEFAULT",
        type="CONFIGURATION_TRANSACTION")
    signedProposal = endorser_util.signProposal(proposal=proposal,
                                                entity=user,
                                                signersCert=signersCert)

    # Send proposal to each specified endorser, waiting 'timeout' seconds for response/error
    endorsers = [row['Peer'] for row in context.table.rows]
    proposalResponseFutures = [
        endorserStub.ProcessProposal.future(signedProposal, int(timeout))
        for endorserStub in endorser_util.getEndorserStubs(context, endorsers)
    ]
    resultsDict = dict(
        zip(endorsers,
            [respFuture.result() for respFuture in proposalResponseFutures]))
    user.tags[joinChannelResult] = resultsDict
 def getEnv(self, composition, context, env):
     directory = getDirectory(context)
     for composer_service in self.getComposerList(composition):
         (orderer_trusted_roots,
          peer_trusted_roots) = self.getTrustedRootsPaths(
              project_name=composition.projectName,
              composer_service=composer_service,
              pathType=PathType.Container)
         keyValStorePath = self.getKeyValStorePath(
             project_name=composition.projectName,
             composer_service=composer_service,
             pathType=PathType.Container)
         (owning_org_name,
          peer_compose_services) = get_peers_for_composer_service(
              directory=directory, composer_service=composer_service)
         connectionProfileDict = self.getConnectionProfile(
             ordererCertPath=orderer_trusted_roots,
             peerCertPath=peer_trusted_roots,
             key_val_store_path=keyValStorePath,
             orderer_compose_services=['orderer0'],
             peer_compose_services=peer_compose_services,
             msp_id=owning_org_name)
         env["{0}_COMPOSER_CONFIG".format(
             composer_service.upper())] = json.dumps(connectionProfileDict,
                                                     separators=(',', ':'))
         keyValStorePath = self.getKeyValStorePath(
             project_name=composition.projectName,
             composer_service=composer_service,
             pathType=PathType.Local)
         env["{0}_PATH_TO_HFC".format(
             composer_service.upper())] = keyValStorePath
Exemple #26
0
def step_impl(context, userName, createChannelSignedConfigEnvelope):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName)
    ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context)


    channelID = context.table.rows[0]["ChannelID"]
    chainCreationPolicyName = context.table.rows[0]["Chain Creation Policy Name"]
    templateName = context.table.rows[0]["Template"]
    # Loop through templates referenced orgs
    mspOrgNames = [org.name for org in user.tags[templateName]]
    signedMspConfigItems = bootstrap_util.getSignedMSPConfigItems(context=context, orgNames=mspOrgNames)

    # Add the anchors signed config Items
    anchorSignedConfigItemsName = context.table.rows[0]["Anchors"]
    signedAnchorsConfigItems = user.tags[anchorSignedConfigItemsName]

    # Intermediate step until template tool is ready
    consensus_type = ordererBootstrapAdmin.tags["ConsensusType"]
    channel_config_groups = bootstrap_util.createSignedConfigItems(directory=directory,
                                                                   consensus_type=consensus_type,
                                                                   configGroups=signedMspConfigItems + signedAnchorsConfigItems)

    # bootstrap_util.setMetaPolicy(channelId=channelID, channgel_config_groups=channgel_config_groups)

    #NOTE: Conidered passing signing key for appDeveloper, but decided that the peer org signatures they need to collect subsequently should be proper way
    config_update_envelope = bootstrap_util.createConfigUpdateEnvelope(channelConfigGroup=channel_config_groups, chainId=channelID, chainCreationPolicyName=chainCreationPolicyName)

    user.setTagValue(createChannelSignedConfigEnvelope, config_update_envelope)
Exemple #27
0
def step_impl(context, ordererSystemChainIdName, mspConfigItemsName):
    assert 'table' in context, "Expected table of policy names"
    directory = bootstrap_util.getDirectory(context)
    ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context)
    ordererSystemChainIdGUUID = ordererBootstrapAdmin.tags[ordererSystemChainIdName]
    mspSignedConfigItems = bootstrap_util.getMspConfigItemsForPolicyNames(context, policyNames=[row['PolicyName'] for row in context.table.rows])
    ordererBootstrapAdmin.setTagValue(mspConfigItemsName, mspSignedConfigItems)
Exemple #28
0
def step_impl(context, userName, ccType, chaincodeName, chaincodePath, ccSpecAlias):
	directory = bootstrap_util.getDirectory(context=context)
	user = directory.getUser(userName)
	args =  bootstrap_util.getArgsFromContextForUser(context, userName)
	ccSpec = endorser_util.getChaincodeSpec(ccType=ccType, path=chaincodePath, name=chaincodeName, args=bdd_grpc_util.toStringArray(args))
	print("ccSpec = {0}".format(ccSpec))
	user.tags[ccSpecAlias] = ccSpec
Exemple #29
0
def step_impl(context):
    assert 'table' in context, "Expected table with triplet of Developer/ChainCreationPolicyName/Organization"
    directory = bootstrap_util.getDirectory(context)
    for row in context.table.rows:
        userName = row['Developer']
        nodeAdminNamedTuple = directory.registerOrdererAdminTuple(userName, row['ChainCreationPolicyName'], row['Organization'])
        user = directory.getUser(userName)
        user.setTagValue(row['AliasSavedUnder'], nodeAdminNamedTuple)
def step_impl(context, userName, peerOrgSetName):
    ' At the moment, only really defining MSP Config Items (NOT SIGNED)'
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName)
    user.setTagValue(peerOrgSetName, [
        directory.getOrganization(row['Organization']).name
        for row in context.table.rows
    ])
Exemple #31
0
def step_impl(context, certAlias):
    assert "table" in context, "Expected table of Organizations"
    directory = bootstrap_util.getDirectory(context)
    ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context)
    assert len(context.table.rows) == 1, "Only support single orderer orgnaization at moment"
    for row in context.table.rows:
        nodeAdminNamedTuple = directory.registerOrdererAdminTuple(ordererBootstrapAdmin.name, "ordererBootstrapAdmin", row['Organization'])
        ordererBootstrapAdmin.setTagValue(certAlias, nodeAdminNamedTuple)
Exemple #32
0
def step_impl(context, userName, ccDeploymentSpecAlias, ccSpecAlias, devopsComposeService):
    directory = bootstrap_util.getDirectory(context=context)
    user = directory.getUser(userName=userName)
    assert ccSpecAlias in user.tags, "ChaincodeSpec alias '{0}' not found for user '{1}'".format(ccSpecAlias, userName)
    deploymentSpec = None
    raise Exception("Not Implemented")
    #user.setTagValue(ccDeploymentSpecAlias, deploymentSpec)
    user.setTagValue(ccDeploymentSpecAlias, deploymentSpec)
Exemple #33
0
def step_impl(context):
    assert 'table' in context, "Expected table with triplet of User/Peer/Organization"
    directory = bootstrap_util.getDirectory(context)
    for row in context.table.rows:
        nodeAdminTuple = directory.registerOrdererAdminTuple(row['User'], row['Peer'], row['Organization'])
        aliasToSaveUnder = row['AliasSavedUnder']
        if aliasToSaveUnder != "":
            directory.getUser(row['User']).setTagValue(aliasToSaveUnder, nodeAdminTuple)
def step_impl(context, userName, configTxName,
              createChannelSignedConfigEnvelopeName):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=userName)
    channelCreationInfo = user.tags[createChannelSignedConfigEnvelopeName]
    user.tags[configTxName] = bootstrap_util.createConfigTxEnvelope(
        channelCreationInfo.channelId,
        channelCreationInfo.signedConfigEnvelope)
def step_impl(context, userName, templateName, chainCreatePolicyName):
    ' At the moment, only really defining MSP Config Items (NOT SIGNED)'
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName)
    user.tags[templateName] = [
        directory.getOrganization(row['Organization'])
        for row in context.table.rows
    ]
def step_impl(context):
    assert 'table' in context, "Expected table with triplet of User/Peer/Organization"
    directory = bootstrap_util.getDirectory(context)
    for row in context.table.rows:
        nodeAdminTuple = directory.registerOrdererAdminTuple(row['User'], row['Peer'], row['Organization'])
        aliasToSaveUnder = row['AliasSavedUnder']
        if aliasToSaveUnder != "":
            directory.getUser(row['User']).setTagValue(aliasToSaveUnder, nodeAdminTuple)
Exemple #37
0
def step_impl(context, userName, composeService):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=userName)
    row = context.table.rows[0]
    chainID = row['ChainId']
    start, end, = orderer_util.convertSeek(row['Start']), orderer_util.convertSeek(row['End'])

    streamHelper = user.getDelivererStreamHelper(context, composeService)
    streamHelper.seekToRange(chainID=chainID, start = start, end = end)
Exemple #38
0
def step_impl(context, userName, deliveryName, composeService, expectedBlocks, numMsgsToBroadcast, batchTimeout):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=userName)
    streamHelper = user.getDelivererStreamHelper(context, composeService)

    blocks = streamHelper.getBlocks()

    # Verify block count
    assert len(blocks) == int(expectedBlocks), "Expected {0} blocks, received {1}".format(expectedBlocks, len(blocks))
def step_impl(context, user_name, compose_service, upgrade_version):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=user_name)
    assert "composition" in context, "No composition found in context"
    composition = context.composition
    composition.issueCommand(['stop'], [compose_service])
    composition.issueCommand(['rm', '-f'], [compose_service])
    composition.set_version_for_service(compose_service, upgrade_version)
    composition.issueCommand(['up', '-d'], [compose_service])
Exemple #40
0
def step_impl(context, userName, transactionAlias, proposalAlias,
              proposalResponseAlias, channelId):
    directory = bootstrap_util.getDirectory(context=context)
    user = directory.getUser(userName)
    proposalResponsesDict = user.tags[proposalResponseAlias]
    proposal = user.tags[proposalAlias]
    signedTx = endorser_util.createSignedTx(user, proposal,
                                            proposalResponsesDict.values())
    user.setTagValue(transactionAlias, signedTx)
Exemple #41
0
def step_impl(context, userName, transactionAlias, orderer, channelId):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=userName)
    transaction = user.tags[transactionAlias]
    bootstrap_util.broadcastCreateChannelConfigTx(context=context,
                                                  composeService=orderer,
                                                  chainId=channelId,
                                                  user=user,
                                                  configTxEnvelope=transaction)
def step_impl(context, userName, transactionAlias, orderer):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=userName)
    transaction = user.tags[transactionAlias]
    bootstrap_util.broadcast_channel_config_tx(context=context,
                                               certAlias=None,
                                               composeService=orderer,
                                               user=user,
                                               configTxEnvelope=transaction)
Exemple #43
0
def step_impl(context, userName, createChannelSignedConfigEnvelopeName):
    assert 'table' in context, "Expected table of peer organizations"
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=userName)
    config_update_envelope = user.tags[createChannelSignedConfigEnvelopeName]
    for row in context.table.rows:
        org = directory.getOrganization(row['Organization'])
        assert bootstrap_util.Network.Peer in org.networks, "Organization '{0}' not in Peer network".format(org.name)
        bootstrap_util.BootstrapHelper.addSignatureToSignedConfigItem(config_update_envelope, (org, org.getSelfSignedCert()))
Exemple #44
0
def step_impl(context, ordererConfigAdmin, consortiumName, modPolicy):
    directory = bootstrap_util.getDirectory(context)
    ordererConfigAdmin = directory.getUser(ordererConfigAdmin)

    # Collect the orgs from the table
    orgNames = [row['Organization'] for row in context.table.rows]
    bootstrap_util.addOrdererBootstrapAdminOrgReferences(context, consortiumName, orgNames)

    consortium = bootstrap_util.createConsortium(context=context, consortium_name=consortiumName, org_names=orgNames, mod_policy=modPolicy)
    ordererConfigAdmin.setTagValue(consortiumName, consortium)
Exemple #45
0
def step_impl(context, userName, ccDeploymentSpecAlias, ccSpecAlias, devopsComposeService):
    directory = bootstrap_util.getDirectory(context=context)
    user = directory.getUser(userName=userName)
    assert ccSpecAlias in user.tags, "ChaincodeSpec alias '{0}' not found for user '{1}'".format(ccSpecAlias, userName)

    ipAddress = bdd_test_util.ipFromContainerNamePart(devopsComposeService, context.compose_containers)
    channel = bdd_grpc_util.getGRPCChannel(ipAddress)
    devopsStub = devops_pb2.beta_create_Devops_stub(channel)
    deploymentSpec = devopsStub.Build(user.tags[ccSpecAlias],20)
    user.tags[ccDeploymentSpecAlias] = deploymentSpec
Exemple #46
0
def step_impl(context, userName, createChannelSignedConfigEnvelopeName):
    assert 'table' in context, "Expected table of peer organizations"
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=userName)
    config_update_envelope = user.tags[createChannelSignedConfigEnvelopeName]
    for row in context.table.rows:
        user = directory.getUser(row['Developer'])
        namedAdminTuple = user.tags[row['Cert Alias']]
        cert = directory.findCertForNodeAdminTuple(namedAdminTuple)
        # assert bootstrap_util.Network.Peer in org.networks, "Organization '{0}' not in Peer network".format(org.name)
        bootstrap_util.BootstrapHelper.addSignatureToSignedConfigItem(config_update_envelope, (user, namedAdminTuple.organization, cert))
Exemple #47
0
def step_impl(context, consortiumName):
    directory = bootstrap_util.getDirectory(context)


    ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context)

    # Collect the orgs from the table
    orgNames = [row['Organization'] for row in context.table.rows]
    bootstrap_util.addOrdererBootstrapAdminOrgReferences(context, consortiumName, orgNames)

    consortium = bootstrap_util.createConsortium(context=context, consortium_name=consortiumName, org_names=orgNames)
    ordererBootstrapAdmin.setTagValue(consortiumName, [consortium])
Exemple #48
0
def step_impl(context, chainCreatePolicyName, ordererSystemChainId):
    directory = bootstrap_util.getDirectory(context)
    ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context)
    ordererSystemChainIdGuuid = ordererBootstrapAdmin.tags[ordererSystemChainId]

    # Collect the orgs from the table
    orgNames = [row['Organization'] for row in context.table.rows]

    (chainCreationPolicyNamesSignedConfigItem, chainCreatorsOrgsPolicySignedConfigItem) = \
        bootstrap_util.createChainCreatorsPolicy(context=context, chainCreatePolicyName=chainCreatePolicyName, chaindId=ordererSystemChainIdGuuid, orgNames=orgNames)

    ordererBootstrapAdmin.tags[chainCreatePolicyName] = (chainCreationPolicyNamesSignedConfigItem, chainCreatorsOrgsPolicySignedConfigItem)
Exemple #49
0
def step_impl(context, userName, createChannelSignedConfigEnvelopeName):
    assert 'table' in context, "Expected table of peer organizations"
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=userName)
    # Get the ChannelCreationInfo object that holds the signedConfigEnvelope
    channelCreationInfo = user.tags[createChannelSignedConfigEnvelopeName]
    signedConfigEnvelope = channelCreationInfo.signedConfigEnvelope
    for row in context.table.rows:
        org = directory.getOrganization(row['Organization'])
        assert bootstrap_util.Network.Peer in org.networks, "Organization '{0}' not in Peer network".format(org.name)
        bootstrap_util.BootstrapHelper.addSignatureToSignedConfigItem(signedConfigEnvelope.Items[0], (org.ecdsaSigningKey, org.getSelfSignedCert()))
    print("Signatures for signedConfigEnvelope:\n {0}\n".format(signedConfigEnvelope.Items[0]))
Exemple #50
0
def step_impl(context, userName, proposalResponsesAlias):
    directory = bootstrap_util.getDirectory(context=context)
    user = directory.getUser(userName=userName)
    assert proposalResponsesAlias in user.tags, "Expected proposal responses at tag '{0}', for user '{1}'".format(proposalResponsesAlias, userName)
    proposalRespDict = user.tags[proposalResponsesAlias]
    assert len(proposalRespDict) > 0, "Expected at least 1 proposal response, found none in proposal responses dictionary"
    if len(proposalRespDict) == 1:
        pass
    else:
        endorsers = [row['Endorser'] for row in context.table.rows]
        endorserToProposalResponseHashDict = dict(zip(endorsers, [user.computeHash(proposalRespDict[endorser].payload) for endorser in endorsers]))
        setOfHashes = set(endorserToProposalResponseHashDict.values())
        assert len(setOfHashes) == 1, "Hashes from endorsers did NOT match: {0}".format(endorserToProposalResponseHashDict)
Exemple #51
0
def step_impl(context, userName, certAlias, configUpdateTxName, createChannelSignedConfigEnvelopeName):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName=userName)
    namedAdminTuple = user.tags[certAlias]
    cert = directory.findCertForNodeAdminTuple(namedAdminTuple)
    config_update_envelope = user.tags[createChannelSignedConfigEnvelopeName]
    config_update = bootstrap_util.getChannelIdFromConfigUpdateEnvelope(config_update_envelope)
    envelope_for_config_update = bootstrap_util.createEnvelopeForMsg(directory=directory,
                                                                     nodeAdminTuple=namedAdminTuple,
                                                                     chainId=config_update.channel_id,
                                                                     msg=config_update_envelope,
                                                                     typeAsString="CONFIG_UPDATE")
    user.setTagValue(configUpdateTxName, envelope_for_config_update)
Exemple #52
0
def step_impl(context, userName, proposalResponsesAlias, statusCode):
    assert 'table' in context, "Expected table of endorsers"
    directory = bootstrap_util.getDirectory(context=context)
    user = directory.getUser(userName=userName)
    # Make sure proposalResponseAlias not already defined
    assert proposalResponsesAlias in user.tags, "Expected proposal responses at tag '{0}', for user '{1}'".format(proposalResponsesAlias, userName)
    proposalRespDict = user.tags[proposalResponsesAlias]

    # Loop through endorser proposal Responses
    endorsers = [row['Endorser'] for row in context.table.rows]
    print("Endorsers = {0}, rsults keys = {1}".format(endorsers, proposalRespDict.keys()))
    for respSatusCode in [proposalRespDict[endorser].response.status for endorser in endorsers]:
        assert int(statusCode) == respSatusCode, "Expected proposal response status code of {0} from {1}, received {2}".format(statusCode, endorser, respSatusCode)
Exemple #53
0
def step_impl(context, userName, proposalAlias, timeout, proposalResponsesAlias):
    assert 'table' in context, "Expected table of endorsers"
    directory = bootstrap_util.getDirectory(context=context)
    user = directory.getUser(userName=userName)

    assert proposalAlias in user.tags, "Proposal alias '{0}' not found for user '{1}'".format(proposalAlias, userName)
    signedProposal = user.tags[proposalAlias]

    # Send proposal to each specified endorser, waiting 'timeout' seconds for response/error
    endorsers = [row['Endorser'] for row in context.table.rows]
    endorserStubs = endorser_util.getEndorserStubs(context, endorsers)
    proposalResponseFutures = [endorserStub.ProcessProposal.future(signedProposal, int(timeout)) for endorserStub in endorserStubs]
    resultsDict =  dict(zip(endorsers, [respFuture.result() for respFuture in proposalResponseFutures]))
    user.tags[proposalResponsesAlias] = resultsDict
Exemple #54
0
def step_impl(context, ordererConfigAdmin, consortiumsConfigUpdateName, configName, ordererSystemChainIdName):
    '''
    channel group/Consortiums/
    Read the consortiums Group from existing genesis block.
    '''
    directory = bootstrap_util.getDirectory(context)
    ordererConfigAdmin = directory.getUser(ordererConfigAdmin)
    channel_group = ordererConfigAdmin.getTagValue(configName)
    orderer_system_chain_id = ordererConfigAdmin.getTagValue(ordererSystemChainIdName)
    config_groups = []
    # Now collect the consortiums
    for row in context.table.rows:
        config_groups.append(ordererConfigAdmin.getTagValue(row['Consortium']))
    config_update = bootstrap_util.create_orderer_consortium_config_update(orderer_system_chain_id, channel_group, config_groups)
    ordererConfigAdmin.setTagValue(tagKey=consortiumsConfigUpdateName, tagValue=config_update)
Exemple #55
0
def step_impl(context, userName, certAlias, proposalAlias, channelName, ccSpecAlias):
    directory = bootstrap_util.getDirectory(context=context)
    user = directory.getUser(userName=userName)
    assert ccSpecAlias in user.tags, "ChaincodeSpec alias '{0}' not found for user '{1}'".format(ccSpecAlias, userName)
    lcChaincodeSpec = user.tags[ccSpecAlias]
    # Find the cert using the cert tuple information saved for the user under certAlias
    nodeAdminTuple = user.tags[certAlias]
    signersCert = directory.findCertForNodeAdminTuple(nodeAdminTuple)
    mspID = nodeAdminTuple.organization

    proposal = endorser_util.createInvokeProposalForBDD(context, ccSpec=lcChaincodeSpec, chainID=channelName,signersCert=signersCert, Mspid=mspID, type="ENDORSER_TRANSACTION")

    signedProposal = endorser_util.signProposal(proposal=proposal, entity=user, signersCert=signersCert)

    # proposal = endorser_util.createDeploymentProposalForBDD(ccDeploymentSpec)
    assert not proposalAlias in user.tags, "Proposal alias '{0}' already exists for '{1}'".format(proposalAlias, userName)
    user.setTagValue(proposalAlias, signedProposal)
Exemple #56
0
def step_impl(context, userName, createChannelSignedConfigEnvelope):
    directory = bootstrap_util.getDirectory(context)
    user = directory.getUser(userName)
    ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context)

    muralisRequiredSignedConfigItems = []

    channelID = context.table.rows[0]["ChannelID"]
    chainCreationPolicyName = context.table.rows[0]["Chain Creation Policy Name"]

    # Intermediate step until template tool is ready
    signedConfigItems = bootstrap_util.createSignedConfigItems(context, channelID, "solo", signedConfigItems=muralisRequiredSignedConfigItems)

    #NOTE: Conidered passing signing key for appDeveloper, but decided that the peer org signatures they need to collect subsequently should be proper way
    signedConfigEnvelope = bootstrap_util.signInitialChainConfig(signedConfigItems=signedConfigItems, chainId=channelID, chainCreationPolicyName=chainCreationPolicyName)

    user.tags[createChannelSignedConfigEnvelope] =  ChannelCreationInfo(channelID, chainCreationPolicyName, signedConfigEnvelope)
Exemple #57
0
    def __init__(self, contextHelper, scenario):
        self.contextHelper = contextHelper
        self.directory = getDirectory(contextHelper.context)
        self.output = StringIO()
        self.currentStep = 0
        self.composition = None

        #Weave advices into contextHelper
        weave(target=self.contextHelper.before_step, advices=self.beforeStepAdvice)
        weave(target=self.contextHelper.after_step, advices=self.afterStepAdvice)
        weave(target=self.contextHelper.after_scenario, advices=self.afterScenarioAdvice)
        weave(target=self.contextHelper.getBootrapHelper, advices=self.getBootstrapHelperAdvice)
        weave(target=self.contextHelper.registerComposition, advices=self.registerCompositionAdvice)

        # Weave advices into Directory
        weave(target=self.directory._registerOrg, advices=self.registerOrgAdvice)
        weave(target=self.directory._registerUser, advices=self.registerUserAdvice)
        weave(target=self.directory.registerOrdererAdminTuple, advices=self.registerNamedNodeAdminTupleAdvice)