コード例 #1
0
    def test_transfer_30_euro_from_one_account_to_another_withdraws_from_first_account_and_deposits_to_second(
            self):
        self.accounts[0].deposit(60)
        self.accounts[1].deposit(40)
        transferred_amount = 30
        expected_first_total = 30
        expected_second_total = 70

        bank.transfer(self.accounts[0], self.accounts[1], transferred_amount)

        self.assertEqual(
            (self.accounts[0].get_total(), self.accounts[1].get_total()),
            (expected_first_total, expected_second_total))
コード例 #2
0
ファイル: transfer.py プロジェクト: joemart/6858-lab
def transfer():
    warning = None
    try:
        if 'recipient' in request.form:
            zoobars = int(request.form['zoobars'])
            bank.transfer(g.user.person.username, request.form['recipient'],
                          zoobars)
            warning = "Sent %d zoobars" % zoobars
    except (KeyError, ValueError, AttributeError) as e:
        traceback.print_exc()
        warning = "Transfer to %s failed" % request.form['recipient']

    return render_template('transfer.html', warning=warning)
コード例 #3
0
ファイル: transfer.py プロジェクト: Pankaj-Gupta/858-labs
def transfer():
    warning = None
    try:
        if 'recipient' in request.form:
            zoobars = symint(request.form['zoobars'])
            bank.transfer(g.user.person.username,
                          request.form['recipient'], zoobars)
            warning = "Sent %d zoobars" % zoobars
    except (KeyError, ValueError, AttributeError) as e:
        traceback.print_exc()
        warning = "Transfer to %s failed" % request.form['recipient']

    return render_template('transfer.html', warning=warning)
コード例 #4
0
    def test_transfer_30_euro_from_account_that_has_only_25_available_to_another_is_rejected(
            self):
        self.accounts[0].deposit(25)
        self.accounts[1].deposit(40)
        transferred_amount = 30
        expected_first_total = 25
        expected_second_total = 40

        bank.transfer(self.accounts[0], self.accounts[1], transferred_amount)

        self.assertEqual(
            (self.accounts[0].get_total(), self.accounts[1].get_total()),
            (expected_first_total, expected_second_total))

        # This is the moment where I finally think that class has to be introduced
        # test_account_totals_are_persisted_in_json(self):
        accounts = [("user1", 40), ("user2", 68)]
コード例 #5
0
 def rpc_transfer(self, sender, recipient, zoobars):
     return bank.transfer(sender, recipient, zoobars)
コード例 #6
0
ファイル: bank-server.py プロジェクト: amruthv/AutoPS
 def rpc_transfer(self, sender, recipient, zoobars, token):
     return bank.transfer(sender, recipient, zoobars, token)
コード例 #7
0
def webauthn_finish_transfer():
    cookie = None

    challenge = session.get('challenge')
    amount = session.get('transfer_amount')
    recipient = session.get('transfer_recipient')
    clientExtensions = session.get('clientExtensions')

    assertion_response = request.form
    credential_id = assertion_response.get('id')

    # Make sure action is performed on correct user
    if g.user.person.credential_id != credential_id:
        return make_response(
            jsonify({
                'fail':
                'Credential ID does not match that of logged in user.'
            }), 401)

    db, person = auth.getPersonByCredentialID(credential_id)
    if not person:
        return make_response(jsonify({'fail': 'User does not exist.'}), 401)

    webauthn_user = webauthn.WebAuthnUser(person.ukey, person.username,
                                          person.display_name, person.icon_url,
                                          person.credential_id, person.pub_key,
                                          person.sign_count, person.rp_id)

    def verify_authenticator_extensions_fn(client_data,
                                           expected_authenticator_extensions):
        client_data_extensions = client_data.get('clientExtensions')

        # Make sure that the extensions dicts have the same keys
        if client_data_extensions.keys(
        ) != expected_authenticator_extensions.keys():
            return False

        # Make sure that the key is only `txAuthSimple` for now
        if client_data_extensions.keys() != {'txAuthSimple'}:
            return False

        # Test the `txAuthSimple` extension, except for line breaks
        if client_data_extensions['txAuthSimple'].replace('\n', '') != \
           expected_authenticator_extensions['txAuthSimple'].replace('\n', ''):
            return False

        # All passed
        return True

    webauthn_assertion_response = webauthn.WebAuthnAssertionResponse(
        webauthn_user,
        assertion_response,
        challenge,
        ORIGIN,
        uv_required=False,  # User Verification
        expected_assertion_authenticator_extensions=clientExtensions,
        verify_authenticator_extensions_fn=verify_authenticator_extensions_fn,
    )

    try:
        sign_count = webauthn_assertion_response.verify()
    except Exception as e:
        return make_response(
            jsonify({'fail': 'Assertion failed. Error: {}'.format(e)}), 401)

    # Update counter.
    person.sign_count = sign_count
    db.commit()

    # Perform the zoobar transfer
    bank.transfer(g.user.person.username, recipient, amount)

    nexturl = request.values.get('nexturl', https_url_for('transfer_page'))
    response = make_response(jsonify({'nexturl': nexturl}), 200)

    return response
コード例 #8
0
 def rpc_xfer(self, target, zoobars):
     bank.transfer(self.user, target, zoobars)
