Mercurial > kallithea
annotate rhodecode/tests/functional/test_login.py @ 1732:8321b3d19b1f beta
test fixes
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 26 Nov 2011 21:50:08 +0200 |
parents | f78bee8eec78 |
children | 8ecc6b8229a5 |
rev | line source |
---|---|
728
f1629c0c28cc
fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents:
723
diff
changeset
|
1 # -*- coding: utf-8 -*- |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
534
diff
changeset
|
2 from rhodecode.tests import * |
1732 | 3 from rhodecode.model.db import User, Notification |
1418 | 4 from rhodecode.lib import generate_api_key |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
534
diff
changeset
|
5 from rhodecode.lib.auth import check_password |
1732 | 6 from rhodecode.model.meta import Session |
188
8337dd6492a9
logins controller test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 |
8337dd6492a9
logins controller test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 class TestLoginController(TestController): |
8337dd6492a9
logins controller test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 |
1732 | 10 def tearDown(self): |
11 for n in Notification.query().all(): | |
12 Session().delete(n) | |
13 | |
14 Session().commit() | |
15 self.assertEqual(Notification.query().all(), []) | |
16 | |
188
8337dd6492a9
logins controller test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 def test_index(self): |
8337dd6492a9
logins controller test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 response = self.app.get(url(controller='login', action='index')) |
1418 | 19 self.assertEqual(response.status, '200 OK') |
188
8337dd6492a9
logins controller test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 # Test response... |
461
e95621133eb6
made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents:
188
diff
changeset
|
21 |
e95621133eb6
made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents:
188
diff
changeset
|
22 def test_login_admin_ok(self): |
e95621133eb6
made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents:
188
diff
changeset
|
23 response = self.app.post(url(controller='login', action='index'), |
e95621133eb6
made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents:
188
diff
changeset
|
24 {'username':'test_admin', |
534
12c976209b2e
fixed test for new version 100% test are ok
Marcin Kuzminski <marcin@python-works.com>
parents:
533
diff
changeset
|
25 'password':'test12'}) |
1418 | 26 self.assertEqual(response.status, '302 Found') |
1718
f78bee8eec78
reduce cookie size for better support of client side sessions
Marcin Kuzminski <marcin@python-works.com>
parents:
1713
diff
changeset
|
27 self.assertEqual(response.session['rhodecode_user'].get('username') , |
1418 | 28 'test_admin') |
462
298546182b41
more test suites on login, fixed strange detached instance bug found during in tests.
Marcin Kuzminski <marcin@python-works.com>
parents:
461
diff
changeset
|
29 response = response.follow() |
1418 | 30 self.assertTrue('%s repository' % HG_REPO in response.body) |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
31 |
461
e95621133eb6
made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents:
188
diff
changeset
|
32 def test_login_regular_ok(self): |
e95621133eb6
made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents:
188
diff
changeset
|
33 response = self.app.post(url(controller='login', action='index'), |
462
298546182b41
more test suites on login, fixed strange detached instance bug found during in tests.
Marcin Kuzminski <marcin@python-works.com>
parents:
461
diff
changeset
|
34 {'username':'test_regular', |
534
12c976209b2e
fixed test for new version 100% test are ok
Marcin Kuzminski <marcin@python-works.com>
parents:
533
diff
changeset
|
35 'password':'test12'}) |
1418 | 36 |
37 self.assertEqual(response.status, '302 Found') | |
1718
f78bee8eec78
reduce cookie size for better support of client side sessions
Marcin Kuzminski <marcin@python-works.com>
parents:
1713
diff
changeset
|
38 self.assertEqual(response.session['rhodecode_user'].get('username') , |
1418 | 39 'test_regular') |
462
298546182b41
more test suites on login, fixed strange detached instance bug found during in tests.
Marcin Kuzminski <marcin@python-works.com>
parents:
461
diff
changeset
|
40 response = response.follow() |
1418 | 41 self.assertTrue('%s repository' % HG_REPO in response.body) |
42 self.assertTrue('<a title="Admin" href="/_admin">' not in response.body) | |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
43 |
461
e95621133eb6
made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents:
188
diff
changeset
|
44 def test_login_ok_came_from(self): |
e95621133eb6
made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents:
188
diff
changeset
|
45 test_came_from = '/_admin/users' |
1418 | 46 response = self.app.post(url(controller='login', action='index', |
47 came_from=test_came_from), | |
461
e95621133eb6
made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents:
188
diff
changeset
|
48 {'username':'test_admin', |
534
12c976209b2e
fixed test for new version 100% test are ok
Marcin Kuzminski <marcin@python-works.com>
parents:
533
diff
changeset
|
49 'password':'test12'}) |
1418 | 50 self.assertEqual(response.status, '302 Found') |
461
e95621133eb6
made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents:
188
diff
changeset
|
51 response = response.follow() |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
52 |
1418 | 53 self.assertEqual(response.status, '200 OK') |
54 self.assertTrue('Users administration' in response.body) | |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
55 |
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
56 |
533
53aa1ee1af86
updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents:
483
diff
changeset
|
57 def test_login_short_password(self): |
461
e95621133eb6
made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents:
188
diff
changeset
|
58 response = self.app.post(url(controller='login', action='index'), |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
59 {'username':'test_admin', |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
60 'password':'as'}) |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
61 self.assertEqual(response.status, '200 OK') |
1418 | 62 |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
63 self.assertTrue('Enter 3 characters or more' in response.body) |
533
53aa1ee1af86
updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents:
483
diff
changeset
|
64 |
53aa1ee1af86
updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents:
483
diff
changeset
|
65 def test_login_wrong_username_password(self): |
53aa1ee1af86
updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents:
483
diff
changeset
|
66 response = self.app.post(url(controller='login', action='index'), |
53aa1ee1af86
updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents:
483
diff
changeset
|
67 {'username':'error', |
53aa1ee1af86
updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents:
483
diff
changeset
|
68 'password':'test12'}) |
1418 | 69 self.assertEqual(response.status , '200 OK') |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
70 |
1418 | 71 self.assertTrue('invalid user name' in response.body) |
72 self.assertTrue('invalid password' in response.body) | |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
73 |
723
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
74 #========================================================================== |
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
75 # REGISTRATIONS |
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
76 #========================================================================== |
463
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
77 def test_register(self): |
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
78 response = self.app.get(url(controller='login', action='register')) |
1418 | 79 self.assertTrue('Sign Up to RhodeCode' in response.body) |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
80 |
463
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
81 def test_register_err_same_username(self): |
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
82 response = self.app.post(url(controller='login', action='register'), |
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
83 {'username':'test_admin', |
723
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
84 'password':'test12', |
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
85 'password_confirmation':'test12', |
463
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
86 'email':'goodmail@domain.com', |
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
87 'name':'test', |
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
88 'lastname':'test'}) |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
89 |
1418 | 90 self.assertEqual(response.status , '200 OK') |
91 self.assertTrue('This username already exists' in response.body) | |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
92 |
745
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
93 def test_register_err_same_email(self): |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
94 response = self.app.post(url(controller='login', action='register'), |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
95 {'username':'test_admin_0', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
96 'password':'test12', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
97 'password_confirmation':'test12', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
98 'email':'test_admin@mail.com', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
99 'name':'test', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
100 'lastname':'test'}) |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
101 |
1418 | 102 self.assertEqual(response.status , '200 OK') |
746
18a3ca35d501
fixed grammar in taken email error
Marcin Kuzminski <marcin@python-works.com>
parents:
745
diff
changeset
|
103 assert 'This e-mail address is already taken' in response.body |
745
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
104 |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
105 def test_register_err_same_email_case_sensitive(self): |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
106 response = self.app.post(url(controller='login', action='register'), |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
107 {'username':'test_admin_1', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
108 'password':'test12', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
109 'password_confirmation':'test12', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
110 'email':'TesT_Admin@mail.COM', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
111 'name':'test', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
112 'lastname':'test'}) |
1418 | 113 self.assertEqual(response.status , '200 OK') |
746
18a3ca35d501
fixed grammar in taken email error
Marcin Kuzminski <marcin@python-works.com>
parents:
745
diff
changeset
|
114 assert 'This e-mail address is already taken' in response.body |
745
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
115 |
463
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
116 def test_register_err_wrong_data(self): |
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
117 response = self.app.post(url(controller='login', action='register'), |
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
118 {'username':'xs', |
723
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
119 'password':'test', |
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
120 'password_confirmation':'test', |
463
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
121 'email':'goodmailm', |
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
122 'name':'test', |
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
123 'lastname':'test'}) |
1418 | 124 self.assertEqual(response.status , '200 OK') |
463
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
125 assert 'An email address must contain a single @' in response.body |
728
f1629c0c28cc
fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents:
723
diff
changeset
|
126 assert 'Enter a value 6 characters long or more' in response.body |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
127 |
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
128 |
745
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
129 def test_register_err_username(self): |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
130 response = self.app.post(url(controller='login', action='register'), |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
131 {'username':'error user', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
132 'password':'test12', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
133 'password_confirmation':'test12', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
134 'email':'goodmailm', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
135 'name':'test', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
136 'lastname':'test'}) |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
137 |
1418 | 138 self.assertEqual(response.status , '200 OK') |
745
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
139 assert 'An email address must contain a single @' in response.body |
1021 | 140 assert ('Username may only contain ' |
141 'alphanumeric characters underscores, ' | |
142 'periods or dashes and must begin with ' | |
143 'alphanumeric character') in response.body | |
745
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
144 |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
145 def test_register_err_case_sensitive(self): |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
146 response = self.app.post(url(controller='login', action='register'), |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
147 {'username':'Test_Admin', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
148 'password':'test12', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
149 'password_confirmation':'test12', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
150 'email':'goodmailm', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
151 'name':'test', |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
152 'lastname':'test'}) |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
153 |
1418 | 154 self.assertEqual(response.status , '200 OK') |
1539
bd604cf75c5a
fixes #260 Put repo in group, then move group to another group -> repo becomes unavailable
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
155 self.assertTrue('An email address must contain a single @' in response.body) |
bd604cf75c5a
fixes #260 Put repo in group, then move group to another group -> repo becomes unavailable
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
156 self.assertTrue('This username already exists' in response.body) |
745
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
157 |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
158 |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
159 |
723
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
160 def test_register_special_chars(self): |
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
161 response = self.app.post(url(controller='login', action='register'), |
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
162 {'username':'xxxaxn', |
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
163 'password':'ąćźżąśśśś', |
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
164 'password_confirmation':'ąćźżąśśśś', |
728
f1629c0c28cc
fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents:
723
diff
changeset
|
165 'email':'goodmailm@test.plx', |
723
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
166 'name':'test', |
728
f1629c0c28cc
fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents:
723
diff
changeset
|
167 'lastname':'test'}) |
723
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
168 |
1418 | 169 self.assertEqual(response.status , '200 OK') |
1539
bd604cf75c5a
fixes #260 Put repo in group, then move group to another group -> repo becomes unavailable
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
170 self.assertTrue('Invalid characters in password' in response.body) |
723
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
171 |
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
172 |
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
173 def test_register_password_mismatch(self): |
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
174 response = self.app.post(url(controller='login', action='register'), |
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
175 {'username':'xs', |
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
176 'password':'123qwe', |
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
177 'password_confirmation':'qwe123', |
728
f1629c0c28cc
fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents:
723
diff
changeset
|
178 'email':'goodmailm@test.plxa', |
723
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
179 'name':'test', |
728
f1629c0c28cc
fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents:
723
diff
changeset
|
180 'lastname':'test'}) |
723
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
181 |
1418 | 182 self.assertEqual(response.status , '200 OK') |
1481
605707b50d7c
test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents:
1418
diff
changeset
|
183 assert 'Passwords do not match' in response.body |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
184 |
463
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
185 def test_register_ok(self): |
473
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
463
diff
changeset
|
186 username = 'test_regular4' |
463
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
187 password = 'qweqwe' |
483
a9e50dce3081
Removed config names from whoosh and celery,
Marcin Kuzminski <marcin@python-works.com>
parents:
473
diff
changeset
|
188 email = 'marcin@test.com' |
463
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
189 name = 'testname' |
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
190 lastname = 'testlastname' |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
191 |
463
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
192 response = self.app.post(url(controller='login', action='register'), |
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
193 {'username':username, |
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
194 'password':password, |
723
bf26b46e82d6
some tests update
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
195 'password_confirmation':password, |
463
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
196 'email':email, |
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
197 'name':name, |
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
198 'lastname':lastname}) |
1418 | 199 self.assertEqual(response.status , '302 Found') |
549
f99075170eb4
more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
200 assert 'You have successfully registered into rhodecode' in response.session['flash'][0], 'No flash message about user registration' |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
201 |
1713
54687aa00724
Tests updates, Session refactoring
Marcin Kuzminski <marcin@python-works.com>
parents:
1693
diff
changeset
|
202 ret = self.Session().query(User).filter(User.username == 'test_regular4').one() |
463
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
203 assert ret.username == username , 'field mismatch %s %s' % (ret.username, username) |
483
a9e50dce3081
Removed config names from whoosh and celery,
Marcin Kuzminski <marcin@python-works.com>
parents:
473
diff
changeset
|
204 assert check_password(password, ret.password) == True , 'password mismatch' |
463
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
205 assert ret.email == email , 'field mismatch %s %s' % (ret.email, email) |
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
206 assert ret.name == name , 'field mismatch %s %s' % (ret.name, name) |
a03250279b15
test for register page
Marcin Kuzminski <marcin@python-works.com>
parents:
462
diff
changeset
|
207 assert ret.lastname == lastname , 'field mismatch %s %s' % (ret.lastname, lastname) |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
208 |
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
209 |
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
210 def test_forgot_password_wrong_mail(self): |
473
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
463
diff
changeset
|
211 response = self.app.post(url(controller='login', action='password_reset'), |
483
a9e50dce3081
Removed config names from whoosh and celery,
Marcin Kuzminski <marcin@python-works.com>
parents:
473
diff
changeset
|
212 {'email':'marcin@wrongmail.org', }) |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
213 |
746
18a3ca35d501
fixed grammar in taken email error
Marcin Kuzminski <marcin@python-works.com>
parents:
745
diff
changeset
|
214 assert "This e-mail address doesn't exist" in response.body, 'Missing error message about wrong email' |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
215 |
473
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
463
diff
changeset
|
216 def test_forgot_password(self): |
1418 | 217 response = self.app.get(url(controller='login', |
218 action='password_reset')) | |
219 self.assertEqual(response.status , '200 OK') | |
473
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
463
diff
changeset
|
220 |
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
463
diff
changeset
|
221 username = 'test_password_reset_1' |
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
463
diff
changeset
|
222 password = 'qweqwe' |
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
463
diff
changeset
|
223 email = 'marcin@python-works.com' |
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
463
diff
changeset
|
224 name = 'passwd' |
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
463
diff
changeset
|
225 lastname = 'reset' |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
567
diff
changeset
|
226 |
1418 | 227 new = User() |
228 new.username = username | |
229 new.password = password | |
230 new.email = email | |
231 new.name = name | |
232 new.lastname = lastname | |
233 new.api_key = generate_api_key(username) | |
1713
54687aa00724
Tests updates, Session refactoring
Marcin Kuzminski <marcin@python-works.com>
parents:
1693
diff
changeset
|
234 self.Session().add(new) |
54687aa00724
Tests updates, Session refactoring
Marcin Kuzminski <marcin@python-works.com>
parents:
1693
diff
changeset
|
235 self.Session().commit() |
1418 | 236 |
237 response = self.app.post(url(controller='login', | |
238 action='password_reset'), | |
239 {'email':email, }) | |
240 | |
241 self.checkSessionFlash(response, 'Your password reset link was sent') | |
242 | |
243 response = response.follow() | |
244 | |
245 # BAD KEY | |
246 | |
247 key = "bad" | |
248 response = self.app.get(url(controller='login', | |
249 action='password_reset_confirmation', | |
250 key=key)) | |
251 self.assertEqual(response.status, '302 Found') | |
252 self.assertTrue(response.location.endswith(url('reset_password'))) | |
253 | |
254 # GOOD KEY | |
255 | |
1530
04027bdb876c
Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1481
diff
changeset
|
256 key = User.get_by_username(username).api_key |
1418 | 257 response = self.app.get(url(controller='login', |
258 action='password_reset_confirmation', | |
259 key=key)) | |
260 self.assertEqual(response.status, '302 Found') | |
261 self.assertTrue(response.location.endswith(url('login_home'))) | |
262 | |
263 self.checkSessionFlash(response, | |
264 ('Your password reset was successful, ' | |
265 'new password has been sent to your email')) | |
266 | |
267 response = response.follow() |