mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-04 21:15:22 +02:00
feat: LDAP Improvements and E2E testing (#2199)
* add option to enable starttls for ldap * add integration test for ldap service * document new, optional environment variable * fix: support anonymous bind * id and mail attributes in LDAP_USER_FILTER should be implied * remove print statement
This commit is contained in:
parent
93eb2af087
commit
7d9be67432
8 changed files with 276 additions and 28 deletions
|
@ -52,11 +52,18 @@ class LdapConnMock:
|
|||
self.app_settings.LDAP_NAME_ATTRIBUTE,
|
||||
self.app_settings.LDAP_MAIL_ATTRIBUTE,
|
||||
]
|
||||
assert filter == self.app_settings.LDAP_USER_FILTER.format(
|
||||
user_filter = self.app_settings.LDAP_USER_FILTER.format(
|
||||
id_attribute=self.app_settings.LDAP_ID_ATTRIBUTE,
|
||||
mail_attribute=self.app_settings.LDAP_MAIL_ATTRIBUTE,
|
||||
input=self.user,
|
||||
)
|
||||
search_filter = "(&(|({id_attribute}={input})({mail_attribute}={input})){filter})".format(
|
||||
id_attribute=self.app_settings.LDAP_ID_ATTRIBUTE,
|
||||
mail_attribute=self.app_settings.LDAP_MAIL_ATTRIBUTE,
|
||||
input=self.user,
|
||||
filter=user_filter,
|
||||
)
|
||||
assert filter == search_filter
|
||||
assert dn == self.app_settings.LDAP_BASE_DN
|
||||
assert scope == ldap.SCOPE_SUBTREE
|
||||
|
||||
|
@ -77,6 +84,9 @@ class LdapConnMock:
|
|||
def unbind_s(self):
|
||||
pass
|
||||
|
||||
def start_tls_s(self):
|
||||
pass
|
||||
|
||||
|
||||
def setup_env(monkeypatch: MonkeyPatch):
|
||||
user = random_string(10)
|
||||
|
@ -204,6 +214,9 @@ def test_ldap_disabled(monkeypatch: MonkeyPatch):
|
|||
def unbind_s(self):
|
||||
pass
|
||||
|
||||
def start_tls_s(self):
|
||||
pass
|
||||
|
||||
def ldap_initialize_mock(url):
|
||||
assert url == ""
|
||||
return LdapConnMock()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue