Import Upstream version 4.12.4

This commit is contained in:
geos_one
2025-08-12 22:28:56 +02:00
parent 03a8170b15
commit 9181ee2487
1629 changed files with 874094 additions and 554378 deletions

View File

@@ -2,55 +2,10 @@
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
from contextlib import contextmanager
import six
from ipalib import api
from ipatests.util import MockLDAP
trust_container_dn = "cn=ad,cn=trusts,{basedn}".format(
basedn=api.env.basedn)
trust_container_add = dict(
objectClass=[b"nsContainer", b"top"]
)
smb_cont_dn = "{cifsdomains},{basedn}".format(
cifsdomains=api.env.container_cifsdomains,
basedn=api.env.basedn)
smb_cont_add = dict(
objectClass=[b"nsContainer", b"top"]
)
def create_mock_trust_containers():
with MockLDAP() as ldap:
ldap.add_entry(trust_container_dn, trust_container_add)
ldap.add_entry(smb_cont_dn, smb_cont_add)
def remove_mock_trust_containers():
with MockLDAP() as ldap:
ldap.del_entry(trust_container_dn)
ldap.del_entry(smb_cont_dn)
@contextmanager
def mocked_trust_containers():
"""Mocked trust containers
Provides containers for the RPC tests:
cn=ad,cn=trusts,BASEDN
cn=ad,cn=etc,BASEDN
Upon exiting, it tries to remove the container entries.
If the user of the context manager failed to remove
all child entries, exiting the context manager will fail.
"""
create_mock_trust_containers()
try:
yield
finally:
remove_mock_trust_containers()
def get_range_dn(name):
format_str = "cn={name},cn=ranges,cn=etc,{basedn}"