annotate rhodecode/tests/functional/test_admin_ldap_settings.py @ 1633:2c0d35e336b5 beta

refactoring of models names for repoGroup permissions
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 02 Nov 2011 03:08:33 +0200
parents 605707b50d7c
children 54687aa00724
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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')
605707b50d7c test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents: 1425
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()
1425
3dedf3991d40 fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents: 1292
diff changeset
45 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
46 '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
47
3dedf3991d40 fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents: 1292
diff changeset
48 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
49 '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
50
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 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
52 self.log_user()
1481
605707b50d7c test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents: 1425
diff changeset
53 if skip_ldap_test:
605707b50d7c test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents: 1425
diff changeset
54 raise SkipTest('skipping due to missing ldap lib')
605707b50d7c test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents: 1425
diff changeset
55
1425
3dedf3991d40 fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents: 1292
diff changeset
56 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
57 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
58
3dedf3991d40 fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents: 1292
diff changeset
59 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
60 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
61 '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
62 '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
63 '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
64 '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
65 '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
66 '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
67 'ldap_filter':'',
3dedf3991d40 fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents: 1292
diff changeset
68 '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
69 '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
70 '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
71 '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
72 'ldap_attr_email':'' })
1481
605707b50d7c test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents: 1425
diff changeset
73
1425
3dedf3991d40 fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents: 1292
diff changeset
74 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
75 """ 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
76 response.body)
1481
605707b50d7c test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents: 1425
diff changeset
77
605707b50d7c test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents: 1425
diff changeset
78
605707b50d7c test fixes for vcs update
Marcin Kuzminski <marcin@python-works.com>
parents: 1425
diff changeset
79
1425
3dedf3991d40 fixes #173, many thanks for slestak for contributing into this one.
Marcin Kuzminski <marcin@python-works.com>
parents: 1292
diff changeset
80 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
81 """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
82
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 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
84 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
85
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 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
87 pass