sources/ldap: divide connector into password, sync and auth, add unittests for password

This commit is contained in:
Jens Langhammer
2020-09-21 21:35:50 +02:00
parent 945d5bfaf6
commit 59e8dca499
12 changed files with 485 additions and 342 deletions

View File

@ -4,8 +4,8 @@ from time import time
from django.core.cache import cache
from passbook.root.celery import CELERY_APP
from passbook.sources.ldap.connector import Connector
from passbook.sources.ldap.models import LDAPSource
from passbook.sources.ldap.sync import LDAPSynchronizer
@CELERY_APP.task()
@ -19,9 +19,9 @@ def sync():
def sync_single(source_pk):
"""Sync a single source"""
source: LDAPSource = LDAPSource.objects.get(pk=source_pk)
connector = Connector(source)
connector.sync_users()
connector.sync_groups()
connector.sync_membership()
syncer = LDAPSynchronizer(source)
syncer.sync_users()
syncer.sync_groups()
syncer.sync_membership()
cache_key = source.state_cache_prefix("last_sync")
cache.set(cache_key, time(), timeout=60 * 60)