예제 #1
0
def test_non_steward_cannot_create_trust_anchor(
        nodeSet, trustAnchor, addedTrustAnchor, client1, looper):

    with whitelistextras("UnknownIdentifier"):
        non_permission = Wallet()
        signer = DidSigner()
        non_permission.addIdentifier(signer=signer)

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

        op = add_nym_operation(
            seed=b'a secret trust anchor seed......', role=TRUST_ANCHOR)

        submitAndCheckRejects(
            looper=looper,
            client=client1,
            wallet=non_permission,
            op=op,
            identifier=non_permission.defaultId,
            contains="UnauthorizedClientRequest")
예제 #2
0
def test_non_trust_anchor_cannot_add_attribute_for_user(nodeSet, nonTrustAnchor, trustAnchor, addedTrustAnchor, userIdA,
                                            looper, attributeData):
    with whitelistextras('UnauthorizedClientRequest'):
        client, wallet = nonTrustAnchor

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

        attrib = Attribute(name='test1 attribute',
                           origin=wallet.defaultId,
                           value=attributeData,
                           dest=userIdA,
                           ledgerStore=LedgerStore.RAW)
        reqs = makeAttribRequest(client, wallet, attrib)
        timeout = waits.expectedTransactionExecutionTime(len(nodeSet))
        looper.run(eventually(checkRejects,
                              client,
                              reqs[0].reqId,
                              "UnauthorizedClientRequest('Only identity "
                              "owner/guardian can add attribute for that identity'",
                              retryWait=1, timeout=timeout))
예제 #3
0
def test_non_trust_anchor_cannot_add_attribute_for_user(
        nodeSet,
        nonTrustAnchor,
        trustAnchor,
        addedTrustAnchor,
        userIdA,
        looper,
        attributeData):
    with whitelistextras('UnauthorizedClientRequest'):
        client, wallet = nonTrustAnchor

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

        attrib = Attribute(name='test1 attribute',
                           origin=wallet.defaultId,
                           value=attributeData,
                           dest=userIdA,
                           ledgerStore=LedgerStore.RAW)
        reqs = makeAttribRequest(client, wallet, attrib)
        timeout = waits.expectedTransactionExecutionTime(len(nodeSet))
        looper.run(
            eventually(
                checkRejects,
                client,
                reqs[0].reqId,
                "UnauthorizedClientRequest('Only identity "
                "owner/guardian can add attribute for that identity'",
                retryWait=1,
                timeout=timeout))
예제 #4
0
def test_attr_with_no_dest_added(nodeSet, tdir, looper,
                                 trustAnchor, addedTrustAnchor, attributeData):
    user_wallet = Wallet()
    signer = DidSigner()
    user_wallet.addIdentifier(signer=signer)

    client, _ = genTestClient(nodeSet, tmpdir=tdir, 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)
예제 #5
0
def test_attr_with_no_dest_added(nodeSet, tdir, looper,
                                 trustAnchor, addedTrustAnchor, attributeData):
    user_wallet = Wallet()
    signer = DidSigner()
    user_wallet.addIdentifier(signer=signer)

    client, _ = genTestClient(nodeSet, tmpdir=tdir, 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)
예제 #6
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
예제 #7
0
def faberAdded(poolNodesCreated, looper, aliceCLI, faberInviteLoaded,
               aliceConnected, steward, stewardWallet):
    li = getLinkInvitation("Faber", aliceCLI.activeWallet)
    createNym(looper,
              li.remoteIdentifier,
              steward,
              stewardWallet,
              role=TRUST_ANCHOR)
예제 #8
0
def testStewardCreatesAnotherTrustAnchor(
        nodeSet,
        steward,
        stewardWallet,
        looper,
        trustAnchorWallet):
    createNym(looper, trustAnchorWallet.defaultId, steward, stewardWallet,
              TRUST_ANCHOR)
    return trustAnchorWallet
def didAddedWithFullVerkey(addedTrustAnchor, looper, trustAnchor,
                           trustAnchorWallet, wallet, fullKeyIdr):
    """{ type: NYM, dest: <id1> }"""
    createNym(looper,
              fullKeyIdr,
              trustAnchor,
              trustAnchorWallet,
              verkey=wallet.getVerkey(fullKeyIdr))
    return wallet
예제 #10
0
def addedTrustAnchor(nodeSet, steward, stewardWallet, looper,
                 trustAnchorWallet):
    createNym(looper,
              trustAnchorWallet.defaultId,
              steward,
              stewardWallet,
              role=TRUST_ANCHOR,
              verkey=trustAnchorWallet.getVerkey())
    return trustAnchorWallet
def didAddedWithAbbrvVerkey(addedTrustAnchor, looper, trustAnchor,
                            trustAnchorWallet, wallet, abbrevIdr):
    """{ type: NYM, dest: <id1> }"""
    createNym(looper,
              abbrevIdr,
              trustAnchor,
              trustAnchorWallet,
              verkey=wallet.getVerkey(abbrevIdr))
    return wallet
예제 #12
0
def addedTrustAnchor(nodeSet, steward, stewardWallet, looper,
                     trustAnchorWallet):
    createNym(looper,
              trustAnchorWallet.defaultId,
              steward,
              stewardWallet,
              role=TRUST_ANCHOR,
              verkey=trustAnchorWallet.getVerkey())
    return trustAnchorWallet
예제 #13
0
def faberAdded(poolNodesCreated,
             looper,
             aliceCLI,
             faberInviteLoaded,
             aliceConnected,
            steward, stewardWallet):
    li = getLinkInvitation("Faber", aliceCLI.activeWallet)
    createNym(looper, li.remoteIdentifier, steward, stewardWallet,
              role=TRUST_ANCHOR)
