Esempio n. 1
0
def walletCreatedForTestEnv(preRequisite, be, do, earlCLI):
    be(earlCLI)
    createAndAssertNewKeyringCreation(do, "default1")
    createAndAssertNewKeyringCreation(do, "default2")
    connectIfNotAlreadyConnected(do, earlCLI, {})
    createAndAssertNewKeyringCreation(do, "test2")
    exitFromCli(do)
def testConsecutiveAddSameNodeWithOnlyAliasChange(be, do,
                                                  newStewardCli, newNodeAdded):
    be(newStewardCli)
    vals['newNodeData'][ALIAS] = randomString(6)
    doNodeCmd(do, nodeData=vals,
              expMsgs=['existing data has conflicts with request data'])
    exitFromCli(do)
Esempio n. 3
0
def walletCreatedForTestEnv(preRequisite, be, do, earlCLI, connectedToTest):
    be(earlCLI)
    createAndAssertNewKeyringCreation(do, "default1")
    createAndAssertNewKeyringCreation(do, "default2")
    connectIfNotAlreadyConnected(do, connectedToTest, earlCLI, {})
    createAndAssertNewKeyringCreation(do, "test2")
    exitFromCli(do)
Esempio n. 4
0
def testConsecutiveAddSameNodeWithoutAnyChange(be, do, newStewardCli,
                                               newNodeVals, newNodeAdded):
    be(newStewardCli)
    doSendNodeCmd(do,
                  newNodeVals,
                  expMsgs=['node already has the same data as requested'])
    exitFromCli(do)
Esempio n. 5
0
def testConsecutiveAddSameNodeWithOnlyAliasChange(be, do,
                                                  newStewardCli, newNodeVals,
                                                  newNodeAdded):
    be(newStewardCli)
    newNodeVals['newNodeData'][ALIAS] = randomString(6)
    doSendNodeCmd(do, newNodeVals,
              expMsgs=['existing data has conflicts with request data'])
    exitFromCli(do)
Esempio n. 6
0
def test_add_same_node_without_any_change(be, do, newStewardCli,
                                          newNodeVals, newNodeAdded):
    '''
    Checks that it's not possible to add the same node twice by owner
    '''
    be(newStewardCli)
    doSendNodeCmd(do, newNodeVals,
                  expMsgs=['node already has the same data as requested'])
    exitFromCli(do)
Esempio n. 7
0
def test_add_same_node_without_any_change(be, do, newStewardCli,
                                          newNodeVals, newNodeAdded):
    '''
    Checks that it's not possible to add the same node twice by owner
    '''
    be(newStewardCli)
    doSendNodeCmd(do, newNodeVals,
                  expMsgs=['node already has the same data as requested'])
    exitFromCli(do)
def testConsecutiveAddSameNodeWithNodeAndClientPortSame(
        be, do, newStewardCli, newNodeAdded):
    be(newStewardCli)
    nodeIp, nodePort = genHa()
    vals['newNodeData'][NODE_IP] = nodeIp
    vals['newNodeData'][NODE_PORT] = nodePort
    vals['newNodeData'][CLIENT_IP] = nodeIp
    vals['newNodeData'][CLIENT_PORT] = nodePort
    doNodeCmd(do, nodeData=vals, expMsgs=["node and client ha can't be same"])
    exitFromCli(do)
Esempio n. 9
0
def test_add_same_node_without_any_change_by_trustee(be, do, trusteeCli,
                                                     newNodeVals, newNodeAdded,
                                                     nodeValsEmptyData):
    '''
    Checks that it's not possible to add the same node twice by Trustee
    '''
    be(trusteeCli)
    doSendNodeCmd(do, newNodeVals,
                  expMsgs=["node already has the same data as requested"])
    exitFromCli(do)
Esempio n. 10
0
def test_add_same_node_without_any_change_by_trustee(be, do, trusteeCli,
                                                     newNodeVals, newNodeAdded,
                                                     nodeValsEmptyData):
    '''
    Checks that it's not possible to add the same node twice by Trustee
    '''
    be(trusteeCli)
    doSendNodeCmd(do, newNodeVals,
                  expMsgs=["node already has the same data as requested"])
    exitFromCli(do)
