##// END OF EJS Templates
fixes #260 Put repo in group, then move group to another group -> repo becomes unavailable
fixes #260 Put repo in group, then move group to another group -> repo becomes unavailable

File last commit:

r1539:bd604cf7 beta
r1539:bd604cf7 beta
Show More
test_login.py
261 lines | 12.1 KiB | text/x-python | PythonLexer
fixed bug in forms found due to testing,...
r728 # -*- coding: utf-8 -*-
renamed project to rhodecode
r547 from rhodecode.tests import *
from rhodecode.model.db import User
Fixes tests
r1418 from rhodecode.lib import generate_api_key
renamed project to rhodecode
r547 from rhodecode.lib.auth import check_password
class TestLoginController(TestController):
def test_index(self):
response = self.app.get(url(controller='login', action='index'))
Fixes tests
r1418 self.assertEqual(response.status, '200 OK')
renamed project to rhodecode
r547 # Test response...
def test_login_admin_ok(self):
response = self.app.post(url(controller='login', action='index'),
{'username':'test_admin',
'password':'test12'})
Fixes tests
r1418 self.assertEqual(response.status, '302 Found')
self.assertEqual(response.session['rhodecode_user'].username ,
'test_admin')
renamed project to rhodecode
r547 response = response.follow()
Fixes tests
r1418 self.assertTrue('%s repository' % HG_REPO in response.body)
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
renamed project to rhodecode
r547 def test_login_regular_ok(self):
response = self.app.post(url(controller='login', action='index'),
{'username':'test_regular',
'password':'test12'})
Fixes tests
r1418
self.assertEqual(response.status, '302 Found')
self.assertEqual(response.session['rhodecode_user'].username ,
'test_regular')
renamed project to rhodecode
r547 response = response.follow()
Fixes tests
r1418 self.assertTrue('%s repository' % HG_REPO in response.body)
self.assertTrue('<a title="Admin" href="/_admin">' not in response.body)
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
renamed project to rhodecode
r547 def test_login_ok_came_from(self):
test_came_from = '/_admin/users'
Fixes tests
r1418 response = self.app.post(url(controller='login', action='index',
came_from=test_came_from),
renamed project to rhodecode
r547 {'username':'test_admin',
'password':'test12'})
Fixes tests
r1418 self.assertEqual(response.status, '302 Found')
renamed project to rhodecode
r547 response = response.follow()
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
Fixes tests
r1418 self.assertEqual(response.status, '200 OK')
self.assertTrue('Users administration' in response.body)
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
renamed project to rhodecode
r547 def test_login_short_password(self):
response = self.app.post(url(controller='login', action='index'),
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 {'username':'test_admin',
'password':'as'})
self.assertEqual(response.status, '200 OK')
Fixes tests
r1418
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached...
r1366 self.assertTrue('Enter 3 characters or more' in response.body)
renamed project to rhodecode
r547
def test_login_wrong_username_password(self):
response = self.app.post(url(controller='login', action='index'),
{'username':'error',
'password':'test12'})
Fixes tests
r1418 self.assertEqual(response.status , '200 OK')
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
Fixes tests
r1418 self.assertTrue('invalid user name' in response.body)
self.assertTrue('invalid password' in response.body)
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
some tests update
r723 #==========================================================================
# REGISTRATIONS
#==========================================================================
renamed project to rhodecode
r547 def test_register(self):
response = self.app.get(url(controller='login', action='register'))
Fixes tests
r1418 self.assertTrue('Sign Up to RhodeCode' in response.body)
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
renamed project to rhodecode
r547 def test_register_err_same_username(self):
response = self.app.post(url(controller='login', action='register'),
{'username':'test_admin',
some tests update
r723 'password':'test12',
'password_confirmation':'test12',
renamed project to rhodecode
r547 'email':'goodmail@domain.com',
'name':'test',
'lastname':'test'})
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
Fixes tests
r1418 self.assertEqual(response.status , '200 OK')
self.assertTrue('This username already exists' in response.body)
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
added test for username and email case senstitive validators,...
r745 def test_register_err_same_email(self):
response = self.app.post(url(controller='login', action='register'),
{'username':'test_admin_0',
'password':'test12',
'password_confirmation':'test12',
'email':'test_admin@mail.com',
'name':'test',
'lastname':'test'})
Fixes tests
r1418 self.assertEqual(response.status , '200 OK')
fixed grammar in taken email error
r746 assert 'This e-mail address is already taken' in response.body
added test for username and email case senstitive validators,...
r745
def test_register_err_same_email_case_sensitive(self):
response = self.app.post(url(controller='login', action='register'),
{'username':'test_admin_1',
'password':'test12',
'password_confirmation':'test12',
'email':'TesT_Admin@mail.COM',
'name':'test',
'lastname':'test'})
Fixes tests
r1418 self.assertEqual(response.status , '200 OK')
fixed grammar in taken email error
r746 assert 'This e-mail address is already taken' in response.body
added test for username and email case senstitive validators,...
r745
renamed project to rhodecode
r547 def test_register_err_wrong_data(self):
response = self.app.post(url(controller='login', action='register'),
{'username':'xs',
some tests update
r723 'password':'test',
'password_confirmation':'test',
renamed project to rhodecode
r547 'email':'goodmailm',
'name':'test',
'lastname':'test'})
Fixes tests
r1418 self.assertEqual(response.status , '200 OK')
renamed project to rhodecode
r547 assert 'An email address must contain a single @' in response.body
fixed bug in forms found due to testing,...
r728 assert 'Enter a value 6 characters long or more' in response.body
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
added test for username and email case senstitive validators,...
r745 def test_register_err_username(self):
response = self.app.post(url(controller='login', action='register'),
{'username':'error user',
'password':'test12',
'password_confirmation':'test12',
'email':'goodmailm',
'name':'test',
'lastname':'test'})
Fixes tests
r1418 self.assertEqual(response.status , '200 OK')
added test for username and email case senstitive validators,...
r745 assert 'An email address must contain a single @' in response.body
fixed tests
r1021 assert ('Username may only contain '
'alphanumeric characters underscores, '
'periods or dashes and must begin with '
'alphanumeric character') in response.body
added test for username and email case senstitive validators,...
r745
def test_register_err_case_sensitive(self):
response = self.app.post(url(controller='login', action='register'),
{'username':'Test_Admin',
'password':'test12',
'password_confirmation':'test12',
'email':'goodmailm',
'name':'test',
'lastname':'test'})
Fixes tests
r1418 self.assertEqual(response.status , '200 OK')
fixes #260 Put repo in group, then move group to another group -> repo becomes unavailable
r1539 self.assertTrue('An email address must contain a single @' in response.body)
self.assertTrue('This username already exists' in response.body)
added test for username and email case senstitive validators,...
r745
some tests update
r723 def test_register_special_chars(self):
response = self.app.post(url(controller='login', action='register'),
{'username':'xxxaxn',
'password':'ąćźżąśśśś',
'password_confirmation':'ąćźżąśśśś',
fixed bug in forms found due to testing,...
r728 'email':'goodmailm@test.plx',
some tests update
r723 'name':'test',
fixed bug in forms found due to testing,...
r728 'lastname':'test'})
some tests update
r723
Fixes tests
r1418 self.assertEqual(response.status , '200 OK')
fixes #260 Put repo in group, then move group to another group -> repo becomes unavailable
r1539 self.assertTrue('Invalid characters in password' in response.body)
some tests update
r723
def test_register_password_mismatch(self):
response = self.app.post(url(controller='login', action='register'),
{'username':'xs',
'password':'123qwe',
'password_confirmation':'qwe123',
fixed bug in forms found due to testing,...
r728 'email':'goodmailm@test.plxa',
some tests update
r723 'name':'test',
fixed bug in forms found due to testing,...
r728 'lastname':'test'})
some tests update
r723
Fixes tests
r1418 self.assertEqual(response.status , '200 OK')
test fixes for vcs update
r1481 assert 'Passwords do not match' in response.body
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
renamed project to rhodecode
r547 def test_register_ok(self):
username = 'test_regular4'
password = 'qweqwe'
email = 'marcin@test.com'
name = 'testname'
lastname = 'testlastname'
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
renamed project to rhodecode
r547 response = self.app.post(url(controller='login', action='register'),
{'username':username,
'password':password,
some tests update
r723 'password_confirmation':password,
renamed project to rhodecode
r547 'email':email,
'name':name,
'lastname':lastname})
Fixes tests
r1418 self.assertEqual(response.status , '302 Found')
more renames for rhode code !!
r549 assert 'You have successfully registered into rhodecode' in response.session['flash'][0], 'No flash message about user registration'
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
renamed project to rhodecode
r547 ret = self.sa.query(User).filter(User.username == 'test_regular4').one()
assert ret.username == username , 'field mismatch %s %s' % (ret.username, username)
assert check_password(password, ret.password) == True , 'password mismatch'
assert ret.email == email , 'field mismatch %s %s' % (ret.email, email)
assert ret.name == name , 'field mismatch %s %s' % (ret.name, name)
assert ret.lastname == lastname , 'field mismatch %s %s' % (ret.lastname, lastname)
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
def test_forgot_password_wrong_mail(self):
renamed project to rhodecode
r547 response = self.app.post(url(controller='login', action='password_reset'),
{'email':'marcin@wrongmail.org', })
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
fixed grammar in taken email error
r746 assert "This e-mail address doesn't exist" in response.body, 'Missing error message about wrong email'
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
renamed project to rhodecode
r547 def test_forgot_password(self):
Fixes tests
r1418 response = self.app.get(url(controller='login',
action='password_reset'))
self.assertEqual(response.status , '200 OK')
renamed project to rhodecode
r547
username = 'test_password_reset_1'
password = 'qweqwe'
email = 'marcin@python-works.com'
name = 'passwd'
lastname = 'reset'
extended repo creation by repo type. fixed fork creation to maintain repo type.
r659
Fixes tests
r1418 new = User()
new.username = username
new.password = password
new.email = email
new.name = name
new.lastname = lastname
new.api_key = generate_api_key(username)
self.sa.add(new)
self.sa.commit()
response = self.app.post(url(controller='login',
action='password_reset'),
{'email':email, })
self.checkSessionFlash(response, 'Your password reset link was sent')
response = response.follow()
# BAD KEY
key = "bad"
response = self.app.get(url(controller='login',
action='password_reset_confirmation',
key=key))
self.assertEqual(response.status, '302 Found')
self.assertTrue(response.location.endswith(url('reset_password')))
# GOOD KEY
Refactoring of model get functions
r1530 key = User.get_by_username(username).api_key
Fixes tests
r1418
response = self.app.get(url(controller='login',
action='password_reset_confirmation',
key=key))
self.assertEqual(response.status, '302 Found')
self.assertTrue(response.location.endswith(url('login_home')))
self.checkSessionFlash(response,
('Your password reset was successful, '
'new password has been sent to your email'))
response = response.follow()