Beispiel #1
0
def test_delete_user_with_notification():
    user = auth.User(username='******', email='*****@*****.**')
    user.create()
    auth.User.delete(username='******',
                     message='Click http://mysite.com/delete/$url to confirm',
                     confirmation=False)
    assert not auth.User.get_user(username='******')
Beispiel #2
0
def test_suspend_with_message():
    user = auth.User(username='******', email='*****@*****.**')
    user.password = '******'
    user.create(activated=True)
    auth.User.suspend(username='******', message='Your account was suspended')
    user = auth.User.get_user(username='******')
    user.authenticate('abc123')
Beispiel #3
0
def test_delete_user_with_confirmation():
    user = auth.User(username='******', email='*****@*****.**')
    user.create()
    auth.User.delete(username='******',
                     message='Click http://mysite.com/delete/$url to confirm')
    user = auth.User.get_user(username='******')
    assert len(user._act_code) == 64
Beispiel #4
0
def test_clear_interaction_clears_act_type():
    user = auth.User(username='******', email='*****@*****.**')
    user.set_activation()
    user.create()
    user = auth.User.get_user(username='******')
    user.clear_interaction()
    assert user._act_type is None
Beispiel #5
0
def test_login_with_real_account():
    user = auth.User(username='******', email='*****@*****.**')
    user.password = '******'
    user.create()
    login_form = authforms.login_form()
    assert not login_form.validates(
        web.storify({
            'username': '******',
            'password': '******',
        }))
    user.activate()
    user.store()
    assert login_form.validates(
        web.storify({
            'username': '******',
            'password': '******',
        })), login_form.note
    assert not login_form.validates(
        web.storify({
            'username': '******',
            'password': '******',
        }))
    assert not login_form.validates(
        web.storify({
            'username': '******',
            'password': '******',
        }))
Beispiel #6
0
def test_suspend_account():
    user = auth.User(username='******', email='*****@*****.**')
    user.password = '******'
    user.create(activated=True)
    auth.User.suspend(username='******')
    user = auth.User.get_user(username='******')
    user.authenticate('abc123')
Beispiel #7
0
def test_registration_fails_if_user_exists():
    user = auth.User(username='******', email='*****@*****.**')
    user.create()
    reg_form = authforms.register_form()
    assert not reg_form.validates(
        web.storify({
            'username': '******',
            'email': '*****@*****.**',
            'password': '******',
            'confirm': 'abc123',
        }))
    assert not reg_form.validates(
        web.storify({
            'username': '******',
            'email': '*****@*****.**',  # still the same e-mail
            'password': '******',
            'confirm': 'abc123',
        }))
    assert not reg_form.validates(
        web.storify({
            'username': '******',
            'email': '*****@*****.**',
            'password': '******',
            'confirm': 'abc123',
        }))
Beispiel #8
0
def test_reset_password_old_pwd_still_valid():
    user = auth.User(username='******', email='*****@*****.**')
    user.password = '******'
    user.create(activated=True)
    user = auth.User.get_user(username='******')
    user.reset_password('123abc',
                        message='Please visit http://mysite.com/confirm/$url')
    assert user.authenticate('abc123')
Beispiel #9
0
def test_reset_password_with_confirmation():
    user = auth.User(username='******', email='*****@*****.**')
    user.password = '******'
    user.create(activated=True)
    user = auth.User.get_user(username='******')
    user.reset_password('123abc',
                        message='Please visit http://mysite.com/confirm/$url')
    assert len(user._pending_pwd) == 81
Beispiel #10
0
def test_reset_password_with_random_pwd():
    user = auth.User(username='******', email='*****@*****.**')
    user.create(activated=True)
    user = auth.User.get_user(username='******')
    user.reset_password()
    password = user._cleartext
    user = auth.User.get_user(username='******')
    assert user.authenticate(password)
Beispiel #11
0
def test_reset_password():
    user = auth.User(username='******', email='*****@*****.**')
    user.password = '******'
    user.create(activated=True)
    user = auth.User.get_user(username='******')
    user.reset_password('123abc')
    user = auth.User.get_user(username='******')
    assert user.authenticate('123abc')
Beispiel #12
0
def test_store_modifications():
    user = auth.User(username='******', email='*****@*****.**')
    user.create()
    user = auth.User.get_user(username='******')
    user.username = '******'
    user.store()
    user = auth.User.get_user(email='*****@*****.**')
    assert user.username == 'otheruser'