Esempio n. 11
0
def test_add_same_data_alias_changed(be, do,
                                     newStewardCli, newNodeVals,
                                     newNodeAdded):
    '''
    Checks that it's not possible to add a new Node with the same alias (by owner)
    '''
    be(newStewardCli)
    newNodeVals['newNodeData'][ALIAS] = randomString(6)
    doSendNodeCmd(do, newNodeVals,
                  expMsgs=['existing data has conflicts with request data'])
    exitFromCli(do)
Esempio n. 12
0
def test_add_same_data_alias_changed(be, do,
                                     newStewardCli, newNodeVals,
                                     newNodeAdded):
    '''
    Checks that it's not possible to add a new Node with the same alias (by owner)
    '''
    be(newStewardCli)
    newNodeVals['newNodeData'][ALIAS] = randomString(6)
    doSendNodeCmd(do, newNodeVals,
                  expMsgs=['existing data has conflicts with request data'])
    exitFromCli(do)
Esempio n. 13
0
def testConsecutiveAddSameNodeWithNonAliasChange(be, do, newStewardCli,
                                                 newNodeAdded):
    be(newStewardCli)
    nodeIp, nodePort = genHa()
    clientIp, clientPort = genHa()
    vals['newNodeData'][NODE_IP] = nodeIp
    vals['newNodeData'][NODE_PORT] = nodePort
    vals['newNodeData'][CLIENT_IP] = nodeIp
    vals['newNodeData'][CLIENT_PORT] = clientPort
    doNodeCmd(do, nodeData=vals)
    exitFromCli(do)
Esempio n. 14
0
def testConsecutiveAddSameNodeWithNonAliasChange(be, do, newStewardCli,
                                                 newNodeVals, newNodeAdded):
    be(newStewardCli)
    nodeIp, nodePort = genHa()
    clientIp, clientPort = genHa()
    newNodeVals['newNodeData'][NODE_IP] = nodeIp
    newNodeVals['newNodeData'][NODE_PORT] = nodePort
    newNodeVals['newNodeData'][CLIENT_IP] = nodeIp
    newNodeVals['newNodeData'][CLIENT_PORT] = clientPort
    doSendNodeCmd(do, newNodeVals)
    exitFromCli(do)
Esempio n. 15
0
def test_add_same_node_with_changed_bls_by_trustee(be, do, trusteeCli,
                                                   newNodeVals, newNodeAdded,
                                                   nodeValsEmptyData):
    '''
    Checks that it's not possible to add the same node with different BLS key by Trustee
    '''
    be(trusteeCli)
    node_vals = newNodeVals
    node_vals['newNodeData'][BLS_KEY] = randomString(32)
    doSendNodeCmd(do, node_vals,
                  expMsgs=["TRUSTEE not in allowed roles ['STEWARD']"])
    exitFromCli(do)
Esempio n. 16
0
def testSaveAndRestoreWallet(do, be, cli, aliceCli):
    be(cli)
    assert cli._activeWallet is None
    createNewKey(do, cli, keyringName="Default")
    createNewKeyring("mykr0", do)
    useKeyring("Default", do)
    filePath = Cli.getWalletFilePath(cli.getContextBasedKeyringsBaseDir(),
                                     cli.walletFileName)
    exitFromCli(do)
    be(aliceCli)
    useKeyring(filePath, do, expectedName="Default")
    useKeyring("mykr0", do, expectedName="mykr0")
Esempio n. 17
0
def test_add_same_node_with_changed_bls_by_trustee(be, do, trusteeCli,
                                                   newNodeVals, newNodeAdded,
                                                   nodeValsEmptyData):
    '''
    Checks that it's not possible to add the same node with different BLS key by Trustee
    '''
    be(trusteeCli)
    node_vals = newNodeVals
    node_vals['newNodeData'][BLS_KEY] = base58.b58encode(randomString(128).encode())
    doSendNodeCmd(do, node_vals,
                  expMsgs=["TRUSTEE not in allowed roles ['STEWARD']"])
    exitFromCli(do)
