forked from Github-Mirrors/canaille
Moved CustomSlapdObject class into the ldap test module
This commit is contained in:
parent
453a7d5c52
commit
fa7c68ff5b
3 changed files with 45 additions and 43 deletions
|
@ -0,0 +1,42 @@
|
|||
import os
|
||||
|
||||
import slapd
|
||||
|
||||
|
||||
class CustomSlapdObject(slapd.Slapd):
|
||||
def __init__(self):
|
||||
schemas = [
|
||||
schema
|
||||
for schema in [
|
||||
"core.ldif",
|
||||
"cosine.ldif",
|
||||
"nis.ldif",
|
||||
"inetorgperson.ldif",
|
||||
"ppolicy.ldif",
|
||||
]
|
||||
if os.path.exists(os.path.join(self.SCHEMADIR, schema))
|
||||
]
|
||||
|
||||
super().__init__(
|
||||
suffix="dc=mydomain,dc=tld",
|
||||
schemas=schemas,
|
||||
)
|
||||
|
||||
def init_tree(self):
|
||||
suffix_dc = self.suffix.split(",")[0][3:]
|
||||
self.ldapadd(
|
||||
"\n".join(
|
||||
[
|
||||
"dn: " + self.suffix,
|
||||
"objectClass: dcObject",
|
||||
"objectClass: organization",
|
||||
"dc: " + suffix_dc,
|
||||
"o: " + suffix_dc,
|
||||
"",
|
||||
"dn: " + self.root_dn,
|
||||
"objectClass: applicationProcess",
|
||||
"cn: " + self.root_cn,
|
||||
]
|
||||
)
|
||||
+ "\n"
|
||||
)
|
|
@ -6,7 +6,8 @@ from canaille.backends.ldap.backend import LDAPBackend
|
|||
from canaille.backends.ldap.ldapobject import LDAPObject
|
||||
from canaille.commands import cli
|
||||
from flask_webtest import TestApp
|
||||
from tests.conftest import CustomSlapdObject
|
||||
|
||||
from . import CustomSlapdObject
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
@ -1,53 +1,12 @@
|
|||
import os
|
||||
|
||||
import pytest
|
||||
import slapd
|
||||
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
|
||||
|
||||
|
||||
class CustomSlapdObject(slapd.Slapd):
|
||||
def __init__(self):
|
||||
schemas = [
|
||||
schema
|
||||
for schema in [
|
||||
"core.ldif",
|
||||
"cosine.ldif",
|
||||
"nis.ldif",
|
||||
"inetorgperson.ldif",
|
||||
"ppolicy.ldif",
|
||||
]
|
||||
if os.path.exists(os.path.join(self.SCHEMADIR, schema))
|
||||
]
|
||||
|
||||
super().__init__(
|
||||
suffix="dc=mydomain,dc=tld",
|
||||
schemas=schemas,
|
||||
)
|
||||
|
||||
def init_tree(self):
|
||||
suffix_dc = self.suffix.split(",")[0][3:]
|
||||
self.ldapadd(
|
||||
"\n".join(
|
||||
[
|
||||
"dn: " + self.suffix,
|
||||
"objectClass: dcObject",
|
||||
"objectClass: organization",
|
||||
"dc: " + suffix_dc,
|
||||
"o: " + suffix_dc,
|
||||
"",
|
||||
"dn: " + self.root_dn,
|
||||
"objectClass: applicationProcess",
|
||||
"cn: " + self.root_cn,
|
||||
]
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def slapd_server():
|
||||
slapd = CustomSlapdObject()
|
||||
|
|
Loading…
Reference in a new issue