Exemplo n.º 1
0
def connectIfNotAlreadyConnected(do, userCli, userMap, expectMsgs=None):
    # TODO: Shouldn't this be testing the cli command `status`?
    if not userCli._isConnectedToAnyEnv():
        connect_and_check_output(do,
                                 userCli.txn_dir,
                                 expect=expectMsgs,
                                 mapper=userMap)
Exemplo n.º 2
0
def trustAnchorCli(be, do, poolNodesStarted, earlCLI,
                   trustAnchorWallet):
    be(earlCLI)
    do('prompt Earl', expect=prompt_is('Earl'))
    addAndActivateCLIWallet(earlCLI, trustAnchorWallet)
    connect_and_check_output(do, earlCLI.txn_dir)
    return earlCLI
Exemplo n.º 3
0
def test_change_key(be, do, susanCLI, newStewardCli):
    # Generate new key in the wallet
    be(susanCLI)
    connect_and_check_output(do, susanCLI.txn_dir)
    do('new key', within=3, expect=["Key created in wallet"])

    # check that id cannot be used for the time
    id = susanCLI.activeDID
    verk = susanCLI.activeWallet.getVerkey(id)
    do('send NYM dest={}'.format(id), within=3, expect=[
       "Error: client request invalid: CouldNotAuthenticate("])

    # Add verkey
    be(newStewardCli)
    do('send NYM dest={} verkey={}'.format(id, verk),
       within=3, expect=["Nym {} added".format(id)])

    # check Susan's key is ok
    be(susanCLI)
    do('send NYM dest={}'.format(id), within=3,
       expect=["Nym {} added".format(id)])
    do('send GET_NYM dest={}'.format(id), within=3, expect=[
       "Current verkey for NYM {} is {}".format(id, verk)])

    # change key
    do('change current key', within=3, expect=["Adding nym {}".format(
        id), "Key changed for {}".format(id), "New verification key is"])

    # check new key
    assert id == susanCLI.activeDID
    assert verk != susanCLI.activeWallet.getVerkey(id)
    do('send NYM dest={}'.format(id), within=3,
       expect=["Nym {} added".format(id)])
    do('send GET_NYM dest={}'.format(id), within=3, expect=[
       "Current verkey for NYM {} is {}".format(id, susanCLI.activeWallet.getVerkey(id))])
Exemplo n.º 4
0
def newStewardCli(be, do, poolNodesStarted, trusteeCli, cliWithNewStewardName,
                  newStewardVals):
    be(trusteeCli)
    if not trusteeCli._isConnectedToAnyEnv():
        connect_and_check_output(do, trusteeCli.txn_dir)

    do('send NYM dest={{newStewardIdr}} role={role} verkey={{newStewardVerkey}}'
       .format(role=Roles.STEWARD.name),
       within=3,
       expect='Nym {newStewardIdr} added',
       mapper=newStewardVals)

    be(cliWithNewStewardName)

    do('new key with seed {newStewardSeed}',
       expect=[
           'DID for key is {newStewardIdr}',
           'Current DID set to {newStewardIdr}'
       ],
       mapper=newStewardVals)

    if not cliWithNewStewardName._isConnectedToAnyEnv():
        connect_and_check_output(do, cliWithNewStewardName.txn_dir)

    return cliWithNewStewardName
Exemplo n.º 5
0
def trustAnchorCli(be, do, poolNodesStarted, earlCLI,
                   trustAnchorWallet):
    be(earlCLI)
    do('prompt Earl', expect=prompt_is('Earl'))
    addAndActivateCLIWallet(earlCLI, trustAnchorWallet)
    connect_and_check_output(do, earlCLI.txn_dir)
    return earlCLI
def aliceCli(be, do, poolNodesStarted, aliceCLI, wallet):
    keyseed = 'a' * 32

    be(aliceCLI)
    addAndActivateCLIWallet(aliceCLI, wallet)
    connect_and_check_output(do, aliceCLI.txn_dir)
    do('new key with seed {}'.format(keyseed))

    return aliceCLI
Exemplo n.º 7
0
def aliceCli(be, do, poolNodesStarted, aliceCLI, wallet):
    keyseed = 'a' * 32

    be(aliceCLI)
    addAndActivateCLIWallet(aliceCLI, wallet)
    connect_and_check_output(do, aliceCLI.txn_dir)
    do('new key with seed {}'.format(keyseed))

    return aliceCLI
Exemplo n.º 8
0
def trustAnchorCli(trustAnchorCLI, be, do, trustAnchorAdded):
    be(trustAnchorCLI)
    do('new wallet TS', expect=['New wallet TS created',
                                'Active wallet set to "TS"'])
    seed = hexlify(vals['newTrustAnchorIdr'][1]).decode()
    do('new key with seed {seed}', expect=['Key created in wallet TS'],
       mapper={'seed': seed})
    connect_and_check_output(do, trustAnchorCLI.txn_dir)
    return trustAnchorCLI
Exemplo n.º 9
0
def trustAnchorCli(trustAnchorCLI, be, do, trustAnchorAdded):
    be(trustAnchorCLI)
    do('new wallet TS',
       expect=['New wallet TS created', 'Active wallet set to "TS"'])
    seed = hexlify(vals['newTrustAnchorIdr'][1]).decode()
    do('new key with seed {seed}',
       expect=['Key created in wallet TS'],
       mapper={'seed': seed})
    connect_and_check_output(do, trustAnchorCLI.txn_dir)
    return trustAnchorCLI