Esempio n. 18
0
def testConsecutiveAddSameNodeWithNodeAndClientPortSame(be, do, newStewardCli,
                                                        newNodeVals,
                                                        newNodeAdded):
    be(newStewardCli)
    nodeIp, nodePort = genHa()
    newNodeVals['newNodeData'][NODE_IP] = nodeIp
    newNodeVals['newNodeData'][NODE_PORT] = nodePort
    newNodeVals['newNodeData'][CLIENT_IP] = nodeIp
    newNodeVals['newNodeData'][CLIENT_PORT] = nodePort
    doSendNodeCmd(do, newNodeVals,
              expMsgs=["node and client ha cannot be same"])
    exitFromCli(do)
Esempio n. 19
0
def test_update_alias(be, do, newStewardCli, newNodeAdded, nodeValsEmptyData):
    '''
    Checks that it's not possible to change alias of existing node (by owner)
    '''
    be(newStewardCli)

    node_vals = nodeValsEmptyData
    node_vals['newNodeData'][ALIAS] = randomString(6)

    doSendNodeCmd(do,
                  node_vals,
                  expMsgs=['existing data has conflicts with request data'])
    exitFromCli(do)
Esempio n. 20
0
def test_update_bls(be, do, newStewardCli, newNodeVals, newNodeAdded,
                    nodeValsEmptyData):
    '''
    Checks that it's possible to update BLS keys by owner (just alias and new key are required)
    '''
    be(newStewardCli)

    node_vals = nodeValsEmptyData
    node_vals['newNodeData'][ALIAS] = newNodeVals['newNodeData'][ALIAS]
    node_vals['newNodeData'][BLS_KEY] = randomString(32)

    doSendNodeCmd(do, node_vals, expMsgs=['Node request completed'])
    exitFromCli(do)
Esempio n. 21
0
def testSaveAndRestoreWallet(do, be, cliForMultiNodePools,
                             aliceMultiNodePools,
                             earlMultiNodePools):
    be(cliForMultiNodePools)
    # No wallet should have been restored
    assert cliForMultiNodePools._activeWallet is None

    connectTo("pool1", do, cliForMultiNodePools,
              activeWalletPresents=True, identifiers=0, firstTimeConnect=True)
    createNewKey(do, cliForMultiNodePools, walletName="Default")

    switchEnv("pool2", do, cliForMultiNodePools, checkIfWalletRestored=False)
    createNewKey(do, cliForMultiNodePools, walletName="Default")
    createNewWallet("mykr0", do)
    createNewKey(do, cliForMultiNodePools, walletName="mykr0")
    createNewKey(do, cliForMultiNodePools, walletName="mykr0")
    useKeyring("Default", do)
    createNewKey(do, cliForMultiNodePools, walletName="Default")
    sleep(10)
    switchEnv("pool1", do, cliForMultiNodePools, checkIfWalletRestored=True,
              restoredWalletKeyName="Default", restoredIdentifiers=1)
    createNewWallet("mykr1", do)
    createNewKey(do, cliForMultiNodePools, walletName="mykr1")

    switchEnv("pool2", do, cliForMultiNodePools, checkIfWalletRestored=True,
              restoredWalletKeyName="Default", restoredIdentifiers=2)
    createNewWallet("mykr0", do,
                    expectedMsgs=[
                        '"mykr0" conflicts with an existing wallet',
                        'Please choose a new name.'])

    filePath = getWalletFilePath(
        cliForMultiNodePools.getContextBasedWalletsBaseDir(),
        cliForMultiNodePools.walletFileName)
    switchEnv("pool1", do, cliForMultiNodePools, checkIfWalletRestored=True,
              restoredWalletKeyName="mykr1", restoredIdentifiers=1)
    useKeyring(filePath, do, expectedName="mykr0",
               expectedMsgs=[
                   "Given wallet file ({}) doesn't "
                   "belong to current context.".format(filePath),
                   "Please connect to 'pool2' environment and try again."])

    # exit from current cli so that active wallet gets saved
    exitFromCli(do)

    # different tests for restoring saved wallet
    filePath = getWalletFilePath(
        cliForMultiNodePools.getContextBasedWalletsBaseDir(),
        cliForMultiNodePools.walletFileName)
    restartCli(aliceMultiNodePools, be, do, "mykr1", 1)
    restartCliWithCorruptedWalletFile(earlMultiNodePools, be, do, filePath)
