def test_valid_user():
    clear_v1()
    user_1_session1 = auth_register_v2('*****@*****.**', 'asdjf~!',
                                       'Rengoku', 'Kyojuro')
    auth_logout_v2(user_1_session1["token"])

    user_1_session2 = auth_login_v2('*****@*****.**', 'asdjf~!')

    assert user_1_session1["auth_user_id"] == user_1_session2["auth_user_id"]

    assert channels_create_v2(user_1_session2["token"], "test name", True)
def test_removed_user():
    clear_v1()

    a_data = auth_register_v2('*****@*****.**', 'asdjf~!', 'Rengoku',
                              'Kyojuro')
    b_data = auth_register_v2('*****@*****.**', 'asdjf~!', 'Rengoku',
                              'Kyojuro')

    auth_logout_v2(b_data["token"])

    user_remove_v1(a_data["token"], b_data["auth_user_id"])

    with pytest.raises(InputError):
        auth_login_v2('*****@*****.**', 'asdjf~!')
def test_successful_reset():
    '''
    password has succesfully changed given reset_code and new_password
    '''
    clear_v1()
    user = auth_register_v2('*****@*****.**', 'asdjf~!', 'Rengoku',
                            'Kyojuro')
    auth_logout_v2(user['token'])
    auth_passwordreset_request_v1('*****@*****.**')
    with open("email.json") as e_file:
        email = load(e_file)
    auth_passwordreset_reset_v1(email['reset_code'], 'babus1337')
    user_session_1 = auth_login_v2('*****@*****.**', 'babus1337')
    assert user_session_1['auth_user_id'] == user['auth_user_id']
def test_invalid_email():
    '''
    Email entered is not a valid email
    '''
    clear_v1()
    user_1 = auth_register_v2('*****@*****.**', 'asdjf~!', 'Rengoku',
                              'Kyojuro')
    auth_logout_v2(user_1["token"])

    with pytest.raises(InputError):
        auth_login_v2('invalid.email.gmail.com', 'asdjf~!')
        auth_login_v2('*****@*****.**', 'asdjf~!')
        auth_login_v2('inval [email protected]', 'asdjf~!')
        auth_login_v2('[email protected]', 'asdjf~!')
        auth_login_v2('129%_.$@[email protected]', 'asdjf~!')
Example #5
0
def test_auth_logout_v2():
    clear_v1()

    auth_user_1_data = auth_register_v2("*****@*****.**", "123456", "Andy",
                                        "Dandy")
    auth_user_1_token = auth_user_1_data["token"]

    is_success_data = auth_logout_v2(auth_user_1_token)
    assert is_success_data["is_success"] == True

    is_success_data = auth_logout_v2(auth_user_1_token)
    assert is_success_data["is_success"] == False

    auth_user_1_data = auth_login_v2("*****@*****.**", "123456")
    auth_user_1_token = auth_user_1_data["token"]

    is_success_data = auth_logout_v2(auth_user_1_token)
    assert is_success_data["is_success"] == True

    is_success_data = auth_logout_v2(auth_user_1_token)
    assert is_success_data["is_success"] == False
def us_logout(scrambler):
    auth_logout_v2(scrambler["token"])