Exemplo n.º 10
0
def anotherTrusteeCli(anotherTrusteeCLI, be, do,
                      anotherTrusteeAdded):
    be(anotherTrusteeCLI)
    do('new wallet TS1', expect=['New wallet TS1 created',
                                 'Active wallet set to "TS1"'])
    seed = hexlify(vals['newTrusteeIdr'][1]).decode()
    do('new key with seed {seed}', expect=['Key created in wallet TS1'],
       mapper={'seed': seed})
    connect_and_check_output(do, anotherTrusteeCLI.txn_dir)
    return anotherTrusteeCLI
Exemplo n.º 11
0
def anotherTrusteeCli(anotherTrusteeCLI, be, do, anotherTrusteeAdded):
    be(anotherTrusteeCLI)
    do('new wallet TS1',
       expect=['New wallet TS1 created', 'Active wallet set to "TS1"'])
    seed = hexlify(vals['newTrusteeIdr'][1]).decode()
    do('new key with seed {seed}',
       expect=['Key created in wallet TS1'],
       mapper={'seed': seed})
    connect_and_check_output(do, anotherTrusteeCLI.txn_dir)
    return anotherTrusteeCLI
Exemplo n.º 12
0
def trusteeCli(be, do, trusteeMap, poolNodesStarted, nymAddedOut, trusteeCLI):
    be(trusteeCLI)
    do('new key with seed {trusteeSeed}', expect=[
        'DID for key is {trusteeIdr}',
        'Current DID set to {trusteeIdr}'],
       mapper=trusteeMap)

    if not trusteeCLI._isConnectedToAnyEnv():
        connect_and_check_output(do, trusteeCLI.txn_dir)

    return trusteeCLI
Exemplo n.º 13
0
def trusteeCli(be, do, trusteeMap, poolNodesStarted, nymAddedOut, trusteeCLI):
    be(trusteeCLI)
    do('new key with seed {trusteeSeed}', expect=[
        'DID for key is {trusteeIdr}',
        'Current DID set to {trusteeIdr}'],
       mapper=trusteeMap)

    if not trusteeCLI._isConnectedToAnyEnv():
        connect_and_check_output(do, trusteeCLI.txn_dir)

    return trusteeCLI
Exemplo n.º 14
0
def testNewKeyChangesWalletsDefaultId(be, do, poolNodesStarted, poolTxnData,
                                      susanCLI):
    mywallet = Wallet('my wallet')
    keyseed = 'a' * 32
    idr, _ = mywallet.addIdentifier(seed=keyseed.encode("utf-8"))

    be(susanCLI)

    connect_and_check_output(do, susanCLI.txn_dir)

    do('new key with seed {}'.format(keyseed))

    do('send NYM dest={}'.format(idr))

    do('new key with seed {}'.format(poolTxnData['seeds']['Steward1']))

    do('send NYM dest={}'.format(idr), within=3,
       expect=["Nym {} added".format(idr)])
Exemplo n.º 15
0
def testNewKeyChangesWalletsDefaultId(be, do, poolNodesStarted, poolTxnData,
                                      susanCLI):
    mywallet = Wallet('my wallet')
    keyseed = 'a' * 32
    idr, _ = mywallet.addIdentifier(seed=keyseed.encode("utf-8"))

    be(susanCLI)

    connect_and_check_output(do, susanCLI.txn_dir)

    do('new key with seed {}'.format(keyseed))

    do('send NYM dest={}'.format(idr))

    do('new key with seed {}'.format(poolTxnData['seeds']['Steward1']))

    do('send NYM dest={}'.format(idr), within=3,
       expect=["Nym {} added".format(idr)])
Exemplo n.º 16
0
def newNodeAdded(be, do, poolNodesStarted, philCli, newStewardCli,
                 newNodeVals):
    be(newStewardCli)
    doSendNodeCmd(do, newNodeVals)
    newNodeData = newNodeVals["newNodeData"]

    def checkClientConnected(client):
        name = newNodeData[ALIAS] + CLIENT_STACK_SUFFIX
        assert name in client.nodeReg

    def checkNodeConnected(nodes):
        for node in nodes:
            name = newNodeData[ALIAS]
            assert name in node.nodeReg

    # Reconnect steward's CLI to get new pool membership info.
    disconnect_and_check_output(do)
    connect_and_check_output(do, newStewardCli.txn_dir)

    timeout = waits.expectedClientToPoolConnectionTimeout(
        len(newStewardCli.activeClient.nodeReg))

    newStewardCli.looper.run(
        eventually(checkClientConnected,
                   newStewardCli.activeClient,
                   timeout=timeout))

    be(philCli)

    # Reconnect Phil's CLI if needed to get new pool membership info.
    if philCli._isConnectedToAnyEnv():
        disconnect_and_check_output(do)
    connect_and_check_output(do, philCli.txn_dir)

    philCli.looper.run(
        eventually(checkClientConnected, philCli.activeClient,
                   timeout=timeout))

    poolNodesStarted.looper.run(
        eventually(checkNodeConnected,
                   list(poolNodesStarted.nodes.values()),
                   timeout=timeout))
    return newNodeVals
Exemplo n.º 17
0
def testCliExitCommand(be, do, poolNodesStarted, aliceCLI, CliBuilder,
                       aliceMap, newKeyringOut,
                       savedKeyringRestored, aliceKeyringMap):
    within = 3
    name = 'Alice'
    be(aliceCLI)
    do('prompt {}'.format(name), expect=prompt_is(name))
    do('new wallet {}'.format(name), expect=newKeyringOut, mapper=aliceMap)
    connect_and_check_output(do, aliceCLI.txn_dir)
    with pytest.raises(Exit):
        do('exit')

    def checkWalletRestore():
        # open cli again
        aliceCliNew = yield from CliBuilder(name)
        # check message of saved wallet alice restored
        be(aliceCliNew)
        connect_and_check_output(do, aliceCliNew.txn_dir, expect=savedKeyringRestored, mapper=aliceKeyringMap)

    # check wallet restore
    aliceCLI.looper.run(eventually(checkWalletRestore, timeout=within))
Exemplo n.º 18
0
def newNodeAdded(be, do, poolNodesStarted, philCli, newStewardCli,
                 newNodeVals):
    be(philCli)

    if not philCli._isConnectedToAnyEnv():
        connect_and_check_output(do, philCli.txn_dir)

    be(newStewardCli)
    doSendNodeCmd(do, newNodeVals)
    newNodeData = newNodeVals["newNodeData"]

    def checkClientConnected(client):
        name = newNodeData[ALIAS] + CLIENT_STACK_SUFFIX
        assert name in client.nodeReg

    def checkNodeConnected(nodes):
        for node in nodes:
            name = newNodeData[ALIAS]
            assert name in node.nodeReg

    timeout = waits.expectedClientToPoolConnectionTimeout(
        util.getMaxFailures(len(philCli.nodeReg))
    )

    newStewardCli.looper.run(eventually(checkClientConnected,
                                        newStewardCli.activeClient,
                                        timeout=timeout))

    philCli.looper.run(eventually(checkClientConnected,
                                  philCli.activeClient,
                                  timeout=timeout))

    poolNodesStarted.looper.run(
        eventually(
            checkNodeConnected,
            list(
                poolNodesStarted.nodes.values()),
            timeout=timeout))
    return newNodeVals
Exemplo n.º 19
0
def newNodeAdded(be, do, poolNodesStarted, philCli, newStewardCli,
                 newNodeVals):
    be(philCli)

    if not philCli._isConnectedToAnyEnv():
        connect_and_check_output(do, philCli.txn_dir)

    be(newStewardCli)
    doSendNodeCmd(do, newNodeVals)
    newNodeData = newNodeVals["newNodeData"]

    def checkClientConnected(client):
        name = newNodeData[ALIAS] + CLIENT_STACK_SUFFIX
        assert name in client.nodeReg

    def checkNodeConnected(nodes):
        for node in nodes:
            name = newNodeData[ALIAS]
            assert name in node.nodeReg

    timeout = waits.expectedClientToPoolConnectionTimeout(
        util.getMaxFailures(len(philCli.nodeReg))
    )

    newStewardCli.looper.run(eventually(checkClientConnected,
                                        newStewardCli.activeClient,
                                        timeout=timeout))

    philCli.looper.run(eventually(checkClientConnected,
                                  philCli.activeClient,
                                  timeout=timeout))

    poolNodesStarted.looper.run(
        eventually(
            checkNodeConnected,
            list(
                poolNodesStarted.nodes.values()),
            timeout=timeout))
    return newNodeVals
Exemplo n.º 20
0
def newStewardCli(be, do, poolNodesStarted, trusteeCli,
                  cliWithNewStewardName, newStewardVals):
    be(trusteeCli)
    if not trusteeCli._isConnectedToAnyEnv():
        connect_and_check_output(do, trusteeCli.txn_dir)

    do('send NYM dest={{newStewardIdr}} role={role} verkey={{newStewardVerkey}}'
       .format(role=Roles.STEWARD.name),
       within=3,
       expect='Nym {newStewardIdr} added',
       mapper=newStewardVals)

    be(cliWithNewStewardName)

    do('new key with seed {newStewardSeed}', expect=[
        'DID for key is {newStewardIdr}',
        'Current DID set to {newStewardIdr}'],
       mapper=newStewardVals)

    if not cliWithNewStewardName._isConnectedToAnyEnv():
        connect_and_check_output(do, cliWithNewStewardName.txn_dir)

    return cliWithNewStewardName
