Show More
@@ -46,8 +46,9 b' log = logging.getLogger(__name__)' | |||||
46 | try: |
|
46 | try: | |
47 | import ldap |
|
47 | import ldap | |
48 | except ImportError: |
|
48 | except ImportError: | |
49 | # means that python-ldap is not installed |
|
49 | # means that python-ldap is not installed, we use Missing object to mark | |
50 |
|
|
50 | # ldap lib is Missing | |
|
51 | ldap = Missing | |||
51 |
|
52 | |||
52 |
|
53 | |||
53 | def plugin_factory(plugin_id, *args, **kwds): |
|
54 | def plugin_factory(plugin_id, *args, **kwds): | |
@@ -182,7 +183,7 b' class AuthLdap(object):' | |||||
182 | tls_kind='PLAIN', tls_reqcert='DEMAND', ldap_version=3, |
|
183 | tls_kind='PLAIN', tls_reqcert='DEMAND', ldap_version=3, | |
183 | search_scope='SUBTREE', attr_login='uid', |
|
184 | search_scope='SUBTREE', attr_login='uid', | |
184 | ldap_filter='(&(objectClass=user)(!(objectClass=computer)))'): |
|
185 | ldap_filter='(&(objectClass=user)(!(objectClass=computer)))'): | |
185 |
if |
|
186 | if ldap == Missing: | |
186 | raise LdapImportError("Missing or incompatible ldap library") |
|
187 | raise LdapImportError("Missing or incompatible ldap library") | |
187 |
|
188 | |||
188 | self.ldap_version = ldap_version |
|
189 | self.ldap_version = ldap_version |
@@ -155,3 +155,29 b' class TestRhodeCodeAuthPlugin(object):' | |||||
155 | self.password_generator_mock = password_generator_patch.start() |
|
155 | self.password_generator_mock = password_generator_patch.start() | |
156 | self.password_generator_mock.return_value = 'new-password' |
|
156 | self.password_generator_mock.return_value = 'new-password' | |
157 | self.finalizers.append(password_generator_patch.stop) |
|
157 | self.finalizers.append(password_generator_patch.stop) | |
|
158 | ||||
|
159 | ||||
|
160 | def test_missing_ldap(): | |||
|
161 | from rhodecode.model.validators import Missing | |||
|
162 | ||||
|
163 | try: | |||
|
164 | import ldap_not_existing | |||
|
165 | except ImportError: | |||
|
166 | # means that python-ldap is not installed | |||
|
167 | ldap_not_existing = Missing | |||
|
168 | ||||
|
169 | # missing is singleton | |||
|
170 | assert ldap_not_existing == Missing | |||
|
171 | ||||
|
172 | ||||
|
173 | def test_import_ldap(): | |||
|
174 | from rhodecode.model.validators import Missing | |||
|
175 | ||||
|
176 | try: | |||
|
177 | import ldap | |||
|
178 | except ImportError: | |||
|
179 | # means that python-ldap is not installed | |||
|
180 | ldap = Missing | |||
|
181 | ||||
|
182 | # missing is singleton | |||
|
183 | assert False is (ldap == Missing) |
General Comments 0
You need to be logged in to leave comments.
Login now