moved slapd_server in the ldap unit tests module

This commit is contained in:
Éloi Rivard 2023-06-03 19:18:37 +02:00
parent e3aede6645
commit 422af73b89
2 changed files with 27 additions and 21 deletions

View file

@ -0,0 +1,24 @@
import pytest
from tests.backends.ldap import CustomSlapdObject
@pytest.fixture(scope="session")
def slapd_server():
slapd = CustomSlapdObject()
try:
slapd.start()
slapd.init_tree()
for ldif in (
"demo/ldif/memberof-config.ldif",
"demo/ldif/ppolicy-config.ldif",
"demo/ldif/ppolicy.ldif",
"canaille/backends/ldap/schemas/oauth2-openldap.ldif",
"demo/ldif/bootstrap-users-tree.ldif",
"demo/ldif/bootstrap-oidc-tree.ldif",
):
with open(ldif) as fd:
slapd.ldapadd(fd.read())
yield slapd
finally:
slapd.stop()

View file

@ -3,30 +3,12 @@ from canaille import create_app
from canaille.app import models
from canaille.backends.ldap.backend import LDAPBackend
from flask_webtest import TestApp
from tests.backends.ldap import CustomSlapdObject
from werkzeug.security import gen_salt
@pytest.fixture(scope="session")
def slapd_server():
slapd = CustomSlapdObject()
try:
slapd.start()
slapd.init_tree()
for ldif in (
"demo/ldif/memberof-config.ldif",
"demo/ldif/ppolicy-config.ldif",
"demo/ldif/ppolicy.ldif",
"canaille/backends/ldap/schemas/oauth2-openldap.ldif",
"demo/ldif/bootstrap-users-tree.ldif",
"demo/ldif/bootstrap-oidc-tree.ldif",
):
with open(ldif) as fd:
slapd.ldapadd(fd.read())
yield slapd
finally:
slapd.stop()
pytest_plugins = [
"tests.backends.ldap.fixtures",
]
@pytest.fixture