예제 #1
0
def test_password_reset_success():
    clear()
    # Register 2 users for coverage
    auth_register("*****@*****.**", "password", "Wilson", "Doe")['u_id']
    auth_register("*****@*****.**", "password", "Wilson", "Doe")['u_id']
    user = auth_login("*****@*****.**", "password")

    # Retrieve the reset code
    reset_code = encoded_resetcode("*****@*****.**")
    # Reset the password
    auth_passwordreset_reset(reset_code, "newpassword")
    # Assert that the new password is updated by checking if the hashed versions are the same

    auth_logout(user['token'])
    user = auth_login("*****@*****.**", "newpassword")
    assert user == {
        'u_id': 1,
        'token': user['token'],
    }
예제 #2
0
def test_successful_logout(register_login):
    token = token_hash(0)
    assert auth_logout(token) == {'is_success': True}
예제 #3
0
def test_unsuccessful_logout(register_login):
    token = token_hash(1)
    assert auth_logout(token) == {'is_success': False}
예제 #4
0
def test_empty_token(register_login):
    token = token_hash(1)
    assert auth_logout(token) == {'is_success': False}
예제 #5
0
def auth_logout_flask():
    payload = request.get_json()

    token = payload['token']

    return dumps(a.auth_logout(token))