Exemplo n.º 21
0
def testManual(do, be, poolNodesStarted, poolTxnStewardData, philCli,
               nymAddedOut, attrAddedOut,
               aliceCLI, newKeyringOut, aliceMap,
               tdir, tdirWithClientPoolTxns, syncConnectionOutWithEndpoint, jobCertificateClaimMap,
               syncedInviteAcceptedOutWithoutClaims, transcriptClaimMap,
               reqClaimOut, reqClaimOut1, susanCLI, susanMap):
    eventually.slowFactor = 3

    # Create steward and add nyms and endpoint attributes of all agents
    _, stewardSeed = poolTxnStewardData
    be(philCli)
    do('new wallet Steward', expect=['New wallet Steward created',
                                     'Active wallet set to "Steward"'])

    mapper = {'seed': stewardSeed.decode()}
    do('new key with seed {seed}', expect=['Key created in wallet Steward'],
       mapper=mapper)
    connect_and_check_output(do, philCli.txn_dir)

    # Add nym and endpoint for Faber, Acme and Thrift
    agentIpAddress = "127.0.0.1"
    faberAgentPort = 5555
    acmeAgentPort = 6666
    thriftAgentPort = 7777

    faberHa = "{}:{}".format(agentIpAddress, faberAgentPort)
    acmeHa = "{}:{}".format(agentIpAddress, acmeAgentPort)
    thriftHa = "{}:{}".format(agentIpAddress, thriftAgentPort)
    faberId = FABER_ID
    acmeId = ACME_ID
    thriftId = THRIFT_ID
    faberVerkey = FABER_VERKEY
    acmeVerkey = ACME_VERKEY
    thriftVerkey = THRIFT_VERKEY
    faberPk = '5hmMA64DDQz5NzGJNVtRzNwpkZxktNQds21q3Wxxa62z'
    acmePk = 'C5eqjU7NMVMGGfGfx2ubvX5H9X346bQt5qeziVAo3naQ'
    thriftPk = 'AGBjYvyM3SFnoiDGAEzkSLHvqyzVkXeMZfKDvdpEsC2x'
    for nym, verkey, ha, pk in [(faberId, faberVerkey, faberHa, faberPk),
                                (acmeId, acmeVerkey, acmeHa, acmePk),
                                (thriftId, thriftVerkey, thriftHa, thriftPk)]:
        m = {'remote': nym, 'remote-verkey': verkey,
             'endpoint': json.dumps({ENDPOINT: {'ha': ha, PUBKEY: pk}})}
        do('send NYM dest={{remote}} role={role}'.format(
            role=Roles.TRUST_ANCHOR.name), within=5, expect=nymAddedOut, mapper=m)
        do('send ATTRIB dest={remote} raw={endpoint}', within=5,
           expect=attrAddedOut, mapper=m)
        do('send NYM dest={{remote}} role={role} verkey={{remote-verkey}}'.format(
            role=Roles.TRUST_ANCHOR.name), within=5, expect=nymAddedOut, mapper=m)

    # Start Faber Agent and Acme Agent

    fMap = faberMap(agentIpAddress, faberAgentPort)
    aMap = acmeMap(agentIpAddress, acmeAgentPort)
    tMap = thriftMap(agentIpAddress, thriftAgentPort)

    agentParams = [
        (create_faber, "Faber College", faberAgentPort,
         buildFaberWallet, bootstrap_faber),
        (create_acme, "Acme Corp", acmeAgentPort,
         buildAcmeWallet, bootstrap_acme),
        (create_thrift, "Thrift Bank", thriftAgentPort,
         buildThriftWallet, bootstrap_thrift)
    ]

    for create_agent_fuc, agentName, agentPort, buildAgentWalletFunc, bootstrap_func in agentParams:
        agent = create_agent_fuc(name=agentName, wallet=buildAgentWalletFunc(),
                                 base_dir_path=tdirWithClientPoolTxns, port=agentPort)
        RunnableAgent.run_agent(
            agent, bootstrap=bootstrap_func(agent), looper=philCli.looper)

    for p in philCli.looper.prodables:
        if p.name == 'Faber College':
            faberAgent = p
        if p.name == 'Acme Corp':
            acmeAgent = p
        if p.name == 'Thrift Bank':
            thriftAgent = p

    async def checkTranscriptWritten():
        faberId = faberAgent.wallet.defaultId
        schemaId = ID(SchemaKey("Transcript", "1.2", faberId))
        schema = await faberAgent.issuer.wallet.getSchema(schemaId)
        assert schema
        assert schema.seqId

        issuerPublicKey = await faberAgent.issuer.wallet.getPublicKey(schemaId)
        assert issuerPublicKey  # TODO isinstance(issuerPublicKey, PublicKey)

    async def checkJobCertWritten():
        acmeId = acmeAgent.wallet.defaultId
        schemaId = ID(SchemaKey("Job-Certificate", "0.2", acmeId))
        schema = await acmeAgent.issuer.wallet.getSchema(schemaId)
        assert schema
        assert schema.seqId

        issuerPublicKey = await acmeAgent.issuer.wallet.getPublicKey(schemaId)
        assert issuerPublicKey
        assert issuerPublicKey.seqId

    timeout = waits.expectedTranscriptWritten()
    philCli.looper.run(eventually(checkTranscriptWritten, timeout=timeout))
    timeout = waits.expectedJobCertWritten()
    philCli.looper.run(eventually(checkJobCertWritten, timeout=timeout))

    # Defining inner method for closures
    def executeGstFlow(
            name,
            userCLI,
            userMap,
            be,
            do,
            fMap,
            aMap,
            jobCertificateClaimMap,
            newKeyringOut,
            reqClaimOut,
            reqClaimOut1,
            syncConnectionOutWithEndpoint,
            syncedInviteAcceptedOutWithoutClaims,
            tMap,
            transcriptClaimMap):

        async def getPublicKey(wallet, schemaId):
            return await wallet.getPublicKey(schemaId)

        async def getClaim(schemaId):
            return await userCLI.agent.prover.wallet.getClaimSignature(schemaId)

        # Start User cli

        be(userCLI)
        setPromptAndKeyring(do, name, newKeyringOut, userMap)
        connect_and_check_output(do, philCli.txn_dir)
        # Accept faber
        do('load sample/faber-request.indy')
        syncInvite(be, do, userCLI, syncConnectionOutWithEndpoint, fMap)
        do('show connection faber')
        accept_request(be, do, userCLI, fMap,
                       syncedInviteAcceptedOutWithoutClaims)
        # Request claim
        do('show claim Transcript')
        aliceRequestedTranscriptClaim(be, do, userCLI, transcriptClaimMap,
                                      reqClaimOut,
                                      None,  # Passing None since its not used
                                      None)  # Passing None since its not used

        faberSchemaId = ID(SchemaKey('Transcript', '1.2', fMap['remote']))
        faberIssuerPublicKey = userCLI.looper.run(
            getPublicKey(faberAgent.issuer.wallet, faberSchemaId))
        userFaberIssuerPublicKey = userCLI.looper.run(
            getPublicKey(userCLI.agent.prover.wallet, faberSchemaId))
        assert faberIssuerPublicKey == userFaberIssuerPublicKey

        do('show claim Transcript')
        assert userCLI.looper.run(getClaim(faberSchemaId))

        # Accept acme
        do('load sample/acme-job-application.indy')
        syncInvite(be, do, userCLI, syncConnectionOutWithEndpoint, aMap)
        accept_request(be, do, userCLI, aMap,
                       syncedInviteAcceptedOutWithoutClaims)
        # Send claim
        do('show claim request Job-Application')
        do('set first_name to Alice')
        do('set last_name to Garcia')
        do('set phone_number to 123-45-6789')
        do('show claim request Job-Application')
        # Passing some args as None since they are not used in the method
        jobApplicationProofSent(be, do, userCLI, aMap, None, None, None)
        do('show claim Job-Certificate')
        # Request new available claims Job-Certificate
        jobCertClaimRequested(be, do, userCLI, None,
                              jobCertificateClaimMap, reqClaimOut1, None)

        acmeSchemaId = ID(SchemaKey('Job-Certificate', '0.2', aMap['remote']))
        acmeIssuerPublicKey = userCLI.looper.run(getPublicKey(
            acmeAgent.issuer.wallet, acmeSchemaId))
        userAcmeIssuerPublicKey = userCLI.looper.run(getPublicKey(
            userCLI.agent.prover.wallet, acmeSchemaId))
        assert acmeIssuerPublicKey == userAcmeIssuerPublicKey

        do('show claim Job-Certificate')
        assert userCLI.looper.run(getClaim(acmeSchemaId))

        # Accept thrift
        do('load sample/thrift-loan-application.indy')
        accept_request(be, do, userCLI, tMap,
                       syncedInviteAcceptedOutWithoutClaims)
        # Send proofs
        bankBasicProofSent(be, do, userCLI, tMap, None)

        thriftAcmeIssuerPublicKey = userCLI.looper.run(getPublicKey(
            thriftAgent.issuer.wallet, acmeSchemaId))
        assert acmeIssuerPublicKey == thriftAcmeIssuerPublicKey
        passed = False
        try:
            bankKYCProofSent(be, do, userCLI, tMap, None)
            passed = True
        except BaseException:
            thriftFaberIssuerPublicKey = userCLI.looper.run(getPublicKey(
                thriftAgent.issuer.wallet, faberSchemaId))
            assert faberIssuerPublicKey == thriftFaberIssuerPublicKey
        assert passed

    executeGstFlow("Alice", aliceCLI, aliceMap, be, do, fMap,
                   aMap, jobCertificateClaimMap, newKeyringOut, reqClaimOut,
                   reqClaimOut1, syncConnectionOutWithEndpoint,
                   syncedInviteAcceptedOutWithoutClaims, tMap,
                   transcriptClaimMap)

    aliceCLI.looper.runFor(3)
