test_admin_ldap_settings.py
98 lines
| 3.7 KiB
| text/x-python
|
PythonLexer
r769 | from rhodecode.tests import * | |||
r1633 | from rhodecode.model.db import RhodeCodeSetting | |||
r1425 | ||||
r769 | class TestLdapSettingsController(TestController): | |||
def test_index(self): | ||||
r1292 | self.log_user() | |||
response = self.app.get(url(controller='admin/ldap_settings', | ||||
action='index')) | ||||
r3646 | response.mustcontain('LDAP administration') | |||
r1292 | ||||
def test_ldap_save_settings(self): | ||||
r1425 | self.log_user() | |||
r3674 | if ldap_lib_installed: | |||
r1481 | raise SkipTest('skipping due to missing ldap lib') | |||
r1818 | ||||
r1425 | test_url = url(controller='admin/ldap_settings', | |||
action='ldap_settings') | ||||
response = self.app.post(url=test_url, | ||||
r3674 | params={'ldap_host': u'dc.example.com', | |||
'ldap_port': '999', | ||||
'ldap_tls_kind': 'PLAIN', | ||||
'ldap_tls_reqcert': 'NEVER', | ||||
'ldap_dn_user': 'test_user', | ||||
'ldap_dn_pass': 'test_pass', | ||||
'ldap_base_dn': 'test_base_dn', | ||||
'ldap_filter': 'test_filter', | ||||
'ldap_search_scope': 'BASE', | ||||
'ldap_attr_login': 'test_attr_login', | ||||
'ldap_attr_firstname': 'ima', | ||||
'ldap_attr_lastname': 'tester', | ||||
'ldap_attr_email': 'test@example.com' }) | ||||
r1425 | ||||
r1633 | new_settings = RhodeCodeSetting.get_ldap_settings() | |||
r1425 | self.assertEqual(new_settings['ldap_host'], u'dc.example.com', | |||
'fail db write compare') | ||||
self.checkSessionFlash(response, | ||||
Mads Kiilerich
|
r3565 | 'LDAP settings updated successfully') | ||
r1292 | ||||
r3674 | def test_ldap_error_form_wrong_port_number(self): | |||
r1425 | self.log_user() | |||
r3674 | if ldap_lib_installed: | |||
r1481 | raise SkipTest('skipping due to missing ldap lib') | |||
r1818 | ||||
r1425 | test_url = url(controller='admin/ldap_settings', | |||
action='ldap_settings') | ||||
response = self.app.post(url=test_url, | ||||
r3674 | params={'ldap_host': '', | |||
'ldap_port': 'i-should-be-number', # bad port num | ||||
'ldap_tls_kind': 'PLAIN', | ||||
'ldap_tls_reqcert': 'NEVER', | ||||
'ldap_dn_user': '', | ||||
'ldap_dn_pass': '', | ||||
'ldap_base_dn': '', | ||||
'ldap_filter': '', | ||||
'ldap_search_scope': 'BASE', | ||||
'ldap_attr_login': '', | ||||
'ldap_attr_firstname': '', | ||||
'ldap_attr_lastname': '', | ||||
'ldap_attr_email': ''}) | ||||
response.mustcontain("""<span class="error-message">""" | ||||
"""Please enter a number</span><br />""") | ||||
def test_ldap_error_form(self): | ||||
self.log_user() | ||||
if ldap_lib_installed: | ||||
raise SkipTest('skipping due to missing ldap lib') | ||||
test_url = url(controller='admin/ldap_settings', | ||||
action='ldap_settings') | ||||
response = self.app.post(url=test_url, | ||||
params={'ldap_host': 'Host', | ||||
'ldap_port': '123', | ||||
'ldap_tls_kind': 'PLAIN', | ||||
'ldap_tls_reqcert': 'NEVER', | ||||
'ldap_dn_user': '', | ||||
'ldap_dn_pass': '', | ||||
'ldap_base_dn': '', | ||||
'ldap_filter': '', | ||||
'ldap_search_scope': 'BASE', | ||||
'ldap_attr_login': '', # <----- missing required input | ||||
'ldap_attr_firstname': '', | ||||
'ldap_attr_lastname': '', | ||||
'ldap_attr_email': ''}) | ||||
r1818 | ||||
r3646 | response.mustcontain("""<span class="error-message">The LDAP Login""" | |||
""" attribute of the CN must be specified""") | ||||
r1818 | ||||
r1292 | def test_ldap_login(self): | |||
pass | ||||
def test_ldap_login_incorrect(self): | ||||
pass | ||||