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 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)
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")
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)
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")
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))
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))
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 faberAdded(poolNodesCreated, looper, aliceCLI, faberInviteLoaded, aliceConnected, steward, stewardWallet): li = get_connection_request("Faber", aliceCLI.activeWallet) createNym(looper, li.remoteIdentifier, steward, stewardWallet, role=TRUST_ANCHOR)
def added_client_without_role(steward, stewardWallet, looper, wallet1): createNym(looper, wallet1.defaultId, steward, stewardWallet, role=None, verkey=wallet1.getVerkey()) return wallet1
def faberAdded(poolNodesCreated, looper, aliceCLI, faberInviteLoaded, aliceConnected, steward, stewardWallet): li = get_connection_request("Faber", aliceCLI.activeWallet) createNym(looper, li.remoteIdentifier, steward, stewardWallet, role=TRUST_ANCHOR)
def didAddedWithAbbrvVerkey(addedTrustAnchor, looper, trustAnchor, trustAnchorWallet, wallet, abbrevIdr): """{ type: NYM, dest: <id1> }""" createNym(looper, abbrevIdr, trustAnchor, trustAnchorWallet, verkey=wallet.getVerkey(abbrevIdr)) return wallet
def didAddedWithFullVerkey(addedTrustAnchor, looper, trustAnchor, trustAnchorWallet, wallet, fullKeyIdr): """{ type: NYM, dest: <id1> }""" createNym(looper, fullKeyIdr, trustAnchor, trustAnchorWallet, verkey=wallet.getVerkey(fullKeyIdr)) return wallet
def added_client_without_role(steward, stewardWallet, looper, wallet1): createNym(looper, wallet1.defaultId, steward, stewardWallet, role=None, verkey=wallet1.getVerkey()) return wallet1
def testStewardCreatesAnotherTrustAnchor( nodeSet, steward, stewardWallet, looper, trustAnchorWallet): createNym(looper, trustAnchorWallet.defaultId, steward, stewardWallet, TRUST_ANCHOR) return trustAnchorWallet
def addedTrustAnchor(nodeSet, steward, stewardWallet, looper, trustAnchorWallet): createNym(looper, trustAnchorWallet.defaultId, steward, stewardWallet, role=TRUST_ANCHOR, verkey=trustAnchorWallet.getVerkey()) return trustAnchorWallet
def addedTrustAnchor(nodeSet, steward, stewardWallet, looper, trustAnchorWallet): createNym(looper, trustAnchorWallet.defaultId, steward, stewardWallet, role=TRUST_ANCHOR, verkey=trustAnchorWallet.getVerkey()) return trustAnchorWallet
def didAddedWithoutVerkey( addedTrustAnchor, looper, trustAnchor, trustAnchorWallet, wallet, noKeyIdr): """{ type: NYM, dest: <id1> }""" createNym(looper, noKeyIdr, trustAnchor, trustAnchorWallet) return wallet
def didAddedWithFullVerkey( addedTrustAnchor, looper, trustAnchor, trustAnchorWallet, wallet, fullKeyIdr): """{ type: NYM, dest: <id1> }""" createNym(looper, fullKeyIdr, trustAnchor, trustAnchorWallet, verkey=wallet.getVerkey(fullKeyIdr)) 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
def anotherTrustAnchor(nodeSet, steward, stewardWallet, tdirWithClientPoolTxns, looper): sseed = b'1 secret trust anchor seed......' signer = DidSigner(seed=sseed) c, _ = genTestClient(nodeSet, tmpdir=tdirWithClientPoolTxns, 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
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)
def addNyms(): with Looper(debug=getConfig().LOOPER_DEBUG) as looper: from indy_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("=======================")
def addNyms(): with Looper(debug=getConfig().LOOPER_DEBUG) as looper: from indy_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("=======================")
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)
def testStewardCreatesAnotherTrustAnchor(nodeSet, steward, stewardWallet, looper, trustAnchorWallet): createNym(looper, trustAnchorWallet.defaultId, steward, stewardWallet, TRUST_ANCHOR) return trustAnchorWallet
def didAddedWithoutVerkey(addedTrustAnchor, looper, trustAnchor, trustAnchorWallet, wallet, noKeyIdr): """{ type: NYM, dest: <id1> }""" createNym(looper, noKeyIdr, trustAnchor, trustAnchorWallet) return wallet