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='******')
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')
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
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
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': '******', }))
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')
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', }))
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')
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
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)
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')
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'
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
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
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')
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='*****@*****.**')
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': '*****@*****.**' }
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': '*****@*****.**', }))
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
def test_wrapper_reset_returns_code(): user = auth.User(username='******', email='*****@*****.**') code = user.set_reset() assert code == user._act_code
def test_create_user_missing_args(): auth.User()
def test_id_property_on_saved_account(): user = auth.User(username='******', email='*****@*****.**') user.create() assert user.id == 1
def test_id_property(): user = auth.User(username='******', email='*****@*****.**') assert user.id is None
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'
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'
def test_interaction_timely_when_no_interaction(): user = auth.User(username='******', email='*****@*****.**') user.is_interaction_timely('a', 10)
def test_interaction_with_wrong_type(): user = auth.User(username='******', email='*****@*****.**') user.set_activation() user.is_interaction_timely('r', 10)
def test_interaction_past_deadline(): user = auth.User(username='******', email='*****@*****.**') user.set_activation() time.sleep(2) assert not user.is_interaction_timely('a', 1)
def create_bad_username_check(string): auth.User(username=string, email="*****@*****.**")
def test_interaction_timeout(): user = auth.User(username='******', email='*****@*****.**') user.set_activation() assert user.is_interaction_timely(type='a', deadline=10)