annotate rhodecode/tests/functional/test_login.py @ 1057:af6ca51fb80f

rhodecode release 1.1.3 changes
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 16 Feb 2011 11:05:35 +0100
parents 18a3ca35d501
children 6832ef664673
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 *
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 534
diff changeset
3 from rhodecode.model.db import User
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 534
diff changeset
4 from rhodecode.lib.auth import check_password
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
5
188
8337dd6492a9 logins controller test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6
8337dd6492a9 logins controller test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 class TestLoginController(TestController):
8337dd6492a9 logins controller test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8
8337dd6492a9 logins controller test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 def test_index(self):
8337dd6492a9 logins controller test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 response = self.app.get(url(controller='login', action='index'))
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
11 assert response.status == '200 OK', 'Wrong response from login page got %s' % response.status
188
8337dd6492a9 logins controller test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 # Test response...
461
e95621133eb6 made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents: 188
diff changeset
13
e95621133eb6 made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents: 188
diff changeset
14 def test_login_admin_ok(self):
e95621133eb6 made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents: 188
diff changeset
15 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
16 {'username':'test_admin',
534
12c976209b2e fixed test for new version 100% test are ok
Marcin Kuzminski <marcin@python-works.com>
parents: 533
diff changeset
17 'password':'test12'})
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
18 assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status
548
b75b77ef649d renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
19 assert response.session['rhodecode_user'].username == 'test_admin', 'wrong logged in user'
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
20 response = response.follow()
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 659
diff changeset
21 assert '%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
22
461
e95621133eb6 made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents: 188
diff changeset
23 def test_login_regular_ok(self):
e95621133eb6 made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents: 188
diff changeset
24 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
25 {'username':'test_regular',
534
12c976209b2e fixed test for new version 100% test are ok
Marcin Kuzminski <marcin@python-works.com>
parents: 533
diff changeset
26 'password':'test12'})
533
53aa1ee1af86 updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents: 483
diff changeset
27 print response
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
28 assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status
548
b75b77ef649d renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
29 assert response.session['rhodecode_user'].username == 'test_regular', 'wrong logged in user'
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
30 response = response.follow()
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 659
diff changeset
31 assert '%s repository' % HG_REPO in response.body
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
32 assert '<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
33
461
e95621133eb6 made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents: 188
diff changeset
34 def test_login_ok_came_from(self):
e95621133eb6 made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents: 188
diff changeset
35 test_came_from = '/_admin/users'
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
36 response = self.app.post(url(controller='login', action='index', came_from=test_came_from),
461
e95621133eb6 made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents: 188
diff changeset
37 {'username':'test_admin',
534
12c976209b2e fixed test for new version 100% test are ok
Marcin Kuzminski <marcin@python-works.com>
parents: 533
diff changeset
38 'password':'test12'})
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
39 assert response.status == '302 Found', 'Wrong response code from came from redirection'
461
e95621133eb6 made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents: 188
diff changeset
40 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
41
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
42 assert response.status == '200 OK', 'Wrong response from login page got %s' % response.status
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
43 assert 'Users administration' in response.body, 'No proper title in response'
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
44
758f64f3fbda extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
45
533
53aa1ee1af86 updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents: 483
diff changeset
46 def test_login_short_password(self):
461
e95621133eb6 made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents: 188
diff changeset
47 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
48 {'username':'error',
e95621133eb6 made test for login page
Marcin Kuzminski <marcin@python-works.com>
parents: 188
diff changeset
49 'password':'test'})
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
50 assert response.status == '200 OK', 'Wrong response from login page'
567
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 549
diff changeset
51 print response.body
80dc0a23edf7 fixed whoosh failure on new repository
Marcin Kuzminski <marcin@python-works.com>
parents: 549
diff changeset
52 assert 'Enter 6 characters or more' in response.body, 'No error password message in response'
533
53aa1ee1af86 updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents: 483
diff changeset
53
53aa1ee1af86 updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents: 483
diff changeset
54 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
55 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
56 {'username':'error',
53aa1ee1af86 updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents: 483
diff changeset
57 'password':'test12'})
53aa1ee1af86 updated tests for new version 6char password etc...
Marcin Kuzminski <marcin@python-works.com>
parents: 483
diff changeset
58 assert response.status == '200 OK', 'Wrong response from login page'
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
59
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
60 assert 'invalid user name' in response.body, 'No error username message in response'
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
61 assert 'invalid password' in response.body, 'No error password message in response'
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
62
723
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
63 #==========================================================================
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
64 # REGISTRATIONS
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
65 #==========================================================================
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
66 def test_register(self):
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
67 response = self.app.get(url(controller='login', action='register'))
728
f1629c0c28cc fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents: 723
diff changeset
68 assert 'Sign Up to RhodeCode' in response.body, 'wrong page for 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
69
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
70 def test_register_err_same_username(self):
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
71 response = self.app.post(url(controller='login', action='register'),
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
72 {'username':'test_admin',
723
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
73 'password':'test12',
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
74 'password_confirmation':'test12',
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
75 'email':'goodmail@domain.com',
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
76 'name':'test',
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
77 '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
78
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
79 assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status
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 assert 'This username already exists' in response.body
758f64f3fbda extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
81
745
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
82 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
83 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
84 {'username':'test_admin_0',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
85 'password':'test12',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
86 'password_confirmation':'test12',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
87 '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
88 'name':'test',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
89 'lastname':'test'})
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
90
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
91 assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status
746
18a3ca35d501 fixed grammar in taken email error
Marcin Kuzminski <marcin@python-works.com>
parents: 745
diff changeset
92 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
93
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
94 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
95 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
96 {'username':'test_admin_1',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
97 'password':'test12',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
98 'password_confirmation':'test12',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
99 '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
100 'name':'test',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
101 'lastname':'test'})
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
102 assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status
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
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
105 def test_register_err_wrong_data(self):
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
106 response = self.app.post(url(controller='login', action='register'),
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
107 {'username':'xs',
723
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
108 'password':'test',
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
109 'password_confirmation':'test',
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
110 'email':'goodmailm',
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
111 'name':'test',
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
112 'lastname':'test'})
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
113 assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
114 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
115 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
116
758f64f3fbda extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
117
745
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
118 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
119 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
120 {'username':'error user',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
121 'password':'test12',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
122 'password_confirmation':'test12',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
123 'email':'goodmailm',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
124 'name':'test',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
125 'lastname':'test'})
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
126
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
127 print response.body
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
128 assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
129 assert 'An email address must contain a single @' in response.body
1057
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
130 assert ('Username may only contain '
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
131 'alphanumeric characters underscores, '
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
132 'periods or dashes and must begin with '
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
133 '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
134
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
135 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
136 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
137 {'username':'Test_Admin',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
138 'password':'test12',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
139 'password_confirmation':'test12',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
140 'email':'goodmailm',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
141 'name':'test',
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
142 'lastname':'test'})
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
143
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
144 assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
145 assert 'An email address must contain a single @' in response.body
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
146 assert 'This username already exists' in response.body
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
147
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
148
c366b237c91d added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents: 728
diff changeset
149
723
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
150 def test_register_special_chars(self):
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
151 response = self.app.post(url(controller='login', action='register'),
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
152 {'username':'xxxaxn',
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
153 'password':'ąćźżąśśśś',
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
154 'password_confirmation':'ąćźżąśśśś',
728
f1629c0c28cc fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents: 723
diff changeset
155 'email':'goodmailm@test.plx',
723
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
156 'name':'test',
728
f1629c0c28cc fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents: 723
diff changeset
157 'lastname':'test'})
723
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
158
728
f1629c0c28cc fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents: 723
diff changeset
159 print response.body
723
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
160 assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
161 assert 'Invalid characters in password' in response.body
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
162
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
163
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
164 def test_register_password_mismatch(self):
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
165 response = self.app.post(url(controller='login', action='register'),
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
166 {'username':'xs',
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
167 'password':'123qwe',
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
168 'password_confirmation':'qwe123',
728
f1629c0c28cc fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents: 723
diff changeset
169 'email':'goodmailm@test.plxa',
723
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
170 'name':'test',
728
f1629c0c28cc fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents: 723
diff changeset
171 'lastname':'test'})
723
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 assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status
728
f1629c0c28cc fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents: 723
diff changeset
174 print response.body
723
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
175 assert 'Password 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
176
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
177 def test_register_ok(self):
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
178 username = 'test_regular4'
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
179 password = 'qweqwe'
483
a9e50dce3081 Removed config names from whoosh and celery,
Marcin Kuzminski <marcin@python-works.com>
parents: 473
diff changeset
180 email = 'marcin@test.com'
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
181 name = 'testname'
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
182 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
183
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
184 response = self.app.post(url(controller='login', action='register'),
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
185 {'username':username,
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
186 'password':password,
723
bf26b46e82d6 some tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
187 'password_confirmation':password,
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
188 'email':email,
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
189 'name':name,
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
190 '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
191 assert response.status == '302 Found', 'Wrong response from register page got %s' % response.status
549
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
192 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
193
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
194 ret = self.sa.query(User).filter(User.username == 'test_regular4').one()
463
a03250279b15 test for register page
Marcin Kuzminski <marcin@python-works.com>
parents: 462
diff changeset
195 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
196 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
197 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
198 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
199 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
200
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
758f64f3fbda extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
202 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
203 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
204 {'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
205
746
18a3ca35d501 fixed grammar in taken email error
Marcin Kuzminski <marcin@python-works.com>
parents: 745
diff changeset
206 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
207
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
208 def test_forgot_password(self):
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
209 response = self.app.get(url(controller='login', action='password_reset'))
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
210 assert response.status == '200 OK', 'Wrong response from login page got %s' % response.status
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
211
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
212 username = 'test_password_reset_1'
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
213 password = 'qweqwe'
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
214 email = 'marcin@python-works.com'
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
215 name = 'passwd'
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
216 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
217
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
218 response = self.app.post(url(controller='login', action='register'),
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
219 {'username':username,
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
220 'password':password,
728
f1629c0c28cc fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents: 723
diff changeset
221 'password_confirmation':password,
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
222 'email':email,
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
223 'name':name,
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
224 'lastname':lastname})
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
225 #register new user for email test
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
226 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
227 {'email':email, })
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
228 print response.session['flash']
549
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
229 assert 'You have successfully registered into rhodecode' in response.session['flash'][0], 'No flash message about user registration'
473
6b934c9607e7 Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents: 463
diff changeset
230 assert 'Your new password was sent' in response.session['flash'][1], 'No flash message about password 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
231
758f64f3fbda extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
232
758f64f3fbda extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents: 567
diff changeset
233