def test_invalid_email():
    clear_v1()
    result1 = auth_register_v2('*****@*****.**', 'password', 'one',
                               'aye')
    with pytest.raises(InputError):
        user_profile_setemail_v2(result1['token'], 'jordanmilchgmail.com')
    with pytest.raises(InputError):
        user_profile_setemail_v2(result1['token'], '*****@*****.**')
def test_basic_setemail():
    clear_v1()
    result1 = auth_register_v2('*****@*****.**', 'password', 'one',
                               'aye')
    output1 = user_profile_v2(result1['token'], result1['auth_user_id'])
    assert output1['user']['email'] == '*****@*****.**'
    user_profile_setemail_v2(result1['token'], '*****@*****.**')
    output2 = user_profile_v2(result1['token'], result1['auth_user_id'])
    assert output2['user']['email'] == '*****@*****.**'
    clear_v1()
예제 #3
0
def test_invalid_email_domain(test_data):
    _, b_data, _ = test_data

    with pytest.raises(InputError):
        user_profile_setemail_v2(b_data["token"], "[email protected]")
        user_profile_setemail_v2(b_data["token"], "[email protected]")
        user_profile_setemail_v2(b_data["token"], "*****@*****.**")
        user_profile_setemail_v2(b_data["token"], "123431@1234")
def test_invalid_token():
    clear_v1()
    result1 = auth_register_v2('*****@*****.**', 'password', 'comp',
                               'student')
    with pytest.raises(AccessError):
        user_profile_setemail_v2('', '*****@*****.**')
    with pytest.raises(AccessError):
        user_profile_sethandle_v1('', 'compstudent01')
    with pytest.raises(AccessError):
        user_profile_setname_v2('', 'jordan', 'milch')
    with pytest.raises(AccessError):
        user_profile_v2('', result1['auth_user_id'])
    with pytest.raises(AccessError):
        users_all_v1('')
    clear_v1()
예제 #5
0
def users_setemail():
    data = request.get_json()
    token = data['token']
    email = data['email']

    output = user_profile_setemail_v2(token, email)

    return dumps(output)
def test_multiple_setemail():
    clear_v1()
    result1 = auth_register_v2('*****@*****.**', 'password', 'one',
                               'aye')
    result2 = auth_register_v2('*****@*****.**', 'password', 'two',
                               'bee')
    result3 = auth_register_v2('*****@*****.**', 'password', 'three',
                               'cee')
    output1 = user_profile_v2(result1['token'], result1['auth_user_id'])
    output2 = user_profile_v2(result1['token'], result2['auth_user_id'])
    output3 = user_profile_v2(result1['token'], result3['auth_user_id'])
    assert output1['user']['email'] == '*****@*****.**'
    assert output2['user']['email'] == '*****@*****.**'
    assert output3['user']['email'] == '*****@*****.**'
    user_profile_setemail_v2(result1['token'], '*****@*****.**')
    user_profile_setemail_v2(result2['token'], '*****@*****.**')
    user_profile_setemail_v2(result3['token'], '*****@*****.**')
    output1a = user_profile_v2(result1['token'], result1['auth_user_id'])
    output2a = user_profile_v2(result2['token'], result2['auth_user_id'])
    output3a = user_profile_v2(result3['token'], result3['auth_user_id'])

    assert output1a['user']['email'] == '*****@*****.**'
    assert output2a['user']['email'] == '*****@*****.**'
    assert output3a['user']['email'] == '*****@*****.**'
    clear_v1()
예제 #7
0
def test_invalid_email_atsign(test_data):
    a_data, _, _ = test_data

    with pytest.raises(InputError):
        user_profile_setemail_v2(a_data["token"], "invalid@[email protected]")
        user_profile_setemail_v2(a_data["token"],
                                 "[email protected]@gmail.com")
        user_profile_setemail_v2(a_data["token"], "invalidemail.gmail.com")
예제 #8
0
def test_invalid_email_characters(test_data):
    _, _, c_data = test_data

    with pytest.raises(InputError):
        user_profile_setemail_v2(c_data["token"],
                                 "invalid!#$$%[email protected]")
        user_profile_setemail_v2(c_data["token"], "invalidemail@gmail@!$!.com")
        user_profile_setemail_v2(c_data["token"],
                                 "invalidemail**&()@gmail@!$!.com")
