Mercurial > kallithea
annotate rhodecode/tests/functional/test_admin_ldap_settings.py @ 1974:edd3f202da4e beta
bumped mercurial to 2.1
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 01 Feb 2012 22:50:10 +0200 |
parents | cf51bbfb120e |
children | 1361ddff4486 |
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 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 class TestLdapSettingsController(TestController): |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 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
|
16 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
|
17 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
|
18 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
|
19 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
|
20 |
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 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
|
22 self.log_user() |
1481
605707b50d7c
test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents:
1425
diff
changeset
|
23 if skip_ldap_test: |
605707b50d7c
test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents:
1425
diff
changeset
|
24 raise SkipTest('skipping due to missing ldap lib') |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1713
diff
changeset
|
25 |
1425
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
26 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
|
27 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
|
28 |
3dedf3991d40
fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents:
1292
diff
changeset
|
29 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
|
30 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
|
31 '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
|
32 '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
|
33 '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
|
34 '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
|
35 '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
|
36 '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
|
37 '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
|
38 '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
|
39 '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
|
40 '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
|
41 '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
|
42 '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
|
43 |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1481
diff
changeset
|
44 new_settings = RhodeCodeSetting.get_ldap_settings() |
1713
54687aa00724
Tests updates, Session refactoring
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
45 print new_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 |