示例#1
0
def step_impl(context, enrollId):
	assert 'users' in context, "users not found in context. Did you register a user?"
	(channel, userRegistration) = bdd_grpc_util.getGRPCChannelAndUser(context, enrollId)
	
	stub = devops_pb2.beta_create_Devops_stub(channel)

	secret =  bdd_grpc_util.getSecretForUserRegistration(userRegistration)
	response = stub.EXP_GetApplicationTCert(secret,2)
	assert response.status == fabric_pb2.Response.SUCCESS, 'Failure getting TCert from {0}, for user "{1}":  {2}'.format(userRegistration.composeService,enrollId, response.msg)
	tcert = response.msg

	userRegistration.lastResult = tcert
def step_impl(context, enrollId, assignerAppTCert, role, assigneeAppTCert):
    assert 'users' in context, "users not found in context. Did you register a user?"
    assert 'compose_containers' in context, "compose_containers not found in context"

    (channel, userRegistration) = bdd_grpc_util.getGRPCChannelAndUser(
        context, enrollId)

    stub = devops_pb2.beta_create_Devops_stub(channel)

    # First get binding with EXP_PrepareForTx
    secret = bdd_grpc_util.getSecretForUserRegistration(userRegistration)
    response = stub.EXP_PrepareForTx(secret, 2)
    assert response.status == fabric_pb2.Response.SUCCESS, 'Failure getting Binding from {0}, for user "{1}":  {2}'.format(
        userRegistration.composeService, enrollId, response.msg)
    binding = response.msg

    # Now produce the sigma EXP_ProduceSigma
    chaincodeInput = chaincode_pb2.ChaincodeInput(
        function="addRole",
        args=(base64.b64encode(userRegistration.tags[assigneeAppTCert]), role))
    chaincodeInputRaw = chaincodeInput.SerializeToString()
    appTCert = userRegistration.tags[assignerAppTCert]
    sigmaInput = devops_pb2.SigmaInput(secret=secret,
                                       appTCert=appTCert,
                                       data=chaincodeInputRaw + binding)
    response = stub.EXP_ProduceSigma(sigmaInput, 2)
    assert response.status == fabric_pb2.Response.SUCCESS, 'Failure prducing sigma from {0}, for user "{1}":  {2}'.format(
        userRegistration.composeService, enrollId, response.msg)
    sigmaOutputBytes = response.msg
    # Parse the msg bytes as a SigmaOutput message
    sigmaOutput = devops_pb2.SigmaOutput()
    sigmaOutput.ParseFromString(sigmaOutputBytes)
    print('Length of sigma = {0}'.format(len(sigmaOutput.sigma)))

    # Now execute the transaction with the saved binding, EXP_ExecuteWithBinding
    assert "grpcChaincodeSpec" in context, "grpcChaincodeSpec NOT found in context"
    newChaincodeSpec = chaincode_pb2.ChaincodeSpec()
    newChaincodeSpec.CopyFrom(context.grpcChaincodeSpec)
    newChaincodeSpec.metadata = sigmaOutput.asn1Encoding
    newChaincodeSpec.ctorMsg.CopyFrom(chaincodeInput)

    ccInvocationSpec = chaincode_pb2.ChaincodeInvocationSpec(
        chaincodeSpec=newChaincodeSpec)

    executeWithBinding = devops_pb2.ExecuteWithBinding(
        chaincodeInvocationSpec=ccInvocationSpec, binding=binding)

    response = stub.EXP_ExecuteWithBinding(executeWithBinding, 60)
    assert response.status == fabric_pb2.Response.SUCCESS, 'Failure executeWithBinding from {0}, for user "{1}":  {2}'.format(
        userRegistration.composeService, enrollId, response.msg)
    context.response = response
    context.transactionID = response.msg
def step_impl(context, enrollId):
    assert 'users' in context, "users not found in context. Did you register a user?"
    (channel, userRegistration) = bdd_grpc_util.getGRPCChannelAndUser(
        context, enrollId)

    stub = devops_pb2.beta_create_Devops_stub(channel)

    secret = bdd_grpc_util.getSecretForUserRegistration(userRegistration)
    response = stub.EXP_GetApplicationTCert(secret, 2)
    assert response.status == fabric_pb2.Response.SUCCESS, 'Failure getting TCert from {0}, for user "{1}":  {2}'.format(
        userRegistration.composeService, enrollId, response.msg)
    tcert = response.msg

    userRegistration.lastResult = tcert
示例#4
0
def step_impl(context, enrollId, assignerAppTCert, role, assigneeAppTCert):
	assert 'users' in context, "users not found in context. Did you register a user?"
	assert 'compose_containers' in context, "compose_containers not found in context"

	(channel, userRegistration) = bdd_grpc_util.getGRPCChannelAndUser(context, enrollId)

	stub = devops_pb2.beta_create_Devops_stub(channel)

	# First get binding with EXP_PrepareForTx
	secret = bdd_grpc_util.getSecretForUserRegistration(userRegistration)
	response = stub.EXP_PrepareForTx(secret,2)
	assert response.status == fabric_pb2.Response.SUCCESS, 'Failure getting Binding from {0}, for user "{1}":  {2}'.format(userRegistration.composeService,enrollId, response.msg)
	binding = response.msg

	# Now produce the sigma EXP_ProduceSigma
	chaincodeInput = chaincode_pb2.ChaincodeInput(function = "addRole", args = (base64.b64encode(userRegistration.tags[assigneeAppTCert]), role) ) 
	chaincodeInputRaw = chaincodeInput.SerializeToString()
	appTCert = userRegistration.tags[assignerAppTCert]
	sigmaInput = devops_pb2.SigmaInput(secret = secret, appTCert = appTCert,  data = chaincodeInputRaw + binding)
	response = stub.EXP_ProduceSigma(sigmaInput,2)
	assert response.status == fabric_pb2.Response.SUCCESS, 'Failure prducing sigma from {0}, for user "{1}":  {2}'.format(userRegistration.composeService,enrollId, response.msg)
	sigmaOutputBytes = response.msg
	# Parse the msg bytes as a SigmaOutput message
	sigmaOutput = devops_pb2.SigmaOutput()
	sigmaOutput.ParseFromString(sigmaOutputBytes)
	print('Length of sigma = {0}'.format(len(sigmaOutput.sigma)))
	
	# Now execute the transaction with the saved binding, EXP_ExecuteWithBinding
	assert "grpcChaincodeSpec" in context, "grpcChaincodeSpec NOT found in context"
	newChaincodeSpec = chaincode_pb2.ChaincodeSpec()
	newChaincodeSpec.CopyFrom(context.grpcChaincodeSpec)
	newChaincodeSpec.metadata = sigmaOutput.asn1Encoding
	newChaincodeSpec.ctorMsg.CopyFrom(chaincodeInput)

	ccInvocationSpec = chaincode_pb2.ChaincodeInvocationSpec(chaincodeSpec = newChaincodeSpec)

	executeWithBinding = devops_pb2.ExecuteWithBinding(chaincodeInvocationSpec = ccInvocationSpec, binding = binding)

	response = stub.EXP_ExecuteWithBinding(executeWithBinding,60)
	assert response.status == fabric_pb2.Response.SUCCESS, 'Failure executeWithBinding from {0}, for user "{1}":  {2}'.format(userRegistration.composeService,enrollId, response.msg)
	context.response = response
	context.transactionID = response.msg