Show More
@@ -1,81 +1,86 b'' | |||||
1 | """Pylons application test package |
|
1 | """Pylons application test package | |
2 |
|
2 | |||
3 | This package assumes the Pylons environment is already loaded, such as |
|
3 | This package assumes the Pylons environment is already loaded, such as | |
4 | when this script is imported from the `nosetests --with-pylons=test.ini` |
|
4 | when this script is imported from the `nosetests --with-pylons=test.ini` | |
5 | command. |
|
5 | command. | |
6 |
|
6 | |||
7 | This module initializes the application via ``websetup`` (`paster |
|
7 | This module initializes the application via ``websetup`` (`paster | |
8 | setup-app`) and provides the base testing objects. |
|
8 | setup-app`) and provides the base testing objects. | |
9 | """ |
|
9 | """ | |
10 | import os |
|
10 | import os | |
11 | from os.path import join as jn |
|
11 | from os.path import join as jn | |
12 |
|
12 | |||
13 | from unittest import TestCase |
|
13 | from unittest import TestCase | |
14 |
|
14 | |||
15 | from paste.deploy import loadapp |
|
15 | from paste.deploy import loadapp | |
16 | from paste.script.appinstall import SetupCommand |
|
16 | from paste.script.appinstall import SetupCommand | |
17 | from pylons import config, url |
|
17 | from pylons import config, url | |
18 | from routes.util import URLGenerator |
|
18 | from routes.util import URLGenerator | |
19 | from webtest import TestApp |
|
19 | from webtest import TestApp | |
20 |
|
20 | |||
21 | from rhodecode.model import meta |
|
21 | from rhodecode.model import meta | |
22 | import logging |
|
22 | import logging | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | log = logging.getLogger(__name__) |
|
25 | log = logging.getLogger(__name__) | |
26 |
|
26 | |||
27 | import pylons.test |
|
27 | import pylons.test | |
28 |
|
28 | |||
29 | __all__ = ['environ', 'url', 'TestController', 'TESTS_TMP_PATH', 'HG_REPO', |
|
29 | __all__ = ['environ', 'url', 'TestController', 'TESTS_TMP_PATH', 'HG_REPO', | |
30 |
'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', 'HG_FORK', 'GIT_FORK', |
|
30 | 'GIT_REPO', 'NEW_HG_REPO', 'NEW_GIT_REPO', 'HG_FORK', 'GIT_FORK', | |
|
31 | 'TEST_ADMIN_USER', 'TEST_ADMIN_PASS' ] | |||
31 |
|
32 | |||
32 | # Invoke websetup with the current config file |
|
33 | # Invoke websetup with the current config file | |
33 | #SetupCommand('setup-app').run([config_file]) |
|
34 | #SetupCommand('setup-app').run([config_file]) | |
34 |
|
35 | |||
35 | ##RUNNING DESIRED TESTS |
|
36 | ##RUNNING DESIRED TESTS | |
36 | #nosetests -x rhodecode.tests.functional.test_admin_settings:TestSettingsController.test_my_account |
|
37 | #nosetests -x rhodecode.tests.functional.test_admin_settings:TestSettingsController.test_my_account | |
37 |
|
38 | |||
38 | environ = {} |
|
39 | environ = {} | |
39 |
|
40 | |||
40 | #SOME GLOBALS FOR TESTS |
|
41 | #SOME GLOBALS FOR TESTS | |
41 | from tempfile import _RandomNameSequence |
|
42 | from tempfile import _RandomNameSequence | |
42 | TESTS_TMP_PATH = jn('/', 'tmp', 'rc_test_%s' % _RandomNameSequence().next()) |
|
43 | TESTS_TMP_PATH = jn('/', 'tmp', 'rc_test_%s' % _RandomNameSequence().next()) | |
43 | HG_REPO = 'vcs_test_hg' |
|
44 | HG_REPO = 'vcs_test_hg' | |
44 | GIT_REPO = 'vcs_test_git' |
|
45 | GIT_REPO = 'vcs_test_git' | |
45 |
|
46 | |||
46 | NEW_HG_REPO = 'vcs_test_hg_new' |
|
47 | NEW_HG_REPO = 'vcs_test_hg_new' | |
47 | NEW_GIT_REPO = 'vcs_test_git_new' |
|
48 | NEW_GIT_REPO = 'vcs_test_git_new' | |
48 |
|
49 | |||
49 | HG_FORK = 'vcs_test_hg_fork' |
|
50 | HG_FORK = 'vcs_test_hg_fork' | |
50 | GIT_FORK = 'vcs_test_git_fork' |
|
51 | GIT_FORK = 'vcs_test_git_fork' | |
51 |
|
52 | |||
|
53 | TEST_ADMIN_USER = 'test_admin' | |||
|
54 | TEST_ADMIN_PASS = 'test12' | |||
|
55 | ||||
52 | class TestController(TestCase): |
|
56 | class TestController(TestCase): | |
53 |
|
57 | |||
54 | def __init__(self, *args, **kwargs): |
|
58 | def __init__(self, *args, **kwargs): | |
55 | wsgiapp = pylons.test.pylonsapp |
|
59 | wsgiapp = pylons.test.pylonsapp | |
56 | config = wsgiapp.config |
|
60 | config = wsgiapp.config | |
57 |
|
61 | |||
58 | self.app = TestApp(wsgiapp) |
|
62 | self.app = TestApp(wsgiapp) | |
59 | url._push_object(URLGenerator(config['routes.map'], environ)) |
|
63 | url._push_object(URLGenerator(config['routes.map'], environ)) | |
60 | self.sa = meta.Session |
|
64 | self.sa = meta.Session | |
61 | self.index_location = config['app_conf']['index_dir'] |
|
65 | self.index_location = config['app_conf']['index_dir'] | |
62 | TestCase.__init__(self, *args, **kwargs) |
|
66 | TestCase.__init__(self, *args, **kwargs) | |
63 |
|
67 | |||
64 |
def log_user(self, username= |
|
68 | def log_user(self, username=TEST_ADMIN_USER, password=TEST_ADMIN_PASS): | |
65 | response = self.app.post(url(controller='login', action='index'), |
|
69 | response = self.app.post(url(controller='login', action='index'), | |
66 | {'username':username, |
|
70 | {'username':username, | |
67 | 'password':password}) |
|
71 | 'password':password}) | |
68 |
|
72 | |||
69 | if 'invalid user name' in response.body: |
|
73 | if 'invalid user name' in response.body: | |
70 | self.fail('could not login using %s %s' % (username, password)) |
|
74 | self.fail('could not login using %s %s' % (username, password)) | |
71 |
|
75 | |||
72 | self.assertEqual(response.status, '302 Found') |
|
76 | self.assertEqual(response.status, '302 Found') | |
73 | self.assertEqual(response.session['rhodecode_user'].username, username) |
|
77 | self.assertEqual(response.session['rhodecode_user'].username, username) | |
74 | return response.follow() |
|
78 | return response.follow() | |
75 |
|
79 | |||
76 |
|
80 | |||
77 |
|
81 | |||
78 | def checkSessionFlash(self, response, msg): |
|
82 | def checkSessionFlash(self, response, msg): | |
|
83 | print response | |||
79 | self.assertTrue('flash' in response.session) |
|
84 | self.assertTrue('flash' in response.session) | |
80 | self.assertTrue(msg in response.session['flash'][0][1]) |
|
85 | self.assertTrue(msg in response.session['flash'][0][1]) | |
81 |
|
86 |
@@ -1,230 +1,261 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | from rhodecode.tests import * |
|
2 | from rhodecode.tests import * | |
3 | from rhodecode.model.db import User |
|
3 | from rhodecode.model.db import User | |
|
4 | from rhodecode.lib import generate_api_key | |||
4 | from rhodecode.lib.auth import check_password |
|
5 | from rhodecode.lib.auth import check_password | |
5 |
|
6 | |||
6 |
|
7 | |||
7 | class TestLoginController(TestController): |
|
8 | class TestLoginController(TestController): | |
8 |
|
9 | |||
9 | def test_index(self): |
|
10 | def test_index(self): | |
10 | response = self.app.get(url(controller='login', action='index')) |
|
11 | response = self.app.get(url(controller='login', action='index')) | |
11 | assert response.status == '200 OK', 'Wrong response from login page got %s' % response.status |
|
12 | self.assertEqual(response.status, '200 OK') | |
12 | # Test response... |
|
13 | # Test response... | |
13 |
|
14 | |||
14 | def test_login_admin_ok(self): |
|
15 | def test_login_admin_ok(self): | |
15 | response = self.app.post(url(controller='login', action='index'), |
|
16 | response = self.app.post(url(controller='login', action='index'), | |
16 | {'username':'test_admin', |
|
17 | {'username':'test_admin', | |
17 | 'password':'test12'}) |
|
18 | 'password':'test12'}) | |
18 | assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status |
|
19 | self.assertEqual(response.status, '302 Found') | |
19 |
assert |
|
20 | self.assertEqual(response.session['rhodecode_user'].username , | |
|
21 | 'test_admin') | |||
20 | response = response.follow() |
|
22 | response = response.follow() | |
21 |
assert |
|
23 | self.assertTrue('%s repository' % HG_REPO in response.body) | |
22 |
|
24 | |||
23 | def test_login_regular_ok(self): |
|
25 | def test_login_regular_ok(self): | |
24 | response = self.app.post(url(controller='login', action='index'), |
|
26 | response = self.app.post(url(controller='login', action='index'), | |
25 | {'username':'test_regular', |
|
27 | {'username':'test_regular', | |
26 | 'password':'test12'}) |
|
28 | 'password':'test12'}) | |
27 | print response |
|
29 | ||
28 | assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status |
|
30 | self.assertEqual(response.status, '302 Found') | |
29 |
assert |
|
31 | self.assertEqual(response.session['rhodecode_user'].username , | |
|
32 | 'test_regular') | |||
30 | response = response.follow() |
|
33 | response = response.follow() | |
31 |
assert |
|
34 | self.assertTrue('%s repository' % HG_REPO in response.body) | |
32 |
assert |
|
35 | self.assertTrue('<a title="Admin" href="/_admin">' not in response.body) | |
33 |
|
36 | |||
34 | def test_login_ok_came_from(self): |
|
37 | def test_login_ok_came_from(self): | |
35 | test_came_from = '/_admin/users' |
|
38 | test_came_from = '/_admin/users' | |
36 |
response = self.app.post(url(controller='login', action='index', |
|
39 | response = self.app.post(url(controller='login', action='index', | |
|
40 | came_from=test_came_from), | |||
37 | {'username':'test_admin', |
|
41 | {'username':'test_admin', | |
38 | 'password':'test12'}) |
|
42 | 'password':'test12'}) | |
39 | assert response.status == '302 Found', 'Wrong response code from came from redirection' |
|
43 | self.assertEqual(response.status, '302 Found') | |
40 | response = response.follow() |
|
44 | response = response.follow() | |
41 |
|
45 | |||
42 | assert response.status == '200 OK', 'Wrong response from login page got %s' % response.status |
|
46 | self.assertEqual(response.status, '200 OK') | |
43 |
assert |
|
47 | self.assertTrue('Users administration' in response.body) | |
44 |
|
48 | |||
45 |
|
49 | |||
46 | def test_login_short_password(self): |
|
50 | def test_login_short_password(self): | |
47 | response = self.app.post(url(controller='login', action='index'), |
|
51 | response = self.app.post(url(controller='login', action='index'), | |
48 | {'username':'test_admin', |
|
52 | {'username':'test_admin', | |
49 | 'password':'as'}) |
|
53 | 'password':'as'}) | |
50 | self.assertEqual(response.status, '200 OK') |
|
54 | self.assertEqual(response.status, '200 OK') | |
51 | print response.body |
|
55 | ||
52 | self.assertTrue('Enter 3 characters or more' in response.body) |
|
56 | self.assertTrue('Enter 3 characters or more' in response.body) | |
53 |
|
57 | |||
54 | def test_login_wrong_username_password(self): |
|
58 | def test_login_wrong_username_password(self): | |
55 | response = self.app.post(url(controller='login', action='index'), |
|
59 | response = self.app.post(url(controller='login', action='index'), | |
56 | {'username':'error', |
|
60 | {'username':'error', | |
57 | 'password':'test12'}) |
|
61 | 'password':'test12'}) | |
58 |
assert |
|
62 | self.assertEqual(response.status , '200 OK') | |
59 |
|
63 | |||
60 |
assert |
|
64 | self.assertTrue('invalid user name' in response.body) | |
61 |
assert |
|
65 | self.assertTrue('invalid password' in response.body) | |
62 |
|
66 | |||
63 | #========================================================================== |
|
67 | #========================================================================== | |
64 | # REGISTRATIONS |
|
68 | # REGISTRATIONS | |
65 | #========================================================================== |
|
69 | #========================================================================== | |
66 | def test_register(self): |
|
70 | def test_register(self): | |
67 | response = self.app.get(url(controller='login', action='register')) |
|
71 | response = self.app.get(url(controller='login', action='register')) | |
68 |
assert |
|
72 | self.assertTrue('Sign Up to RhodeCode' in response.body) | |
69 |
|
73 | |||
70 | def test_register_err_same_username(self): |
|
74 | def test_register_err_same_username(self): | |
71 | response = self.app.post(url(controller='login', action='register'), |
|
75 | response = self.app.post(url(controller='login', action='register'), | |
72 | {'username':'test_admin', |
|
76 | {'username':'test_admin', | |
73 | 'password':'test12', |
|
77 | 'password':'test12', | |
74 | 'password_confirmation':'test12', |
|
78 | 'password_confirmation':'test12', | |
75 | 'email':'goodmail@domain.com', |
|
79 | 'email':'goodmail@domain.com', | |
76 | 'name':'test', |
|
80 | 'name':'test', | |
77 | 'lastname':'test'}) |
|
81 | 'lastname':'test'}) | |
78 |
|
82 | |||
79 | assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status |
|
83 | self.assertEqual(response.status , '200 OK') | |
80 |
assert |
|
84 | self.assertTrue('This username already exists' in response.body) | |
81 |
|
85 | |||
82 | def test_register_err_same_email(self): |
|
86 | def test_register_err_same_email(self): | |
83 | response = self.app.post(url(controller='login', action='register'), |
|
87 | response = self.app.post(url(controller='login', action='register'), | |
84 | {'username':'test_admin_0', |
|
88 | {'username':'test_admin_0', | |
85 | 'password':'test12', |
|
89 | 'password':'test12', | |
86 | 'password_confirmation':'test12', |
|
90 | 'password_confirmation':'test12', | |
87 | 'email':'test_admin@mail.com', |
|
91 | 'email':'test_admin@mail.com', | |
88 | 'name':'test', |
|
92 | 'name':'test', | |
89 | 'lastname':'test'}) |
|
93 | 'lastname':'test'}) | |
90 |
|
94 | |||
91 | assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status |
|
95 | self.assertEqual(response.status , '200 OK') | |
92 | assert 'This e-mail address is already taken' in response.body |
|
96 | assert 'This e-mail address is already taken' in response.body | |
93 |
|
97 | |||
94 | def test_register_err_same_email_case_sensitive(self): |
|
98 | def test_register_err_same_email_case_sensitive(self): | |
95 | response = self.app.post(url(controller='login', action='register'), |
|
99 | response = self.app.post(url(controller='login', action='register'), | |
96 | {'username':'test_admin_1', |
|
100 | {'username':'test_admin_1', | |
97 | 'password':'test12', |
|
101 | 'password':'test12', | |
98 | 'password_confirmation':'test12', |
|
102 | 'password_confirmation':'test12', | |
99 | 'email':'TesT_Admin@mail.COM', |
|
103 | 'email':'TesT_Admin@mail.COM', | |
100 | 'name':'test', |
|
104 | 'name':'test', | |
101 | 'lastname':'test'}) |
|
105 | 'lastname':'test'}) | |
102 | assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status |
|
106 | self.assertEqual(response.status , '200 OK') | |
103 | assert 'This e-mail address is already taken' in response.body |
|
107 | assert 'This e-mail address is already taken' in response.body | |
104 |
|
108 | |||
105 | def test_register_err_wrong_data(self): |
|
109 | def test_register_err_wrong_data(self): | |
106 | response = self.app.post(url(controller='login', action='register'), |
|
110 | response = self.app.post(url(controller='login', action='register'), | |
107 | {'username':'xs', |
|
111 | {'username':'xs', | |
108 | 'password':'test', |
|
112 | 'password':'test', | |
109 | 'password_confirmation':'test', |
|
113 | 'password_confirmation':'test', | |
110 | 'email':'goodmailm', |
|
114 | 'email':'goodmailm', | |
111 | 'name':'test', |
|
115 | 'name':'test', | |
112 | 'lastname':'test'}) |
|
116 | 'lastname':'test'}) | |
113 | assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status |
|
117 | self.assertEqual(response.status , '200 OK') | |
114 | assert 'An email address must contain a single @' in response.body |
|
118 | assert 'An email address must contain a single @' in response.body | |
115 | assert 'Enter a value 6 characters long or more' in response.body |
|
119 | assert 'Enter a value 6 characters long or more' in response.body | |
116 |
|
120 | |||
117 |
|
121 | |||
118 | def test_register_err_username(self): |
|
122 | def test_register_err_username(self): | |
119 | response = self.app.post(url(controller='login', action='register'), |
|
123 | response = self.app.post(url(controller='login', action='register'), | |
120 | {'username':'error user', |
|
124 | {'username':'error user', | |
121 | 'password':'test12', |
|
125 | 'password':'test12', | |
122 | 'password_confirmation':'test12', |
|
126 | 'password_confirmation':'test12', | |
123 | 'email':'goodmailm', |
|
127 | 'email':'goodmailm', | |
124 | 'name':'test', |
|
128 | 'name':'test', | |
125 | 'lastname':'test'}) |
|
129 | 'lastname':'test'}) | |
126 |
|
130 | |||
127 | print response.body |
|
131 | self.assertEqual(response.status , '200 OK') | |
128 | assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status |
|
|||
129 | assert 'An email address must contain a single @' in response.body |
|
132 | assert 'An email address must contain a single @' in response.body | |
130 | assert ('Username may only contain ' |
|
133 | assert ('Username may only contain ' | |
131 | 'alphanumeric characters underscores, ' |
|
134 | 'alphanumeric characters underscores, ' | |
132 | 'periods or dashes and must begin with ' |
|
135 | 'periods or dashes and must begin with ' | |
133 | 'alphanumeric character') in response.body |
|
136 | 'alphanumeric character') in response.body | |
134 |
|
137 | |||
135 | def test_register_err_case_sensitive(self): |
|
138 | def test_register_err_case_sensitive(self): | |
136 | response = self.app.post(url(controller='login', action='register'), |
|
139 | response = self.app.post(url(controller='login', action='register'), | |
137 | {'username':'Test_Admin', |
|
140 | {'username':'Test_Admin', | |
138 | 'password':'test12', |
|
141 | 'password':'test12', | |
139 | 'password_confirmation':'test12', |
|
142 | 'password_confirmation':'test12', | |
140 | 'email':'goodmailm', |
|
143 | 'email':'goodmailm', | |
141 | 'name':'test', |
|
144 | 'name':'test', | |
142 | 'lastname':'test'}) |
|
145 | 'lastname':'test'}) | |
143 |
|
146 | |||
144 | assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status |
|
147 | self.assertEqual(response.status , '200 OK') | |
145 | assert 'An email address must contain a single @' in response.body |
|
148 | assert 'An email address must contain a single @' in response.body | |
146 | assert 'This username already exists' in response.body |
|
149 | assert 'This username already exists' in response.body | |
147 |
|
150 | |||
148 |
|
151 | |||
149 |
|
152 | |||
150 | def test_register_special_chars(self): |
|
153 | def test_register_special_chars(self): | |
151 | response = self.app.post(url(controller='login', action='register'), |
|
154 | response = self.app.post(url(controller='login', action='register'), | |
152 | {'username':'xxxaxn', |
|
155 | {'username':'xxxaxn', | |
153 | 'password':'Δ ΔΕΊΕΌΔ ΕΕΕΕ', |
|
156 | 'password':'Δ ΔΕΊΕΌΔ ΕΕΕΕ', | |
154 | 'password_confirmation':'Δ ΔΕΊΕΌΔ ΕΕΕΕ', |
|
157 | 'password_confirmation':'Δ ΔΕΊΕΌΔ ΕΕΕΕ', | |
155 | 'email':'goodmailm@test.plx', |
|
158 | 'email':'goodmailm@test.plx', | |
156 | 'name':'test', |
|
159 | 'name':'test', | |
157 | 'lastname':'test'}) |
|
160 | 'lastname':'test'}) | |
158 |
|
161 | |||
159 | print response.body |
|
162 | self.assertEqual(response.status , '200 OK') | |
160 | assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status |
|
|||
161 | assert 'Invalid characters in password' in response.body |
|
163 | assert 'Invalid characters in password' in response.body | |
162 |
|
164 | |||
163 |
|
165 | |||
164 | def test_register_password_mismatch(self): |
|
166 | def test_register_password_mismatch(self): | |
165 | response = self.app.post(url(controller='login', action='register'), |
|
167 | response = self.app.post(url(controller='login', action='register'), | |
166 | {'username':'xs', |
|
168 | {'username':'xs', | |
167 | 'password':'123qwe', |
|
169 | 'password':'123qwe', | |
168 | 'password_confirmation':'qwe123', |
|
170 | 'password_confirmation':'qwe123', | |
169 | 'email':'goodmailm@test.plxa', |
|
171 | 'email':'goodmailm@test.plxa', | |
170 | 'name':'test', |
|
172 | 'name':'test', | |
171 | 'lastname':'test'}) |
|
173 | 'lastname':'test'}) | |
172 |
|
174 | |||
173 | assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status |
|
175 | self.assertEqual(response.status , '200 OK') | |
174 | print response.body |
|
|||
175 | assert 'Password do not match' in response.body |
|
176 | assert 'Password do not match' in response.body | |
176 |
|
177 | |||
177 | def test_register_ok(self): |
|
178 | def test_register_ok(self): | |
178 | username = 'test_regular4' |
|
179 | username = 'test_regular4' | |
179 | password = 'qweqwe' |
|
180 | password = 'qweqwe' | |
180 | email = 'marcin@test.com' |
|
181 | email = 'marcin@test.com' | |
181 | name = 'testname' |
|
182 | name = 'testname' | |
182 | lastname = 'testlastname' |
|
183 | lastname = 'testlastname' | |
183 |
|
184 | |||
184 | response = self.app.post(url(controller='login', action='register'), |
|
185 | response = self.app.post(url(controller='login', action='register'), | |
185 | {'username':username, |
|
186 | {'username':username, | |
186 | 'password':password, |
|
187 | 'password':password, | |
187 | 'password_confirmation':password, |
|
188 | 'password_confirmation':password, | |
188 | 'email':email, |
|
189 | 'email':email, | |
189 | 'name':name, |
|
190 | 'name':name, | |
190 | 'lastname':lastname}) |
|
191 | 'lastname':lastname}) | |
191 | assert response.status == '302 Found', 'Wrong response from register page got %s' % response.status |
|
192 | self.assertEqual(response.status , '302 Found') | |
192 | assert 'You have successfully registered into rhodecode' in response.session['flash'][0], 'No flash message about user registration' |
|
193 | assert 'You have successfully registered into rhodecode' in response.session['flash'][0], 'No flash message about user registration' | |
193 |
|
194 | |||
194 | ret = self.sa.query(User).filter(User.username == 'test_regular4').one() |
|
195 | ret = self.sa.query(User).filter(User.username == 'test_regular4').one() | |
195 | assert ret.username == username , 'field mismatch %s %s' % (ret.username, username) |
|
196 | assert ret.username == username , 'field mismatch %s %s' % (ret.username, username) | |
196 | assert check_password(password, ret.password) == True , 'password mismatch' |
|
197 | assert check_password(password, ret.password) == True , 'password mismatch' | |
197 | assert ret.email == email , 'field mismatch %s %s' % (ret.email, email) |
|
198 | assert ret.email == email , 'field mismatch %s %s' % (ret.email, email) | |
198 | assert ret.name == name , 'field mismatch %s %s' % (ret.name, name) |
|
199 | assert ret.name == name , 'field mismatch %s %s' % (ret.name, name) | |
199 | assert ret.lastname == lastname , 'field mismatch %s %s' % (ret.lastname, lastname) |
|
200 | assert ret.lastname == lastname , 'field mismatch %s %s' % (ret.lastname, lastname) | |
200 |
|
201 | |||
201 |
|
202 | |||
202 | def test_forgot_password_wrong_mail(self): |
|
203 | def test_forgot_password_wrong_mail(self): | |
203 | response = self.app.post(url(controller='login', action='password_reset'), |
|
204 | response = self.app.post(url(controller='login', action='password_reset'), | |
204 | {'email':'marcin@wrongmail.org', }) |
|
205 | {'email':'marcin@wrongmail.org', }) | |
205 |
|
206 | |||
206 | assert "This e-mail address doesn't exist" in response.body, 'Missing error message about wrong email' |
|
207 | assert "This e-mail address doesn't exist" in response.body, 'Missing error message about wrong email' | |
207 |
|
208 | |||
208 | def test_forgot_password(self): |
|
209 | def test_forgot_password(self): | |
209 |
response = self.app.get(url(controller='login', |
|
210 | response = self.app.get(url(controller='login', | |
210 | assert response.status == '200 OK', 'Wrong response from login page got %s' % response.status |
|
211 | action='password_reset')) | |
|
212 | self.assertEqual(response.status , '200 OK') | |||
211 |
|
213 | |||
212 | username = 'test_password_reset_1' |
|
214 | username = 'test_password_reset_1' | |
213 | password = 'qweqwe' |
|
215 | password = 'qweqwe' | |
214 | email = 'marcin@python-works.com' |
|
216 | email = 'marcin@python-works.com' | |
215 | name = 'passwd' |
|
217 | name = 'passwd' | |
216 | lastname = 'reset' |
|
218 | lastname = 'reset' | |
217 |
|
219 | |||
218 | response = self.app.post(url(controller='login', action='register'), |
|
220 | new = User() | |
219 | {'username':username, |
|
221 | new.username = username | |
220 | 'password':password, |
|
222 | new.password = password | |
221 | 'password_confirmation':password, |
|
223 | new.email = email | |
222 | 'email':email, |
|
224 | new.name = name | |
223 | 'name':name, |
|
225 | new.lastname = lastname | |
224 | 'lastname':lastname}) |
|
226 | new.api_key = generate_api_key(username) | |
225 | #register new user for email test |
|
227 | self.sa.add(new) | |
226 | response = self.app.post(url(controller='login', action='password_reset'), |
|
228 | self.sa.commit() | |
|
229 | ||||
|
230 | response = self.app.post(url(controller='login', | |||
|
231 | action='password_reset'), | |||
227 |
|
|
232 | {'email':email, }) | |
228 | print response.session['flash'] |
|
233 | ||
229 | assert 'You have successfully registered into rhodecode' in response.session['flash'][0], 'No flash message about user registration' |
|
234 | self.checkSessionFlash(response, 'Your password reset link was sent') | |
230 | assert 'Your new password was sent' in response.session['flash'][1], 'No flash message about password reset' |
|
235 | ||
|
236 | response = response.follow() | |||
|
237 | ||||
|
238 | # BAD KEY | |||
|
239 | ||||
|
240 | key = "bad" | |||
|
241 | response = self.app.get(url(controller='login', | |||
|
242 | action='password_reset_confirmation', | |||
|
243 | key=key)) | |||
|
244 | self.assertEqual(response.status, '302 Found') | |||
|
245 | self.assertTrue(response.location.endswith(url('reset_password'))) | |||
|
246 | ||||
|
247 | # GOOD KEY | |||
|
248 | ||||
|
249 | key = User.by_username(username).api_key | |||
|
250 | ||||
|
251 | response = self.app.get(url(controller='login', | |||
|
252 | action='password_reset_confirmation', | |||
|
253 | key=key)) | |||
|
254 | self.assertEqual(response.status, '302 Found') | |||
|
255 | self.assertTrue(response.location.endswith(url('login_home'))) | |||
|
256 | ||||
|
257 | self.checkSessionFlash(response, | |||
|
258 | ('Your password reset was successful, ' | |||
|
259 | 'new password has been sent to your email')) | |||
|
260 | ||||
|
261 | response = response.follow() |
@@ -1,42 +1,43 b'' | |||||
1 | [egg_info] |
|
1 | [egg_info] | |
2 | tag_build = beta |
|
2 | tag_build = beta | |
3 | tag_svn_revision = true |
|
3 | tag_svn_revision = true | |
4 |
|
4 | |||
5 | [easy_install] |
|
5 | [easy_install] | |
6 | find_links = http://www.pylonshq.com/download/ |
|
6 | find_links = http://www.pylonshq.com/download/ | |
7 |
|
7 | |||
8 | [nosetests] |
|
8 | [nosetests] | |
9 | verbose=True |
|
9 | verbose=True | |
10 | verbosity=2 |
|
10 | verbosity=2 | |
11 | with-pylons=test.ini |
|
11 | with-pylons=test.ini | |
12 | detailed-errors=1 |
|
12 | detailed-errors=1 | |
|
13 | nologcapture=1 | |||
13 |
|
14 | |||
14 | # Babel configuration |
|
15 | # Babel configuration | |
15 | [compile_catalog] |
|
16 | [compile_catalog] | |
16 | domain = rhodecode |
|
17 | domain = rhodecode | |
17 | directory = rhodecode/i18n |
|
18 | directory = rhodecode/i18n | |
18 | statistics = true |
|
19 | statistics = true | |
19 |
|
20 | |||
20 | [extract_messages] |
|
21 | [extract_messages] | |
21 | add_comments = TRANSLATORS: |
|
22 | add_comments = TRANSLATORS: | |
22 | output_file = rhodecode/i18n/rhodecode.pot |
|
23 | output_file = rhodecode/i18n/rhodecode.pot | |
23 | width = 80 |
|
24 | width = 80 | |
24 |
|
25 | |||
25 | [init_catalog] |
|
26 | [init_catalog] | |
26 | domain = rhodecode |
|
27 | domain = rhodecode | |
27 | input_file = rhodecode/i18n/rhodecode.pot |
|
28 | input_file = rhodecode/i18n/rhodecode.pot | |
28 | output_dir = rhodecode/i18n |
|
29 | output_dir = rhodecode/i18n | |
29 |
|
30 | |||
30 | [update_catalog] |
|
31 | [update_catalog] | |
31 | domain = rhodecode |
|
32 | domain = rhodecode | |
32 | input_file = rhodecode/i18n/rhodecode.pot |
|
33 | input_file = rhodecode/i18n/rhodecode.pot | |
33 | output_dir = rhodecode/i18n |
|
34 | output_dir = rhodecode/i18n | |
34 | previous = true |
|
35 | previous = true | |
35 |
|
36 | |||
36 | [build_sphinx] |
|
37 | [build_sphinx] | |
37 | source-dir = docs/ |
|
38 | source-dir = docs/ | |
38 | build-dir = docs/_build |
|
39 | build-dir = docs/_build | |
39 | all_files = 1 |
|
40 | all_files = 1 | |
40 |
|
41 | |||
41 | [upload_sphinx] |
|
42 | [upload_sphinx] | |
42 | upload-dir = docs/_build/html No newline at end of file |
|
43 | upload-dir = docs/_build/html |
General Comments 0
You need to be logged in to leave comments.
Login now