Beispiel #1
0
def addAgent(looper, agent, steward, stewardWallet):
    # 1. add Agent's NYM (by Steward)
    agentNym = agent.wallet.defaultId
    createNym(looper,
              agentNym,
              steward,
              stewardWallet,
              role=TRUST_ANCHOR,
              verkey=agent.wallet.getVerkey())

    # 2. add client to the loop
    looper.add(agent.client)

    # 3. add attribute to the Agent's NYM with endpoint information (by
    # Agent's client)
    ep = '127.0.0.1:{}'.format(agent.port)
    attributeData = json.dumps({ENDPOINT: {'ha': ep}})

    attrib = Attribute(name='{}_endpoint'.format(agentNym),
                       origin=agentNym,
                       value=attributeData,
                       dest=agentNym,
                       ledgerStore=LedgerStore.RAW)
    addAttributeAndCheck(looper, agent.client, agent.wallet, attrib)
    return attrib
Beispiel #2
0
def test_attr_with_no_dest_added(nodeSet, tdirWithClientPoolTxns, looper,
                                 trustAnchor, addedTrustAnchor, attributeData):
    user_wallet = Wallet()
    signer = DidSigner()
    user_wallet.addIdentifier(signer=signer)

    client, _ = genTestClient(nodeSet,
                              tmpdir=tdirWithClientPoolTxns,
                              usePoolLedger=True)
    client.registerObserver(user_wallet.handleIncomingReply)
    looper.add(client)
    looper.run(client.ensureConnectedToNodes())
    makePendingTxnsRequest(client, user_wallet)

    createNym(looper,
              user_wallet.defaultId,
              trustAnchor,
              addedTrustAnchor,
              role=None,
              verkey=user_wallet.getVerkey())

    attr1 = json.dumps({'age': "24"})
    attrib = Attribute(name='test4 attribute',
                       origin=user_wallet.defaultId,
                       value=attr1,
                       dest=None,
                       ledgerStore=LedgerStore.RAW)
    addAttributeAndCheck(looper, client, user_wallet, attrib)
Beispiel #3
0
def testLatestAttrIsReceived(nodeSet, addedTrustAnchor, trustAnchorWallet,
                             looper, trustAnchor, userIdA):
    attr1 = json.dumps({'name': 'Mario'})
    attrib = Attribute(name='name',
                       origin=trustAnchorWallet.defaultId,
                       value=attr1,
                       dest=userIdA,
                       ledgerStore=LedgerStore.RAW)
    addAttributeAndCheck(looper, trustAnchor, trustAnchorWallet, attrib)
    assert attr1 in [
        a.value for a in trustAnchorWallet.getAttributesForNym(userIdA)
    ]

    attr2 = json.dumps({'name': 'Luigi'})
    attrib = Attribute(name='name',
                       origin=trustAnchorWallet.defaultId,
                       value=attr2,
                       dest=userIdA,
                       ledgerStore=LedgerStore.RAW)
    addAttributeAndCheck(looper, trustAnchor, trustAnchorWallet, attrib)
    logger.debug(
        [a.value for a in trustAnchorWallet.getAttributesForNym(userIdA)])
    assert attr2 in [
        a.value for a in trustAnchorWallet.getAttributesForNym(userIdA)
    ]
Beispiel #4
0
def addAgent(looper, agent, steward, stewardWallet):
    # 1. add Agent's NYM (by Steward)
    agentNym = agent.wallet.defaultId
    createNym(looper,
              agentNym,
              steward,
              stewardWallet,
              role=TRUST_ANCHOR,
              verkey=agent.wallet.getVerkey())

    # 2. add client to the loop
    looper.add(agent.client)

    # 3. add attribute to the Agent's NYM with endpoint information (by
    # Agent's client)
    ep = '127.0.0.1:{}'.format(agent.port)
    attributeData = json.dumps({ENDPOINT: {'ha': ep}})

    attrib = Attribute(name='{}_endpoint'.format(agentNym),
                       origin=agentNym,
                       value=attributeData,
                       dest=agentNym,
                       ledgerStore=LedgerStore.RAW)
    addAttributeAndCheck(looper, agent.client, agent.wallet, attrib)
    return attrib