Exemplo n.º 22
0
def testGettingStartedTutorialAgainstSandbox(newGuyCLI, be, do):
    be(newGuyCLI)
    connect_and_check_output(newGuyCLI.txn_dir)
Exemplo n.º 23
0
    def executeGstFlow(
            name,
            userCLI,
            userMap,
            be,
            do,
            fMap,
            aMap,
            jobCertificateClaimMap,
            newKeyringOut,
            reqClaimOut,
            reqClaimOut1,
            syncConnectionOutWithEndpoint,
            syncedInviteAcceptedOutWithoutClaims,
            tMap,
            transcriptClaimMap):

        async def getPublicKey(wallet, schemaId):
            return await wallet.getPublicKey(schemaId)

        async def getClaim(schemaId):
            return await userCLI.agent.prover.wallet.getClaimSignature(schemaId)

        # Start User cli

        be(userCLI)
        setPromptAndKeyring(do, name, newKeyringOut, userMap)
        connect_and_check_output(do, philCli.txn_dir)
        # Accept faber
        do('load sample/faber-request.indy')
        syncInvite(be, do, userCLI, syncConnectionOutWithEndpoint, fMap)
        do('show connection faber')
        accept_request(be, do, userCLI, fMap,
                       syncedInviteAcceptedOutWithoutClaims)
        # Request claim
        do('show claim Transcript')
        aliceRequestedTranscriptClaim(be, do, userCLI, transcriptClaimMap,
                                      reqClaimOut,
                                      None,  # Passing None since its not used
                                      None)  # Passing None since its not used

        faberSchemaId = ID(SchemaKey('Transcript', '1.2', fMap['remote']))
        faberIssuerPublicKey = userCLI.looper.run(
            getPublicKey(faberAgent.issuer.wallet, faberSchemaId))
        userFaberIssuerPublicKey = userCLI.looper.run(
            getPublicKey(userCLI.agent.prover.wallet, faberSchemaId))
        assert faberIssuerPublicKey == userFaberIssuerPublicKey

        do('show claim Transcript')
        assert userCLI.looper.run(getClaim(faberSchemaId))

        # Accept acme
        do('load sample/acme-job-application.indy')
        syncInvite(be, do, userCLI, syncConnectionOutWithEndpoint, aMap)
        accept_request(be, do, userCLI, aMap,
                       syncedInviteAcceptedOutWithoutClaims)
        # Send claim
        do('show claim request Job-Application')
        do('set first_name to Alice')
        do('set last_name to Garcia')
        do('set phone_number to 123-45-6789')
        do('show claim request Job-Application')
        # Passing some args as None since they are not used in the method
        jobApplicationProofSent(be, do, userCLI, aMap, None, None, None)
        do('show claim Job-Certificate')
        # Request new available claims Job-Certificate
        jobCertClaimRequested(be, do, userCLI, None,
                              jobCertificateClaimMap, reqClaimOut1, None)

        acmeSchemaId = ID(SchemaKey('Job-Certificate', '0.2', aMap['remote']))
        acmeIssuerPublicKey = userCLI.looper.run(getPublicKey(
            acmeAgent.issuer.wallet, acmeSchemaId))
        userAcmeIssuerPublicKey = userCLI.looper.run(getPublicKey(
            userCLI.agent.prover.wallet, acmeSchemaId))
        assert acmeIssuerPublicKey == userAcmeIssuerPublicKey

        do('show claim Job-Certificate')
        assert userCLI.looper.run(getClaim(acmeSchemaId))

        # Accept thrift
        do('load sample/thrift-loan-application.indy')
        accept_request(be, do, userCLI, tMap,
                       syncedInviteAcceptedOutWithoutClaims)
        # Send proofs
        bankBasicProofSent(be, do, userCLI, tMap, None)

        thriftAcmeIssuerPublicKey = userCLI.looper.run(getPublicKey(
            thriftAgent.issuer.wallet, acmeSchemaId))
        assert acmeIssuerPublicKey == thriftAcmeIssuerPublicKey
        passed = False
        try:
            bankKYCProofSent(be, do, userCLI, tMap, None)
            passed = True
        except BaseException:
            thriftFaberIssuerPublicKey = userCLI.looper.run(getPublicKey(
                thriftAgent.issuer.wallet, faberSchemaId))
            assert faberIssuerPublicKey == thriftFaberIssuerPublicKey
        assert passed