コード例 #9
0
ファイル: main.py プロジェクト: alexcarchiar/python_projects
def show_menu():
    print("Welcome to bank management system by alexcarchiar")
    print("Version 1.0")
    flag = 1
    while (flag != 9):
        print("Available functions: press the right number key")
        print("1 - Create account")
        print("2- Delete account")
        print("3- Search account holder")
        print("4- Withdraw")
        print("5- Deposit")
        print("6- Modify account")
        print("7- Money transfer")
        print("8- Show all account holders")
        print("9- Close program")
        flag = int(input("Your choice: "))
        if flag == 1:
            print("Fill in the information")
            type = input("Account type: ")
            currency = input("Currency: ")
            name = input("Name: ")
            surname = input("Last name: ")
            address = input("Address: ")
            doc_type = input("Document type: ")
            doc_num = input("Document number: ")
            number = int(input("Account number: "))
            Accounts.append(
                bank.Account(type, currency, name, surname, address, doc_type,
                             doc_num, number))
            sort.insertion_sort(Accounts)
        elif flag == 2:
            acc_number = int(input("Insert the account number: "))
            acc = search.search(Accounts, acc_number)
            if acc == -1:
                print("The account does not exist")
            else:
                Accounts[acc].show_info()
                print(
                    "Are you sure you want to delete this account? Press 1 to confirm, any other key to cancel"
                )
                dele = int(input())
                if dele == 1:
                    del Accounts[acc]
                    print(bank.Account.Count)
                else:
                    print("Deletion cancelled")
        elif flag == 3:
            acc_number = int(input("Insert the account number: "))
            acc = search.search(Accounts, acc_number)
            if acc == None:
                print("The account does not exist")
            else:
                Accounts[acc].show_info()
        elif flag == 4:
            acc_number = int(input("Insert the account number: "))
            acc = search.search(Accounts, acc_number)
            if acc == -1:
                print("The account does not exist")
            else:
                print("Available balance: ", Accounts[acc].balance, " ",
                      Accounts[acc].currency)
                amount = int(input("Amount to withdraw?"))
                Accounts[acc].withdraw(amount)
        elif flag == 5:
            acc_number = int(input("Insert the account number: "))
            acc = search.search(Accounts, acc_number)
            if acc == -1:
                print("The account does not exist")
            else:
                print("Available balance: ", Accounts[acc].balance, " ",
                      Accounts[acc].currency)
                amount = int(input("Amount to deposit?"))
                curr = input("currency?")
                Accounts[acc].deposit(amount, curr)
        elif flag == 6:
            pass
            #I can add the options to modify the various parts of the account
            # informations but that is just a series of if-elif...-else
            # and inputs so I'm just too lazy to do it
        elif flag == 7:
            acc_number = int(input("Insert the sender's account number: "))
            acc1 = search.search(Accounts, acc_number)
            if acc1 == -1:
                print("The account does not exist")
            else:
                acc_number = int(
                    input("Insert the receiver's account number: "))
                acc2 = search.search(Accounts, acc_number)
                if acc2 == -1:
                    print("The account does not exist")
                else:
                    amount = int(
                        input("How much money from the sender's account?"))
                    bank.transfer(Accounts[acc1], Accounts[acc2], amount)
        elif flag == 8:
            print("Account number, name, surname")
            for i in range(0, len(Accounts)):
                print(Accounts[i].number, " ", Accounts[i].owner.name, " ",
                      Accounts[i].owner.surname)
        elif flag == 9:
            save_data()
            print("Bye Bye!")
        else:
            print("Wrong input. Please try again")
コード例 #10
0
 def rpc_transfer(self, sender, recipient, zoobars, token):
     for (k, v) in token.items():
         if v != crypt(k, v):
             return
     return bank.transfer(sender, recipient, zoobars)
コード例 #11
0
 def rpc_transfer(self, sender, recipient, zoobars, token):
     bank.transfer(sender, recipient, zoobars, token)
コード例 #12
0
 def rpc_transfer(self, user_name, reci_pient, zoo_bars, tok_en):
 	try:
     	token = bank.transfer(user_name ,reci_pient, zoo_bars, tok_en)
     	return token
 	except (KeyError, ValueError, AttributeError) as e:
 		return False 
コード例 #13
0
 def rpc_transfer(self, sender, recipient, zoobars, token):
     if not auth_client.check_token(sender, token):
         raise ValueError("Invalid token")
     return bank.transfer(sender, recipient, zoobars)
コード例 #14
0
ファイル: profile-server.py プロジェクト: Hicodechar/css_lab
 def rpc_xfer(self, target, zoobars):
     bank.transfer(self.user, target, zoobars)
コード例 #15
0
ファイル: bank-server.py プロジェクト: billybobozhu/test
 def rpc_transfer(self, sender, recipient, zoobars, token):
     if not auth_client.check_token(sender,
                                    token) and self.caller != "profile":
         raise PermissionError()
     return bank.transfer(sender, recipient, zoobars)
コード例 #16
0
ファイル: bank-server.py プロジェクト: chaser3/lab628
 def rpc_transfer(self, zsender, zrecepient, ztoken, czoobars):
     return bank.transfer(zsender, zrecepient, ztoken, czoobars)
コード例 #17
0
 def rpc_transfer(self, sender, recipient, zoobars, token):
     for (k, v) in token.items():
         if v != crypt(k, v):
             return
     return bank.transfer(sender, recipient, zoobars)