Show More
@@ -6,4 +6,5 b' List of contributors to RhodeCode projec' | |||||
6 | cejones |
|
6 | cejones | |
7 | Lorenzo M. Catucci <lorenzo@sancho.ccd.uniroma2.it> |
|
7 | Lorenzo M. Catucci <lorenzo@sancho.ccd.uniroma2.it> | |
8 | Dmitri Kuznetsov |
|
8 | Dmitri Kuznetsov | |
9 | Jared Bunting <jared.bunting@peachjean.com> No newline at end of file |
|
9 | Jared Bunting <jared.bunting@peachjean.com> | |
|
10 | Steve Romanow <slestak989@gmail.com> No newline at end of file |
@@ -41,7 +41,7 b' if __platform__ in PLATFORM_WIN:' | |||||
41 | if __platform__ in PLATFORM_OTHERS: |
|
41 | if __platform__ in PLATFORM_OTHERS: | |
42 | import bcrypt |
|
42 | import bcrypt | |
43 |
|
43 | |||
44 | from rhodecode.lib import str2bool |
|
44 | from rhodecode.lib import str2bool, safe_unicode | |
45 | from rhodecode.lib.exceptions import LdapPasswordError, LdapUsernameError |
|
45 | from rhodecode.lib.exceptions import LdapPasswordError, LdapUsernameError | |
46 | from rhodecode.lib.utils import get_repo_slug |
|
46 | from rhodecode.lib.utils import get_repo_slug | |
47 | from rhodecode.lib.auth_ldap import AuthLdap |
|
47 | from rhodecode.lib.auth_ldap import AuthLdap | |
@@ -207,8 +207,8 b' def authenticate(username, password):' | |||||
207 | .get(k), [''])[0] |
|
207 | .get(k), [''])[0] | |
208 |
|
208 | |||
209 | user_attrs = { |
|
209 | user_attrs = { | |
210 |
|
|
210 | 'name': safe_unicode(get_ldap_attr('ldap_attr_firstname')), | |
211 |
|
|
211 | 'lastname': safe_unicode(get_ldap_attr('ldap_attr_lastname')), | |
212 |
|
|
212 | 'email': get_ldap_attr('ldap_attr_email'), | |
213 |
|
|
213 | } | |
214 |
|
214 |
@@ -1,4 +1,11 b'' | |||||
1 | from rhodecode.tests import * |
|
1 | from rhodecode.tests import * | |
|
2 | from rhodecode.model.db import RhodeCodeSettings | |||
|
3 | ||||
|
4 | try: | |||
|
5 | import ldap | |||
|
6 | except ImportError: | |||
|
7 | # means that python-ldap is not installed | |||
|
8 | pass | |||
2 |
|
9 | |||
3 | class TestLdapSettingsController(TestController): |
|
10 | class TestLdapSettingsController(TestController): | |
4 |
|
11 | |||
@@ -6,13 +13,60 b' class TestLdapSettingsController(TestCon' | |||||
6 | self.log_user() |
|
13 | self.log_user() | |
7 | response = self.app.get(url(controller='admin/ldap_settings', |
|
14 | response = self.app.get(url(controller='admin/ldap_settings', | |
8 | action='index')) |
|
15 | action='index')) | |
9 | # Test response... |
|
16 | self.assertTrue('LDAP administration' in response.body) | |
10 |
|
17 | |||
11 | def test_ldap_save_settings(self): |
|
18 | def test_ldap_save_settings(self): | |
12 | pass |
|
19 | self.log_user() | |
|
20 | test_url = url(controller='admin/ldap_settings', | |||
|
21 | action='ldap_settings') | |||
|
22 | ||||
|
23 | response = self.app.post(url=test_url, | |||
|
24 | params={'ldap_host' : u'dc.example.com', | |||
|
25 | 'ldap_port' : '999', | |||
|
26 | 'ldap_tls_kind' : 'PLAIN', | |||
|
27 | 'ldap_tls_reqcert' : 'NEVER', | |||
|
28 | 'ldap_dn_user':'test_user', | |||
|
29 | 'ldap_dn_pass':'test_pass', | |||
|
30 | 'ldap_base_dn':'test_base_dn', | |||
|
31 | 'ldap_filter':'test_filter', | |||
|
32 | 'ldap_search_scope':'BASE', | |||
|
33 | 'ldap_attr_login':'test_attr_login', | |||
|
34 | 'ldap_attr_firstname':'ima', | |||
|
35 | 'ldap_attr_lastname':'tester', | |||
|
36 | 'ldap_attr_email':'test@example.com' }) | |||
|
37 | ||||
|
38 | new_settings = RhodeCodeSettings.get_ldap_settings() | |||
|
39 | self.assertEqual(new_settings['ldap_host'], u'dc.example.com', | |||
|
40 | 'fail db write compare') | |||
|
41 | ||||
|
42 | self.checkSessionFlash(response, | |||
|
43 | 'Ldap settings updated successfully') | |||
13 |
|
44 | |||
14 | def test_ldap_error_form(self): |
|
45 | def test_ldap_error_form(self): | |
15 | pass |
|
46 | self.log_user() | |
|
47 | test_url = url(controller='admin/ldap_settings', | |||
|
48 | action='ldap_settings') | |||
|
49 | ||||
|
50 | response = self.app.post(url=test_url, | |||
|
51 | params={'ldap_host' : '', | |||
|
52 | 'ldap_port' : 'i-should-be-number', | |||
|
53 | 'ldap_tls_kind' : 'PLAIN', | |||
|
54 | 'ldap_tls_reqcert' : 'NEVER', | |||
|
55 | 'ldap_dn_user':'', | |||
|
56 | 'ldap_dn_pass':'', | |||
|
57 | 'ldap_base_dn':'', | |||
|
58 | 'ldap_filter':'', | |||
|
59 | 'ldap_search_scope':'BASE', | |||
|
60 | 'ldap_attr_login':'', # <----- missing required input | |||
|
61 | 'ldap_attr_firstname':'', | |||
|
62 | 'ldap_attr_lastname':'', | |||
|
63 | 'ldap_attr_email':'' }) | |||
|
64 | ||||
|
65 | self.assertTrue("""<span class="error-message">The LDAP Login""" | |||
|
66 | """ attribute of the CN must be specified""" in | |||
|
67 | response.body) | |||
|
68 | self.assertTrue("""<span class="error-message">Please """ | |||
|
69 | """enter a number</span>""" in response.body) | |||
16 |
|
70 | |||
17 | def test_ldap_login(self): |
|
71 | def test_ldap_login(self): | |
18 | pass |
|
72 | pass |
General Comments 0
You need to be logged in to leave comments.
Login now