Beispiel #13
0
def test_activation_code_in_db():
    user = auth.User(username='******', email='*****@*****.**')
    user.create(message='This is the activation mail')
    record = database.select('authenticationpy_users',
                             what='act_code',
                             where="username = '******'",
                             limit=1)[0]
    assert record.act_code == user._act_code
Beispiel #14
0
def test_activation_on_create():
    user = auth.User(username='******', email='*****@*****.**')
    user.create(activated=True)
    record = database.select('authenticationpy_users',
                             what='active',
                             where="username = '******'",
                             limit=1)[0]
    assert record.active == True
Beispiel #15
0
def test_reset_password_with_notification():
    user = auth.User(username='******', email='*****@*****.**')
    user.password = '******'
    user.create(activated=True)
    user = auth.User.get_user(username='******')
    user.reset_password('123abc',
                        message='Your password has been reset',
                        confirmation=False)
    assert user.authenticate('123abc')
Beispiel #16
0
def test_user_exist():
    user = auth.User(username='******', email='*****@*****.**')
    user.create()
    assert auth.User.exists(username='******')
    assert auth.User.exists(email='*****@*****.**')
    assert auth.User.exists(username='******', email='*****@*****.**')
    assert auth.User.exists(username='******', email='*****@*****.**')
    assert auth.User.exists(username='******', email='*****@*****.**')
    assert not auth.User.exists(username='******')
    assert not auth.User.exists(email='*****@*****.**')
Beispiel #17
0
def test_data_to_store():
    user = auth.User(username='******', email='*****@*****.**')
    user.create()
    user = auth.User.get_user(username='******')
    user.username = '******'
    user.email = '*****@*****.**'
    assert user._data_to_store == {
        'username': '******',
        'email': '*****@*****.**'
    }
Beispiel #18
0
def test_email_belongs_to_account_validation():
    user = auth.User(username='******', email='*****@*****.**')
    user.create()
    email_form = authforms.email_request_form()
    assert email_form.validates(web.storify({
        'email': user.email,
    })), email_form.note
    assert not email_form.validates(web.storify({
        'email': '*****@*****.**',
    }))
Beispiel #19
0
def test_get_user_sets_cache():
    user = auth.User(username='******', email='*****@*****.**')
    user.create()
    user = auth.User.get_user(username='******')
    assert web.ctx.auth_user_cache
    assert web.ctx.auth_user_cache.get('username')
    assert web.ctx.auth_user_cache.get('email')
    assert web.ctx.auth_user_cache.get('object')
    assert web.ctx.auth_user_cache.get('object') is user
    user = auth.User.get_user(username='******')
    assert web.ctx.auth_user_cache.get('object') is user
Beispiel #20
0
def test_wrapper_reset_returns_code():
    user = auth.User(username='******', email='*****@*****.**')
    code = user.set_reset()
    assert code == user._act_code
Beispiel #21
0
def test_create_user_missing_args():
    auth.User()
Beispiel #22
0
def test_id_property_on_saved_account():
    user = auth.User(username='******', email='*****@*****.**')
    user.create()
    assert user.id == 1
Beispiel #23
0
def test_id_property():
    user = auth.User(username='******', email='*****@*****.**')
    assert user.id is None
Beispiel #24
0
def test_get_user_by_action_code():
    user = auth.User(username='******', email='*****@*****.**')
    user.set_activation()
    user.create()
    same_user = auth.User.get_user_by_act_code(user._act_code)
    assert same_user.username == 'myuser'
Beispiel #25
0
def test_interaction_data_stored_properly():
    user = auth.User(username='******', email='*****@*****.**')
    user.set_activation()
    user.create()
    user = auth.User.get_user(username='******')
    assert user._act_type == 'a'
Beispiel #26
0
def test_interaction_timely_when_no_interaction():
    user = auth.User(username='******', email='*****@*****.**')
    user.is_interaction_timely('a', 10)
Beispiel #27
0
def test_interaction_with_wrong_type():
    user = auth.User(username='******', email='*****@*****.**')
    user.set_activation()
    user.is_interaction_timely('r', 10)
Beispiel #28
0
def test_interaction_past_deadline():
    user = auth.User(username='******', email='*****@*****.**')
    user.set_activation()
    time.sleep(2)
    assert not user.is_interaction_timely('a', 1)
Beispiel #29
0
def create_bad_username_check(string):
    auth.User(username=string, email="*****@*****.**")
Beispiel #30
0
def test_interaction_timeout():
    user = auth.User(username='******', email='*****@*****.**')
    user.set_activation()
    assert user.is_interaction_timely(type='a', deadline=10)