def testSaveAndRestoreWallet(do, be, cliForMultiNodePools,
                             aliceMultiNodePools,
                             earlMultiNodePools):
    be(cliForMultiNodePools)
    # No wallet should have been restored
    assert cliForMultiNodePools._activeWallet is None

    connectTo("pool1", do, cliForMultiNodePools,
              activeWalletPresents=True, identifiers=0, firstTimeConnect=True)
    createNewKey(do, cliForMultiNodePools, keyringName="Default")

    switchEnv("pool2", do, cliForMultiNodePools, checkIfWalletRestored=False)
    createNewKey(do, cliForMultiNodePools, keyringName="Default")
    createNewKeyring("mykr0", do)
    createNewKey(do, cliForMultiNodePools, keyringName="mykr0")
    createNewKey(do, cliForMultiNodePools, keyringName="mykr0")
    useKeyring("Default", do)
    createNewKey(do, cliForMultiNodePools, keyringName="Default")
    sleep(10)
    switchEnv("pool1", do, cliForMultiNodePools, checkIfWalletRestored=True,
              restoredWalletKeyName="Default", restoredIdentifiers=1)
    createNewKeyring("mykr1", do)
    createNewKey(do, cliForMultiNodePools, keyringName="mykr1")

    switchEnv("pool2", do, cliForMultiNodePools, checkIfWalletRestored=True,
              restoredWalletKeyName="Default", restoredIdentifiers=2)
    createNewKeyring("mykr0", do,
                     expectedMsgs = [
                         '"mykr0" conflicts with an existing keyring',
                         'Please choose a new name.'])

    filePath = getWalletFilePath(cliForMultiNodePools.getContextBasedKeyringsBaseDir(),
                                     cliForMultiNodePools.walletFileName)
    switchEnv("pool1", do, cliForMultiNodePools, checkIfWalletRestored=True,
              restoredWalletKeyName="mykr1", restoredIdentifiers=1)
    useKeyring(filePath, do, expectedName="mykr0",
               expectedMsgs=[
                   "Given wallet file ({}) doesn't "
                   "belong to current context.".format(filePath),
                   "Please connect to 'pool2' environment and try again."])

    # exit from current cli so that active wallet gets saved
    exitFromCli(do)

    # different tests for restoring saved wallet
    filePath = getWalletFilePath(cliForMultiNodePools.getContextBasedKeyringsBaseDir(),
                                     cliForMultiNodePools.walletFileName)
    restartCli(aliceMultiNodePools, be, do, "mykr1", 1)
    restartCliWithCorruptedWalletFile(earlMultiNodePools, be, do, filePath)
Esempio n. 23
0
def test_update_bls_by_trustee(be, do, trusteeCli,
                               newNodeVals, newNodeAdded,
                               nodeValsEmptyData):
    '''
    Checks that it's not possible to update BLS keys by Trustee (just alias and new key are required)
    '''
    be(trusteeCli)

    node_vals = nodeValsEmptyData
    node_vals['newNodeData'][ALIAS] = newNodeVals['newNodeData'][ALIAS]
    node_vals['newNodeData'][BLS_KEY] = base58.b58encode(randomString(128).encode())

    doSendNodeCmd(do, node_vals,
                  expMsgs=["TRUSTEE not in allowed roles ['STEWARD']"])
    exitFromCli(do)
Esempio n. 24
0
def test_add_same_node_with_changed_bls_by_trustee(be, do, trusteeCli,
                                                   newNodeVals, newNodeAdded,
                                                   nodeValsEmptyData,
                                                   new_bls_keys):
    '''
    Checks that it's not possible to add the same node with different BLS key by Trustee
    '''
    be(trusteeCli)
    node_vals = newNodeVals
    bls_key, key_proof = new_bls_keys
    node_vals['newNodeData'][BLS_KEY] = bls_key
    node_vals['newNodeData'][BLS_KEY_PROOF] = key_proof
    doSendNodeCmd(do, node_vals,
                  expMsgs=["TRUSTEE not in allowed roles ['STEWARD']"])
    exitFromCli(do)