Beispiel #5
0
def test_attr_with_no_dest_added(nodeSet, tdirWithClientPoolTxns, looper,
                                 trustAnchor, addedTrustAnchor, attributeData):
    user_wallet = Wallet()
    signer = DidSigner()
    user_wallet.addIdentifier(signer=signer)

    client, _ = genTestClient(nodeSet, tmpdir=tdirWithClientPoolTxns, usePoolLedger=True)
    client.registerObserver(user_wallet.handleIncomingReply)
    looper.add(client)
    looper.run(client.ensureConnectedToNodes())
    makePendingTxnsRequest(client, user_wallet)

    createNym(looper,
              user_wallet.defaultId,
              trustAnchor,
              addedTrustAnchor,
              role=None,
              verkey=user_wallet.getVerkey())

    attr1 = json.dumps({'age': "24"})
    attrib = Attribute(name='test4 attribute',
                       origin=user_wallet.defaultId,
                       value=attr1,
                       dest=None,
                       ledgerStore=LedgerStore.RAW)
    addAttributeAndCheck(looper, client, user_wallet, attrib)
Beispiel #6
0
def testLatestAttrIsReceived(
        nodeSet,
        addedTrustAnchor,
        trustAnchorWallet,
        looper,
        trustAnchor,
        userIdA):
    attr1 = json.dumps({'name': 'Mario'})
    attrib = Attribute(name='name',
                       origin=trustAnchorWallet.defaultId,
                       value=attr1,
                       dest=userIdA,
                       ledgerStore=LedgerStore.RAW)
    addAttributeAndCheck(looper, trustAnchor, trustAnchorWallet, attrib)
    assert attr1 in [
        a.value for a in trustAnchorWallet.getAttributesForNym(userIdA)]

    attr2 = json.dumps({'name': 'Luigi'})
    attrib = Attribute(name='name',
                       origin=trustAnchorWallet.defaultId,
                       value=attr2,
                       dest=userIdA,
                       ledgerStore=LedgerStore.RAW)
    addAttributeAndCheck(looper, trustAnchor, trustAnchorWallet, attrib)
    logger.debug(
        [a.value for a in trustAnchorWallet.getAttributesForNym(userIdA)])
    assert attr2 in [a.value for a in
                     trustAnchorWallet.getAttributesForNym(userIdA)]
Beispiel #7
0
def addedRawAttribute(userWalletA: Wallet, trustAnchor: Client,
                      trustAnchorWallet: Wallet, attributeData, looper):
    attrib = Attribute(name='test attribute',
                       origin=trustAnchorWallet.defaultId,
                       value=attributeData,
                       dest=userWalletA.defaultId,
                       ledgerStore=LedgerStore.RAW)
    addAttributeAndCheck(looper, trustAnchor, trustAnchorWallet, attrib)
    return attrib
Beispiel #8
0
def addedRawAttribute(userWalletA: Wallet, trustAnchor: Client,
                      trustAnchorWallet: Wallet, attributeData, looper):
    attrib = Attribute(name='test attribute',
                       origin=trustAnchorWallet.defaultId,
                       value=attributeData,
                       dest=userWalletA.defaultId,
                       ledgerStore=LedgerStore.RAW)
    addAttributeAndCheck(looper, trustAnchor, trustAnchorWallet, attrib)
    return attrib
Beispiel #9
0
def test_user_add_attrs_for_herself(nodeSet, looper, userClientA, userWalletA,
                                    userIdA, trustAnchor, addedTrustAnchor,
                                    attributeData):
    createNym(looper,
              userWalletA.defaultId,
              trustAnchor,
              addedTrustAnchor,
              role=None,
              verkey=userWalletA.getVerkey())

    attr1 = json.dumps({'age': "25"})
    attrib = Attribute(name='test4 attribute',
                       origin=userIdA,
                       value=attr1,
                       dest=userIdA,
                       ledgerStore=LedgerStore.RAW)
    addAttributeAndCheck(looper, userClientA, userWalletA, attrib)
Beispiel #10
0
def test_user_add_attrs_for_herself(
        nodeSet,
        looper,
        userClientA,
        userWalletA,
        userIdA,
        trustAnchor,
        addedTrustAnchor,
        attributeData):
    createNym(looper,
              userWalletA.defaultId,
              trustAnchor,
              addedTrustAnchor,
              role=None,
              verkey=userWalletA.getVerkey())

    attr1 = json.dumps({'age': "25"})
    attrib = Attribute(name='test4 attribute',
                       origin=userIdA,
                       value=attr1,
                       dest=userIdA,
                       ledgerStore=LedgerStore.RAW)
    addAttributeAndCheck(looper, userClientA, userWalletA, attrib)