Mercurial > kallithea
annotate rhodecode/tests/functional/test_admin_ldap_settings.py @ 3089:4cc9bb83ecb4 beta
Fixed some issues with edit form
- unified code (but still a lot of duplicated code left over)
- fixed forms
- fixed validators
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 13 Dec 2012 03:34:19 +0100 |
parents | 1361ddff4486 |
children | a8f2d78d14ea |
rev | line source |
---|---|
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 from rhodecode.tests import * |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1481
diff
changeset
|
2 from rhodecode.model.db import RhodeCodeSetting |
1481
605707b50d7c
test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents:
1425
diff
changeset
|
3 from nose.plugins.skip import SkipTest |
1425
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
4 |
1481
605707b50d7c
test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents:
1425
diff
changeset
|
5 skip_ldap_test = False |
1425
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
6 try: |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
7 import ldap |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
8 except ImportError: |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
9 # means that python-ldap is not installed |
1481
605707b50d7c
test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents:
1425
diff
changeset
|
10 skip_ldap_test = True |
1425
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
11 pass |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 |
3024
1361ddff4486
Cleanup leftover print statements
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
13 |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 class TestLdapSettingsController(TestController): |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 def test_index(self): |
1292
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
769
diff
changeset
|
17 self.log_user() |
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
769
diff
changeset
|
18 response = self.app.get(url(controller='admin/ldap_settings', |
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
769
diff
changeset
|
19 action='index')) |
1425
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
20 self.assertTrue('LDAP administration' in response.body) |
1292
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
769
diff
changeset
|
21 |
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
769
diff
changeset
|
22 def test_ldap_save_settings(self): |
1425
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
23 self.log_user() |
1481
605707b50d7c
test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents:
1425
diff
changeset
|
24 if skip_ldap_test: |
605707b50d7c
test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents:
1425
diff
changeset
|
25 raise SkipTest('skipping due to missing ldap lib') |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1713
diff
changeset
|
26 |
1425
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
27 test_url = url(controller='admin/ldap_settings', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
28 action='ldap_settings') |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
29 |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
30 response = self.app.post(url=test_url, |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
31 params={'ldap_host' : u'dc.example.com', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
32 'ldap_port' : '999', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
33 'ldap_tls_kind' : 'PLAIN', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
34 'ldap_tls_reqcert' : 'NEVER', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
35 'ldap_dn_user':'test_user', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
36 'ldap_dn_pass':'test_pass', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
37 'ldap_base_dn':'test_base_dn', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
38 'ldap_filter':'test_filter', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
39 'ldap_search_scope':'BASE', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
40 'ldap_attr_login':'test_attr_login', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
41 'ldap_attr_firstname':'ima', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
42 'ldap_attr_lastname':'tester', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
43 'ldap_attr_email':'test@example.com' }) |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
44 |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1481
diff
changeset
|
45 new_settings = RhodeCodeSetting.get_ldap_settings() |
1425
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
46 self.assertEqual(new_settings['ldap_host'], u'dc.example.com', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
47 'fail db write compare') |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
48 |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
49 self.checkSessionFlash(response, |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
50 'Ldap settings updated successfully') |
1292
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
769
diff
changeset
|
51 |
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
769
diff
changeset
|
52 def test_ldap_error_form(self): |
1425
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
53 self.log_user() |
1481
605707b50d7c
test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents:
1425
diff
changeset
|
54 if skip_ldap_test: |
605707b50d7c
test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents:
1425
diff
changeset
|
55 raise SkipTest('skipping due to missing ldap lib') |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1713
diff
changeset
|
56 |
1425
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
57 test_url = url(controller='admin/ldap_settings', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
58 action='ldap_settings') |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
59 |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
60 response = self.app.post(url=test_url, |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
61 params={'ldap_host' : '', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
62 'ldap_port' : 'i-should-be-number', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
63 'ldap_tls_kind' : 'PLAIN', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
64 'ldap_tls_reqcert' : 'NEVER', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
65 'ldap_dn_user':'', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
66 'ldap_dn_pass':'', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
67 'ldap_base_dn':'', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
68 'ldap_filter':'', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
69 'ldap_search_scope':'BASE', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
70 'ldap_attr_login':'', # <----- missing required input |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
71 'ldap_attr_firstname':'', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
72 'ldap_attr_lastname':'', |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
73 'ldap_attr_email':'' }) |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1713
diff
changeset
|
74 |
1425
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
75 self.assertTrue("""<span class="error-message">The LDAP Login""" |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
76 """ attribute of the CN must be specified""" in |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
77 response.body) |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1713
diff
changeset
|
78 |
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1713
diff
changeset
|
79 |
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1713
diff
changeset
|
80 |
1425
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
81 self.assertTrue("""<span class="error-message">Please """ |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
82 """enter a number</span>""" in response.body) |
1292
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
769
diff
changeset
|
83 |
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
769
diff
changeset
|
84 def test_ldap_login(self): |
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
769
diff
changeset
|
85 pass |
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
769
diff
changeset
|
86 |
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
769
diff
changeset
|
87 def test_ldap_login_incorrect(self): |
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
769
diff
changeset
|
88 pass |