Esempio n. 25
0
def test_update_bls(be, do, newStewardCli,
                    newNodeVals, newNodeAdded,
                    nodeValsEmptyData):
    '''
    Checks that it's possible to update BLS keys by owner (just alias and new key are required)
    '''
    be(newStewardCli)

    node_vals = nodeValsEmptyData
    node_vals['newNodeData'][ALIAS] = newNodeVals['newNodeData'][ALIAS]
    node_vals['newNodeData'][BLS_KEY] = randomString(32)

    doSendNodeCmd(do, node_vals,
                  expMsgs=['Node request completed'])
    exitFromCli(do)
Esempio n. 26
0
def test_update_alias(be, do,
                      newStewardCli,
                      newNodeAdded,
                      nodeValsEmptyData):
    '''
    Checks that it's not possible to change alias of existing node (by owner)
    '''
    be(newStewardCli)

    node_vals = nodeValsEmptyData
    node_vals['newNodeData'][ALIAS] = randomString(6)

    doSendNodeCmd(do, node_vals,
                  expMsgs=['existing data has conflicts with request data'])
    exitFromCli(do)
Esempio n. 27
0
def test_update_bls_by_trustee(be, do, trusteeCli,
                               newNodeVals, newNodeAdded,
                               nodeValsEmptyData):
    '''
    Checks that it's not possible to update BLS keys by Trustee (just alias and new key are required)
    '''
    be(trusteeCli)

    node_vals = nodeValsEmptyData
    node_vals['newNodeData'][ALIAS] = newNodeVals['newNodeData'][ALIAS]
    node_vals['newNodeData'][BLS_KEY] = randomString(32)

    doSendNodeCmd(do, node_vals,
                  expMsgs=["TRUSTEE not in allowed roles ['STEWARD']"])
    exitFromCli(do)
Esempio n. 28
0
def test_update_node_and_client_port_same(be, do, newStewardCli, newNodeVals,
                                          newNodeAdded, nodeValsEmptyData):
    '''
    Checks that it's not possible to have node and client ports same (by owner)
    '''
    be(newStewardCli)
    nodeIp, nodePort = genHa()

    node_vals = nodeValsEmptyData
    node_vals['newNodeData'][ALIAS] = newNodeVals['newNodeData'][ALIAS]
    node_vals['newNodeData'][NODE_IP] = nodeIp
    node_vals['newNodeData'][NODE_PORT] = nodePort
    node_vals['newNodeData'][CLIENT_IP] = nodeIp
    node_vals['newNodeData'][CLIENT_PORT] = nodePort

    doSendNodeCmd(do, node_vals, expMsgs=["node and client ha cannot be same"])
    exitFromCli(do)
Esempio n. 29
0
def test_update_bls(be, do, newStewardCli,
                    newNodeVals, newNodeAdded,
                    nodeValsEmptyData,
                    new_bls_keys):
    '''
    Checks that it's possible to update BLS keys by owner (just alias and new key are required)
    '''
    be(newStewardCli)

    node_vals = nodeValsEmptyData
    bls_key, key_proof = new_bls_keys
    node_vals['newNodeData'][BLS_KEY] = bls_key
    node_vals['newNodeData'][BLS_KEY_PROOF] = key_proof
    node_vals['newNodeData'][ALIAS] = newNodeVals['newNodeData'][ALIAS]

    doSendNodeCmd(do, node_vals,
                  expMsgs=['Node request completed'])
    exitFromCli(do)