예제 #14
0
def anotherTrustAnchor(nodeSet, steward, stewardWallet, tdir, looper):
    sseed = b'1 secret trust anchor seed......'
    signer = DidSigner(seed=sseed)
    c, _ = genTestClient(nodeSet, tmpdir=tdir, usePoolLedger=True)
    w = Wallet(c.name)
    w.addIdentifier(signer=signer)
    c.registerObserver(w.handleIncomingReply)
    looper.add(c)
    looper.run(c.ensureConnectedToNodes())
    createNym(looper, signer.identifier, steward, stewardWallet,
              role=TRUST_ANCHOR, verkey=signer.verkey)
    return c, w
예제 #15
0
def anotherTrustAnchor(nodeSet, steward, stewardWallet, tdir, looper):
    sseed = b'1 secret trust anchor seed......'
    signer = DidSigner(seed=sseed)
    c, _ = genTestClient(nodeSet, tmpdir=tdir, usePoolLedger=True)
    w = Wallet(c.name)
    w.addIdentifier(signer=signer)
    c.registerObserver(w.handleIncomingReply)
    looper.add(c)
    looper.run(c.ensureConnectedToNodes())
    createNym(looper, signer.identifier, steward, stewardWallet,
              role=TRUST_ANCHOR, verkey=signer.verkey)
    return c, w
예제 #16
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)
예제 #17
0
def test_non_trust_anchor_cannot_create_user(nodeSet, looper, trustAnchor, addedTrustAnchor, client1):
    with whitelistextras("UnknownIdentifier"):
        non_trust_anchor = Wallet()
        signer = DidSigner()
        non_trust_anchor.addIdentifier(signer=signer)

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

        op = add_nym_operation(seed=b'a secret trust anchor seed......')

        submitAndCheckRejects(looper=looper, client=client1, wallet=non_trust_anchor, op=op,
                              identifier=non_trust_anchor.defaultId,
                              contains="UnauthorizedClientRequest")
예제 #18
0
def addNyms():
    with Looper(debug=True) as looper:

        from sovrin_client.test.helper import createNym

        # Starting clients
        print("Spawning client")
        client, wallet = spawnClient(stewardName, 5678, stewardSeed)
        client.registerObserver(wallet.handleIncomingReply)
        print("Adding it to looper")
        looper.add(client)
        print("Running it")
        looper.run(ensureConnectedToNodes(client))

        # Creating request
        print("Creating request")
        bad = []
        for seed in trustAnchorSeeds:
            signer = DidSigner(seed=seed.encode())
            nym = signer.identifier
            verkey = signer.verkey
            # Sending requests
            print("Creating nym for seed {}".format(seed))
            try:
                createNym(looper=looper,
                          nym=nym,
                          creatorClient=client,
                          creatorWallet=wallet,
                          verkey=verkey,
                          role=TRUST_ANCHOR)
                print("Successfully created nym for {}".format(seed))
            except Exception as ex:
                bad.append(seed)
                print("Failed to create nym for {}".format(seed))

        print("=======================")
        if not bad:
            print("All nyms created successfully")
        else:
            print("Failed to created nyms for:")
            for nym in bad:
                print("-", nym)
        print("=======================")
예제 #19
0
def addNyms():
    with Looper(debug=True) as looper:

        from sovrin_client.test.helper import createNym

        # Starting clients
        print("Spawning client")
        client, wallet = spawnClient(stewardName, 5678, stewardSeed)
        client.registerObserver(wallet.handleIncomingReply)
        print("Adding it to looper")
        looper.add(client)
        print("Running it")
        looper.run(ensureConnectedToNodes(client))

        # Creating request
        print("Creating request")
        bad = []
        for seed in trustAnchorSeeds:
            signer = SimpleSigner(seed=seed.encode())
            nym = signer.identifier
            verkey = signer.verkey
            # Sending requests
            print("Creating nym for seed {}".format(seed))
            try:
                createNym(looper=looper, nym=nym, creatorClient=client,
                          creatorWallet=wallet, verkey=verkey, role=TRUST_ANCHOR)
                print("Successfully created nym for {}".format(seed))
            except Exception as ex:
                bad.append(seed)
                print("Failed to create nym for {}".format(seed))


        print("=======================")
        if not bad:
            print("All nyms created successfully")
        else:
            print("Failed to created nyms for:")
            for nym in bad:
                print("-", nym)
        print("=======================")
예제 #20
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
def didAddedWithoutVerkey(addedTrustAnchor, looper, trustAnchor,
                          trustAnchorWallet, wallet, noKeyIdr):
    """{ type: NYM, dest: <id1> }"""
    createNym(looper, noKeyIdr, trustAnchor, trustAnchorWallet)
    return wallet
def didAddedWithAbbrvVerkey(addedTrustAnchor, looper, trustAnchor, trustAnchorWallet,
                          wallet, abbrevIdr):
    """{ type: NYM, dest: <id1> }"""
    createNym(looper, abbrevIdr, trustAnchor, trustAnchorWallet,
              verkey=wallet.getVerkey(abbrevIdr))
    return wallet
예제 #23
0
def testStewardCreatesAnotherTrustAnchor(nodeSet, steward, stewardWallet, looper,
                                     trustAnchorWallet):
    createNym(looper, trustAnchorWallet.defaultId, steward, stewardWallet,
              TRUST_ANCHOR)
    return trustAnchorWallet