Beispiel #1
0
def connect():
    data = getData()
    email, password = (request.form[x] for x in ('email', 'password'))
    checkEmail(email)

    user = loginFunc(data, email, password)
    data['tokens'].append(generateToken(user['u_id']))

    return sendSuccess({
        'u_id': user['u_id'],
        'token': generateToken(user['u_id']),
    })
Beispiel #2
0
def test_invalid_login_email_correct_password():
    '''
    Testing if auth_login functions raises a Value Error if 
    if passed an incorrect email and correct password.
    '''

    data = {
        "users": [{
            "email": "*****@*****.**",
            "password": hashPassword("validPassword"),
            "name_first": "validFirst",
            "name_last": "validLast",
            "handle": "validFirstvalidLast",
            "u_id": 8501,
            "resetCode": None,
            "is_admin": 1,
            "img_url": None
        }],
        "tokens": [],
        "channels": [],
    }

    with pytest.raises(errors.ValueError):
        loginFunc(data, "*****@*****.**", "validPassword")
Beispiel #3
0
def test_valid_login():
    '''
    Testing if auth_login functions return expected outputs 
    if passed the correct password and email.
    '''

    data = {
        "users": [{
            "email": "*****@*****.**",
            "password": hashPassword("validPassword"),
            "name_first": "validFirst",
            "name_last": "validLast",
            "handle": "validFirstvalidLast",
            "u_id": 8501,
            "resetCode": None,
            "is_admin": 1,
            "img_url": None
        }],
        "tokens": [],
        "channels": [],
    }

    assert loginFunc(data, "*****@*****.**",
                     "validPassword") == data['users'][0]