Esempio n. 30
0
def test_update_bls_by_trustee(be, do, trusteeCli,
                               newNodeVals, newNodeAdded,
                               nodeValsEmptyData,
                               new_bls_keys):
    '''
    Checks that it's not possible to update BLS keys by Trustee (just alias and new key are required)
    '''
    be(trusteeCli)

    node_vals = nodeValsEmptyData
    bls_key, key_proof = new_bls_keys
    node_vals['newNodeData'][BLS_KEY] = bls_key
    node_vals['newNodeData'][BLS_KEY_PROOF] = key_proof
    node_vals['newNodeData'][ALIAS] = newNodeVals['newNodeData'][ALIAS]

    doSendNodeCmd(do, node_vals,
                  expMsgs=["TRUSTEE not in allowed roles ['STEWARD']"])
    exitFromCli(do)
Esempio n. 31
0
def test_update_ports_and_ips(be, do, newStewardCli, newNodeVals, newNodeAdded,
                              nodeValsEmptyData):
    '''
    Checks that it's possible to update node and client ports and IPs (by owner)
    (just alias and ports/IPs are required)
    '''
    be(newStewardCli)
    nodeIp, nodePort = genHa()
    clientIp, clientPort = genHa()

    node_vals = nodeValsEmptyData
    node_vals['newNodeData'][ALIAS] = newNodeVals['newNodeData'][ALIAS]
    node_vals['newNodeData'][NODE_IP] = nodeIp
    node_vals['newNodeData'][NODE_PORT] = nodePort
    node_vals['newNodeData'][CLIENT_IP] = clientIp
    node_vals['newNodeData'][CLIENT_PORT] = clientPort

    doSendNodeCmd(do, node_vals, expMsgs=['Node request completed'])
    exitFromCli(do)
Esempio n. 32
0
def test_update_node_and_client_port_same(be, do, newStewardCli,
                                          newNodeVals,
                                          newNodeAdded,
                                          nodeValsEmptyData):
    '''
    Checks that it's not possible to have node and client ports same (by owner)
    '''
    be(newStewardCli)
    nodeIp, nodePort = genHa()

    node_vals = nodeValsEmptyData
    node_vals['newNodeData'][ALIAS] = newNodeVals['newNodeData'][ALIAS]
    node_vals['newNodeData'][NODE_IP] = nodeIp
    node_vals['newNodeData'][NODE_PORT] = nodePort
    node_vals['newNodeData'][CLIENT_IP] = nodeIp
    node_vals['newNodeData'][CLIENT_PORT] = nodePort

    doSendNodeCmd(do, node_vals,
                  expMsgs=["node and client ha cannot be same"])
    exitFromCli(do)
Esempio n. 33
0
def test_update_ports_and_ips(be, do, newStewardCli,
                              newNodeVals, newNodeAdded,
                              nodeValsEmptyData):
    '''
    Checks that it's possible to update node and client ports and IPs (by owner)
    (just alias and ports/IPs are required)
    '''
    be(newStewardCli)
    nodeIp, nodePort = genHa()
    clientIp, clientPort = genHa()

    node_vals = nodeValsEmptyData
    node_vals['newNodeData'][ALIAS] = newNodeVals['newNodeData'][ALIAS]
    node_vals['newNodeData'][NODE_IP] = nodeIp
    node_vals['newNodeData'][NODE_PORT] = nodePort
    node_vals['newNodeData'][CLIENT_IP] = clientIp
    node_vals['newNodeData'][CLIENT_PORT] = clientPort

    doSendNodeCmd(do, node_vals,
                  expMsgs=['Node request completed'])
    exitFromCli(do)