def test_email_in_use():
    clear_v1()
    result1 = auth_register_v2('*****@*****.**', 'password', 'one',
                               'aye')
    result2 = auth_register_v2('*****@*****.**', 'password', 'two',
                               'bee')
    result3 = auth_register_v2('*****@*****.**', 'password', 'three',
                               'cee')
    with pytest.raises(InputError):
        user_profile_setemail_v2(result1['token'], '*****@*****.**')
    with pytest.raises(InputError):
        user_profile_setemail_v2(result2['token'], '*****@*****.**')
    with pytest.raises(InputError):
        user_profile_setemail_v2(result3['token'], '*****@*****.**')
    clear_v1()
예제 #10
0
def test_invalid_email(test_data):
    a_data, b_data, c_data = test_data

    with pytest.raises(InputError):
        user_profile_setemail_v2(a_data["token"], "")
        user_profile_setemail_v2(a_data["token"], "       ")
        user_profile_setemail_v2(b_data["token"], "123456")
        user_profile_setemail_v2(b_data["token"], "adwdawaasd")
        user_profile_setemail_v2(c_data["token"], "AUNWED2da")
        user_profile_setemail_v2(c_data["token"], "!$*!@$)@(!*$!")
예제 #11
0
def test_invalid_token(test_data):
    a_data, b_data, c_data = test_data

    with pytest.raises(AccessError):
        user_profile_setemail_v2("", a_data["auth_user_id"])
        user_profile_setemail_v2(0, a_data["auth_user_id"])
        user_profile_setemail_v2(999328, a_data["auth_user_id"])
        user_profile_setemail_v2(-42, b_data["auth_user_id"])
        user_profile_setemail_v2("5912381", b_data["auth_user_id"])
        user_profile_setemail_v2("invalid.token.101", b_data["auth_user_id"])
        user_profile_setemail_v2("bytasdoawqeawqdqafwa",
                                 c_data["auth_user_id"])
        user_profile_setemail_v2("ADWNUASMfaaAWwm", c_data["auth_user_id"])
        user_profile_setemail_v2("ASUIdb21d9ADsDi21", c_data["auth_user_id"])
        user_profile_setemail_v2("!)(%&@!*%#!$", a_data["auth_user_id"])
        user_profile_setemail_v2("        ", a_data["auth_user_id"])
예제 #12
0
def test_normal(test_data):
    a_data, b_data, c_data = test_data

    # changing email "name"?
    user_profile_setemail_v2(a_data["token"], "*****@*****.**")
    assert user_profile_v2(
        a_data["token"],
        a_data["auth_user_id"])["user"]["email"] == "*****@*****.**"

    user_profile_setemail_v2(a_data["token"], "123451231@different_domain.au")
    assert user_profile_v2(
        a_data["token"], a_data["auth_user_id"]
    )["user"]["email"] == "123451231@different_domain.au"

    user_profile_setemail_v2(b_data["token"], "*****@*****.**")
    assert user_profile_v2(a_data["token"], b_data["auth_user_id"]
                           )["user"]["email"] == "*****@*****.**"

    user_profile_setemail_v2(c_data["token"],
                             "*****@*****.**")
    assert user_profile_v2(
        a_data["token"], c_data["auth_user_id"]
    )["user"]["email"] == "*****@*****.**"

    # changing domain
    user_profile_setemail_v2(a_data["token"],
                             "*****@*****.**")
    assert user_profile_v2(
        a_data["token"], a_data["auth_user_id"]
    )["user"]["email"] == "*****@*****.**"

    user_profile_setemail_v2(b_data["token"], "*****@*****.**")
    assert user_profile_v2(
        a_data["token"], b_data["auth_user_id"]
    )["user"]["email"] == "*****@*****.**"

    user_profile_setemail_v2(c_data["token"],
                             "*****@*****.**")
    assert user_profile_v2(
        a_data["token"], c_data["auth_user_id"]
    )["user"]["email"] == "*****@*****.**"
예제 #13
0
def test_existing_email(test_data):
    a_data, b_data, c_data = test_data

    with pytest.raises(InputError):
        user_profile_setemail_v2(a_data["token"], "*****@*****.**")
        user_profile_setemail_v2(a_data["token"], "*****@*****.**")
        user_profile_setemail_v2(a_data["token"], "*****@*****.**")
        user_profile_setemail_v2(b_data["token"], "*****@*****.**")
        user_profile_setemail_v2(b_data["token"], "*****@*****.**")
        user_profile_setemail_v2(b_data["token"], "*****@*****.**")
        user_profile_setemail_v2(c_data["token"], "*****@*****.**")
        user_profile_setemail_v2(c_data["token"], "*****@*****.**")
        user_profile_setemail_v2(c_data["token"], "*****@*****.**")