Exemplo n.º 24
0
def connectIfNotAlreadyConnected(do, userCli, userMap, expectMsgs=None):
    # TODO: Shouldn't this be testing the cli command `status`?
    if not userCli._isConnectedToAnyEnv():
        connect_and_check_output(do, userCli.txn_dir, expect=expectMsgs, mapper=userMap)
Exemplo n.º 25
0
def testManual(do, be, poolNodesStarted, poolTxnStewardData, philCli,
               nymAddedOut, attrAddedOut,
               aliceCLI, newKeyringOut, aliceMap,
               tdir, tdirWithClientPoolTxns, syncConnectionOutWithEndpoint, jobCertificateClaimMap,
               syncedInviteAcceptedOutWithoutClaims, transcriptClaimMap,
               reqClaimOut, reqClaimOut1, susanCLI, susanMap):
    eventually.slowFactor = 3

    # Create steward and add nyms and endpoint attributes of all agents
    _, stewardSeed = poolTxnStewardData
    be(philCli)
    do('new wallet Steward', expect=['New wallet Steward created',
                                     'Active wallet set to "Steward"'])

    mapper = {'seed': stewardSeed.decode()}
    do('new key with seed {seed}', expect=['Key created in wallet Steward'],
       mapper=mapper)
    connect_and_check_output(do, philCli.txn_dir)

    # Add nym and endpoint for Faber, Acme and Thrift
    agentIpAddress = "127.0.0.1"
    faberAgentPort = 7777
    acmeAgentPort = 8888
    thriftAgentPort = 9999

    faberHa = "{}:{}".format(agentIpAddress, faberAgentPort)
    acmeHa = "{}:{}".format(agentIpAddress, acmeAgentPort)
    thriftHa = "{}:{}".format(agentIpAddress, thriftAgentPort)
    faberId = FABER_ID
    acmeId = ACME_ID
    thriftId = THRIFT_ID
    faberVerkey = FABER_VERKEY
    acmeVerkey = ACME_VERKEY
    thriftVerkey = THRIFT_VERKEY
    faberPk = '5hmMA64DDQz5NzGJNVtRzNwpkZxktNQds21q3Wxxa62z'
    acmePk = 'C5eqjU7NMVMGGfGfx2ubvX5H9X346bQt5qeziVAo3naQ'
    thriftPk = 'AGBjYvyM3SFnoiDGAEzkSLHvqyzVkXeMZfKDvdpEsC2x'
    for nym, verkey, ha, pk in [(faberId, faberVerkey, faberHa, faberPk),
                                (acmeId, acmeVerkey, acmeHa, acmePk),
                                (thriftId, thriftVerkey, thriftHa, thriftPk)]:
        m = {'remote': nym, 'remote-verkey': verkey,
             'endpoint': json.dumps({ENDPOINT: {'ha': ha, PUBKEY: pk}})}
        do('send NYM dest={{remote}} role={role}'.format(
            role=Roles.TRUST_ANCHOR.name), within=5, expect=nymAddedOut, mapper=m)
        do('send ATTRIB dest={remote} raw={endpoint}', within=5,
           expect=attrAddedOut, mapper=m)
        do('send NYM dest={{remote}} role={role} verkey={{remote-verkey}}'.format(
            role=Roles.TRUST_ANCHOR.name), within=5, expect=nymAddedOut, mapper=m)

    # Start Faber Agent and Acme Agent

    fMap = faberMap(agentIpAddress, faberAgentPort)
    aMap = acmeMap(agentIpAddress, acmeAgentPort)
    tMap = thriftMap(agentIpAddress, thriftAgentPort)

    agentParams = [
        (create_faber, "Faber College", faberAgentPort,
         buildFaberWallet, bootstrap_faber),
        (create_acme, "Acme Corp", acmeAgentPort,
         buildAcmeWallet, bootstrap_acme),
        (create_thrift, "Thrift Bank", thriftAgentPort,
         buildThriftWallet, bootstrap_thrift)
    ]

    for create_agent_fuc, agentName, agentPort, buildAgentWalletFunc, bootstrap_func in agentParams:
        agent = create_agent_fuc(name=agentName, wallet=buildAgentWalletFunc(),
                                 base_dir_path=tdirWithClientPoolTxns, port=agentPort)
        RunnableAgent.run_agent(
            agent, bootstrap=bootstrap_func(agent), looper=philCli.looper)

    for p in philCli.looper.prodables:
        if p.name == 'Faber College':
            faberAgent = p
        if p.name == 'Acme Corp':
            acmeAgent = p
        if p.name == 'Thrift Bank':
            thriftAgent = p

    async def checkTranscriptWritten():
        faberId = faberAgent.wallet.defaultId
        schemaId = ID(SchemaKey("Transcript", "1.2", faberId))
        schema = await faberAgent.issuer.wallet.getSchema(schemaId)
        assert schema
        assert schema.seqId

        issuerPublicKey = await faberAgent.issuer.wallet.getPublicKey(schemaId)
        assert issuerPublicKey  # TODO isinstance(issuerPublicKey, PublicKey)

    async def checkJobCertWritten():
        acmeId = acmeAgent.wallet.defaultId
        schemaId = ID(SchemaKey("Job-Certificate", "0.2", acmeId))
        schema = await acmeAgent.issuer.wallet.getSchema(schemaId)
        assert schema
        assert schema.seqId

        issuerPublicKey = await acmeAgent.issuer.wallet.getPublicKey(schemaId)
        assert issuerPublicKey
        assert issuerPublicKey.seqId

    timeout = waits.expectedTranscriptWritten()
    philCli.looper.run(eventually(checkTranscriptWritten, timeout=timeout))
    timeout = waits.expectedJobCertWritten()
    philCli.looper.run(eventually(checkJobCertWritten, timeout=timeout))

    # Defining inner method for closures
    def executeGstFlow(
            name,
            userCLI,
            userMap,
            be,
            do,
            fMap,
            aMap,
            jobCertificateClaimMap,
            newKeyringOut,
            reqClaimOut,
            reqClaimOut1,
            syncConnectionOutWithEndpoint,
            syncedInviteAcceptedOutWithoutClaims,
            tMap,
            transcriptClaimMap):

        async def getPublicKey(wallet, schemaId):
            return await wallet.getPublicKey(schemaId)

        async def getClaim(schemaId):
            return await userCLI.agent.prover.wallet.getClaimSignature(schemaId)

        # Start User cli

        be(userCLI)
        setPromptAndKeyring(do, name, newKeyringOut, userMap)
        connect_and_check_output(do, philCli.txn_dir)
        # Accept faber
        do('load sample/faber-request.indy')
        syncInvite(be, do, userCLI, syncConnectionOutWithEndpoint, fMap)
        do('show connection faber')
        accept_request(be, do, userCLI, fMap,
                       syncedInviteAcceptedOutWithoutClaims)
        # Request claim
        do('show claim Transcript')
        aliceRequestedTranscriptClaim(be, do, userCLI, transcriptClaimMap,
                                      reqClaimOut,
                                      None,  # Passing None since its not used
                                      None)  # Passing None since its not used

        faberSchemaId = ID(SchemaKey('Transcript', '1.2', fMap['remote']))
        faberIssuerPublicKey = userCLI.looper.run(
            getPublicKey(faberAgent.issuer.wallet, faberSchemaId))
        userFaberIssuerPublicKey = userCLI.looper.run(
            getPublicKey(userCLI.agent.prover.wallet, faberSchemaId))
        assert faberIssuerPublicKey == userFaberIssuerPublicKey

        do('show claim Transcript')
        assert userCLI.looper.run(getClaim(faberSchemaId))

        # Accept acme
        do('load sample/acme-job-application.indy')
        syncInvite(be, do, userCLI, syncConnectionOutWithEndpoint, aMap)
        accept_request(be, do, userCLI, aMap,
                       syncedInviteAcceptedOutWithoutClaims)
        # Send claim
        do('show claim request Job-Application')
        do('set first_name to Alice')
        do('set last_name to Garcia')
        do('set phone_number to 123-45-6789')
        do('show claim request Job-Application')
        # Passing some args as None since they are not used in the method
        jobApplicationProofSent(be, do, userCLI, aMap, None, None, None)
        do('show claim Job-Certificate')
        # Request new available claims Job-Certificate
        jobCertClaimRequested(be, do, userCLI, None,
                              jobCertificateClaimMap, reqClaimOut1, None)

        acmeSchemaId = ID(SchemaKey('Job-Certificate', '0.2', aMap['remote']))
        acmeIssuerPublicKey = userCLI.looper.run(getPublicKey(
            acmeAgent.issuer.wallet, acmeSchemaId))
        userAcmeIssuerPublicKey = userCLI.looper.run(getPublicKey(
            userCLI.agent.prover.wallet, acmeSchemaId))
        assert acmeIssuerPublicKey == userAcmeIssuerPublicKey

        do('show claim Job-Certificate')
        assert userCLI.looper.run(getClaim(acmeSchemaId))

        # Accept thrift
        do('load sample/thrift-loan-application.indy')
        accept_request(be, do, userCLI, tMap,
                       syncedInviteAcceptedOutWithoutClaims)
        # Send proofs
        bankBasicProofSent(be, do, userCLI, tMap, None)

        thriftAcmeIssuerPublicKey = userCLI.looper.run(getPublicKey(
            thriftAgent.issuer.wallet, acmeSchemaId))
        assert acmeIssuerPublicKey == thriftAcmeIssuerPublicKey
        passed = False
        try:
            bankKYCProofSent(be, do, userCLI, tMap, None)
            passed = True
        except BaseException:
            thriftFaberIssuerPublicKey = userCLI.looper.run(getPublicKey(
                thriftAgent.issuer.wallet, faberSchemaId))
            assert faberIssuerPublicKey == thriftFaberIssuerPublicKey
        assert passed

    executeGstFlow("Alice", aliceCLI, aliceMap, be, do, fMap,
                   aMap, jobCertificateClaimMap, newKeyringOut, reqClaimOut,
                   reqClaimOut1, syncConnectionOutWithEndpoint,
                   syncedInviteAcceptedOutWithoutClaims, tMap,
                   transcriptClaimMap)

    aliceCLI.looper.runFor(3)