def testSaveAndRestoreWallet(do, be, cliForMultiNodePools,
                             aliceMultiNodePools,
                             earlMultiNodePools):
    be(cliForMultiNodePools)
    # No wallet should have been restored
    assert cliForMultiNodePools._activeWallet is None

    connectTo("pool1", do, cliForMultiNodePools,
              activeWalletPresents=True, identifiers=0, firstTimeConnect=True)
    createNewKey(do, cliForMultiNodePools, walletName="Default")

    switchEnv("pool2", do, cliForMultiNodePools, checkIfWalletRestored=False)
    createNewKey(do, cliForMultiNodePools, walletName="Default")
    createNewWallet("mykr0", do)
    createNewKey(do, cliForMultiNodePools, walletName="mykr0")
    createNewKey(do, cliForMultiNodePools, walletName="mykr0")
    useKeyring("Default", do)
    createNewKey(do, cliForMultiNodePools, walletName="Default")
    sleep(10)
    switchEnv("pool1", do, cliForMultiNodePools, checkIfWalletRestored=True,
              restoredWalletKeyName="Default", restoredIdentifiers=1)
    createNewWallet("mykr1", do)
    createNewKey(do, cliForMultiNodePools, walletName="mykr1")

    switchEnv("pool2", do, cliForMultiNodePools, checkIfWalletRestored=True,
              restoredWalletKeyName="Default", restoredIdentifiers=2)
    createNewWallet("mykr0", do,
                    expectedMsgs=[
                        '"mykr0" conflicts with an existing wallet',
                        'Please choose a new name.'])

    filePath = getWalletFilePath(
        cliForMultiNodePools.getContextBasedWalletsBaseDir(),
        cliForMultiNodePools.walletFileName)
    switchEnv("pool1", do, cliForMultiNodePools, checkIfWalletRestored=True,
              restoredWalletKeyName="mykr1", restoredIdentifiers=1)
    useKeyring(filePath, do, expectedName="mykr0",
               expectedMsgs=[
                   "Given wallet file ({}) doesn't "
                   "belong to current context.".format(filePath),
                   "Please connect to 'pool2' environment and try again."])

    # exit from current cli so that active wallet gets saved
    exitFromCli(do)

    alice_wallets_dir = os.path.join(aliceMultiNodePools.getWalletsBaseDir(), "pool1")
    earl_wallets_dir = os.path.join(earlMultiNodePools.getWalletsBaseDir(), "pool1")

    os.makedirs(alice_wallets_dir, exist_ok=True)
    os.makedirs(earl_wallets_dir, exist_ok=True)

    alice_wallet_path = os.path.join(alice_wallets_dir, cliForMultiNodePools.walletFileName)
    earl_wallet_path = os.path.join(earl_wallets_dir, cliForMultiNodePools.walletFileName)

    # different tests for restoring saved wallet
    filePath = getWalletFilePath(
        cliForMultiNodePools.getContextBasedWalletsBaseDir(),
        "default.wallet")

    shutil.copy(filePath, alice_wallets_dir)
    shutil.copy(filePath, earl_wallets_dir)

    filePath = getWalletFilePath(
        cliForMultiNodePools.getContextBasedWalletsBaseDir(),
        cliForMultiNodePools.walletFileName)

    shutil.copy(filePath, alice_wallet_path)
    shutil.copy(filePath, earl_wallet_path)

    def _f(path):
        if not os.path.exists(path):
            raise FileNotFoundError("{}".format(path))

    cliForMultiNodePools.looper.run(eventually(_f, alice_wallet_path))
    cliForMultiNodePools.looper.run(eventually(_f, earl_wallet_path))

    restartCli(aliceMultiNodePools, be, do, "mykr1", 1)
    restartCliWithCorruptedWalletFile(earlMultiNodePools, be, do, earl_wallet_path)
Esempio n. 35
0
def testConsecutiveAddNewNodes(be, do, newStewardCli, newNodeAdded):
    be(newStewardCli)
    sendNodeCmd(do)
    exitFromCli(do)
