Added tests

This commit is contained in:
2025-06-27 16:10:49 +02:00
parent be7f871ce7
commit 4be81275f8
4 changed files with 67 additions and 5 deletions

View File

@@ -26,6 +26,10 @@ def normalize(def_str: bytes) -> bytes:
"""
return re.sub(rb'\s+', b' ', def_str.strip())
def extract_oid(ldif: str) -> str:
match = re.search(r'\(\s*([\d\.]+)', ldif)
return match.group(1) if match else ''
def main():
parser = argparse.ArgumentParser(
description='Create or update OpenLDAP schema entries under cn=config'
@@ -162,11 +166,6 @@ def main():
norm_existing = [normalize(v) for v in existing]
norm_encoded = normalize(encoded)
# Extract OID from definition (assumes it is the first word in parentheses)
def extract_oid(ldif: str) -> str:
return ldif.split()[0].strip('(')
oid = extract_oid(atdef)
# Normalize existing