Exemplo n.º 26
0
    def executeGstFlow(
            name,
            userCLI,
            userMap,
            be,
            do,
            fMap,
            aMap,
            jobCertificateClaimMap,
            newKeyringOut,
            reqClaimOut,
            reqClaimOut1,
            syncConnectionOutWithEndpoint,
            syncedInviteAcceptedOutWithoutClaims,
            tMap,
            transcriptClaimMap):

        async def getPublicKey(wallet, schemaId):
            return await wallet.getPublicKey(schemaId)

        async def getClaim(schemaId):
            return await userCLI.agent.prover.wallet.getClaimSignature(schemaId)

        # Start User cli

        be(userCLI)
        setPromptAndKeyring(do, name, newKeyringOut, userMap)
        connect_and_check_output(do, philCli.txn_dir)
        # Accept faber
        do('load sample/faber-request.indy')
        syncInvite(be, do, userCLI, syncConnectionOutWithEndpoint, fMap)
        do('show connection faber')
        accept_request(be, do, userCLI, fMap,
                       syncedInviteAcceptedOutWithoutClaims)
        # Request claim
        do('show claim Transcript')
        aliceRequestedTranscriptClaim(be, do, userCLI, transcriptClaimMap,
                                      reqClaimOut,
                                      None,  # Passing None since its not used
                                      None)  # Passing None since its not used

        faberSchemaId = ID(SchemaKey('Transcript', '1.2', fMap['remote']))
        faberIssuerPublicKey = userCLI.looper.run(
            getPublicKey(faberAgent.issuer.wallet, faberSchemaId))
        userFaberIssuerPublicKey = userCLI.looper.run(
            getPublicKey(userCLI.agent.prover.wallet, faberSchemaId))
        assert faberIssuerPublicKey == userFaberIssuerPublicKey

        do('show claim Transcript')
        assert userCLI.looper.run(getClaim(faberSchemaId))

        # Accept acme
        do('load sample/acme-job-application.indy')
        syncInvite(be, do, userCLI, syncConnectionOutWithEndpoint, aMap)
        accept_request(be, do, userCLI, aMap,
                       syncedInviteAcceptedOutWithoutClaims)
        # Send claim
        do('show claim request Job-Application')
        do('set first_name to Alice')
        do('set last_name to Garcia')
        do('set phone_number to 123-45-6789')
        do('show claim request Job-Application')
        # Passing some args as None since they are not used in the method
        jobApplicationProofSent(be, do, userCLI, aMap, None, None, None)
        do('show claim Job-Certificate')
        # Request new available claims Job-Certificate
        jobCertClaimRequested(be, do, userCLI, None,
                              jobCertificateClaimMap, reqClaimOut1, None)

        acmeSchemaId = ID(SchemaKey('Job-Certificate', '0.2', aMap['remote']))
        acmeIssuerPublicKey = userCLI.looper.run(getPublicKey(
            acmeAgent.issuer.wallet, acmeSchemaId))
        userAcmeIssuerPublicKey = userCLI.looper.run(getPublicKey(
            userCLI.agent.prover.wallet, acmeSchemaId))
        assert acmeIssuerPublicKey == userAcmeIssuerPublicKey

        do('show claim Job-Certificate')
        assert userCLI.looper.run(getClaim(acmeSchemaId))

        # Accept thrift
        do('load sample/thrift-loan-application.indy')
        accept_request(be, do, userCLI, tMap,
                       syncedInviteAcceptedOutWithoutClaims)
        # Send proofs
        bankBasicProofSent(be, do, userCLI, tMap, None)

        thriftAcmeIssuerPublicKey = userCLI.looper.run(getPublicKey(
            thriftAgent.issuer.wallet, acmeSchemaId))
        assert acmeIssuerPublicKey == thriftAcmeIssuerPublicKey
        passed = False
        try:
            bankKYCProofSent(be, do, userCLI, tMap, None)
            passed = True
        except BaseException:
            thriftFaberIssuerPublicKey = userCLI.looper.run(getPublicKey(
                thriftAgent.issuer.wallet, faberSchemaId))
            assert faberIssuerPublicKey == thriftFaberIssuerPublicKey
        assert passed
Exemplo n.º 27
0
 def checkWalletRestore():
     # open cli again
     aliceCliNew = yield from CliBuilder(name)
     # check message of saved wallet alice restored
     be(aliceCliNew)
     connect_and_check_output(do, aliceCliNew.txn_dir, expect=savedKeyringRestored, mapper=aliceKeyringMap)
Exemplo n.º 28
0
def aliceCli(be, do, poolNodesStarted, aliceCLI, wallet):
    be(aliceCLI)
    do('prompt Alice', expect=prompt_is('Alice'))
    addAndActivateCLIWallet(aliceCLI, wallet)
    connect_and_check_output(do, aliceCLI.txn_dir)
    return aliceCLI
Exemplo n.º 29
0
def testGettingStartedTutorialAgainstSandbox(newGuyCLI, be, do):
    be(newGuyCLI)
    connect_and_check_output(newGuyCLI.txn_dir)
Exemplo n.º 30
0
def aliceCli(be, do, poolNodesStarted, aliceCLI, wallet):
    be(aliceCLI)
    do('prompt Alice', expect=prompt_is('Alice'))
    addAndActivateCLIWallet(aliceCLI, wallet)
    connect_and_check_output(do, aliceCLI.txn_dir)
    return aliceCLI