Esempio n. 36
0
def testSaveAndRestoreWallet(do, be, cliForMultiNodePools, aliceMultiNodePools,
                             earlMultiNodePools):
    be(cliForMultiNodePools)
    # No wallet should have been restored
    assert cliForMultiNodePools._activeWallet is None

    connectTo("pool1",
              do,
              cliForMultiNodePools,
              activeWalletPresents=True,
              identifiers=0,
              firstTimeConnect=True)
    createNewKey(do, cliForMultiNodePools, walletName="Default")

    switchEnv("pool2", do, cliForMultiNodePools, checkIfWalletRestored=False)
    createNewKey(do, cliForMultiNodePools, walletName="Default")
    createNewWallet("mykr0", do)
    createNewKey(do, cliForMultiNodePools, walletName="mykr0")
    createNewKey(do, cliForMultiNodePools, walletName="mykr0")
    useKeyring("Default", do)
    createNewKey(do, cliForMultiNodePools, walletName="Default")
    sleep(10)
    switchEnv("pool1",
              do,
              cliForMultiNodePools,
              checkIfWalletRestored=True,
              restoredWalletKeyName="Default",
              restoredIdentifiers=1)
    createNewWallet("mykr1", do)
    createNewKey(do, cliForMultiNodePools, walletName="mykr1")

    switchEnv("pool2",
              do,
              cliForMultiNodePools,
              checkIfWalletRestored=True,
              restoredWalletKeyName="Default",
              restoredIdentifiers=2)
    createNewWallet("mykr0",
                    do,
                    expectedMsgs=[
                        '"mykr0" conflicts with an existing wallet',
                        'Please choose a new name.'
                    ])

    filePath = getWalletFilePath(
        cliForMultiNodePools.getContextBasedWalletsBaseDir(),
        cliForMultiNodePools.walletFileName)
    switchEnv("pool1",
              do,
              cliForMultiNodePools,
              checkIfWalletRestored=True,
              restoredWalletKeyName="mykr1",
              restoredIdentifiers=1)
    useKeyring(filePath,
               do,
               expectedName="mykr0",
               expectedMsgs=[
                   "Given wallet file ({}) doesn't "
                   "belong to current context.".format(filePath),
                   "Please connect to 'pool2' environment and try again."
               ])

    # exit from current cli so that active wallet gets saved
    exitFromCli(do)

    alice_wallets_dir = os.path.join(aliceMultiNodePools.getWalletsBaseDir(),
                                     "pool1")
    earl_wallets_dir = os.path.join(earlMultiNodePools.getWalletsBaseDir(),
                                    "pool1")

    os.makedirs(alice_wallets_dir, exist_ok=True)
    os.makedirs(earl_wallets_dir, exist_ok=True)

    alice_wallet_path = os.path.join(alice_wallets_dir,
                                     cliForMultiNodePools.walletFileName)
    earl_wallet_path = os.path.join(earl_wallets_dir,
                                    cliForMultiNodePools.walletFileName)

    # different tests for restoring saved wallet
    filePath = getWalletFilePath(
        cliForMultiNodePools.getContextBasedWalletsBaseDir(), "default.wallet")

    shutil.copy(filePath, alice_wallets_dir)
    shutil.copy(filePath, earl_wallets_dir)

    filePath = getWalletFilePath(
        cliForMultiNodePools.getContextBasedWalletsBaseDir(),
        cliForMultiNodePools.walletFileName)

    shutil.copy(filePath, alice_wallet_path)
    shutil.copy(filePath, earl_wallet_path)

    def _f(path):
        if not os.path.exists(path):
            raise FileNotFoundError("{}".format(path))

    cliForMultiNodePools.looper.run(eventually(_f, alice_wallet_path))
    cliForMultiNodePools.looper.run(eventually(_f, earl_wallet_path))

    restartCli(aliceMultiNodePools, be, do, "mykr1", 1)
    restartCliWithCorruptedWalletFile(earlMultiNodePools, be, do,
                                      earl_wallet_path)
Esempio n. 37
0
def testAliceSendBankKYCClaim(be, do, aliceCli, susanCli, bankKYCProofSent):
    be(aliceCli)
    exitFromCli(do)
    restartCliAndTestWalletRestoration(be, do, susanCli)
Esempio n. 38
0
def testAliceSendBankKYCClaim(be, do, aliceCli, susanCli, bankKYCProofSent,
                              connectedToTest):
    be(aliceCli)
    exitFromCli(do)
    restartCliAndTestWalletRestoration(be, do, susanCli, connectedToTest)
Esempio n. 39
0
def testConsecutiveAddSameNodeWithoutAnyChange(be, do, newStewardCli,
                                               newNodeVals, newNodeAdded):
    be(newStewardCli)
    doSendNodeCmd(do, newNodeVals,
              expMsgs=['node already has the same data as requested'])
    exitFromCli(do)