univention.testing.ucsschool package#
Submodules#
univention.testing.ucsschool.acl module#
- univention.testing.ucsschool.acl.run_commands(cmdlist, argdict)[source]#
Start all commands in cmdlist and replace formatstrings with arguments in argdict.
>>> run_commands([['/bin/echo', '%(msg)s'], ['/bin/echo', 'World']], {'msg': 'Hello'}) [('Hello
‘, ‘’), (‘World ‘, ‘’)]
- param list cmdlist:
list of commands to start
- param dict argdict:
formatstrings for commands in cmdlist
- return:
tuple: (output message, error message)
- rtype:
tuple[str, str]
- class univention.testing.ucsschool.acl.CreateContextManager(container_dn, **kwargs)[source]#
Bases:
objectCreate random object in a specific container:
- Parameters:
container_dn (str) – container dn to create the object in
kwargs – arguments to pass to udm.create_object() additionally to cls.create_kwargs
- udm_module = ''#
- create_kwargs = {}#
- class univention.testing.ucsschool.acl.CreateGroupInContainer(container_dn, **kwargs)[source]#
Bases:
CreateContextManagerCreate random object in a specific container:
- Parameters:
container_dn (str) – container dn to create the object in
kwargs – arguments to pass to udm.create_object() additionally to cls.create_kwargs
- udm_module = 'groups/group'#
- create_kwargs = {'name': 'rqxgt2qnck'}#
- class univention.testing.ucsschool.acl.CreateDCSlaveInContainer(container_dn, **kwargs)[source]#
Bases:
CreateContextManagerCreate random object in a specific container:
- Parameters:
container_dn (str) – container dn to create the object in
kwargs – arguments to pass to udm.create_object() additionally to cls.create_kwargs
- udm_module = 'computers/domaincontroller_slave'#
- create_kwargs = {'name': 'cyfm4g62er'}#
- class univention.testing.ucsschool.acl.Acl(school, auth_dn, access_allowance)[source]#
Bases:
objectAcl class
contains the basic functuality to test acls for the common container in ucsschool may change with time.
- Parameters:
- assert_room(room_dn, access)[source]#
Lehrer und ouadmins duerfen Raum-Gruppen anlegen und bearbeiten
- assert_teacher_group(access)[source]#
Lehrer, Mitarbeiter und Mitglieder der lokalen Administratoren duerfen Arbeitsgruppen anlegen und aendern
Assert that for the given share object the given <access>, “read” or “write”, is (not) given. Please note that the attribute list may not be complete.
Lehrer und Mitglieder der lokalen Administratoren duerfen Shares anlegen, Klassenshares aber nicht aendern
- assert_temps(access)[source]#
Mitglieder der lokalen Administratoren muessen einige temporaere Objekte schreiben duerfen da keine regulaeren Ausdruecke auf Gruppenmitgliedschaften moeglich sind wird dies allen Lehrern erlaubt
- assert_ou(access)[source]#
Replica Directory Nodes duerfen Eintraege Ihrer ou lesen und schreiben (Passwortaenderungen etc.) Lehrer und Managed Nodes duerfen sie lesen, ou-eigene bekommen Standard-ACLs, ou-fremde Server/user duerfen nichts
- assert_global_containers(access)[source]#
Schüler, Lehrer, Mitarbeiter, Admins duerfen globale Container univention, policies, groups und dns lesen (werden bei Schuelern/Rechnern angezeigt)
- assert_computers(computer_dn, access)[source]#
Mitglieder der lokalen Administratoren duerfen MAC-Adressen im Rechner- und DHCP-Objekt aendern
- assert_user(user_dn, access)[source]#
Mitglieder der lokalen Administratoren duerfen Passwoerter unterhalb von cn=users aendern
univention.testing.ucsschool.computer module#
- class univention.testing.ucsschool.computer.SupportedComputer(value)[source]#
Bases:
Enum- windows = 1#
- macos = 2#
- ipmanagedclient = 3#
- linux = 4#
- ubuntu = 5#
- class univention.testing.ucsschool.computer.IpIter[source]#
Bases:
object- netmasks = ['/255.255.255.0', '/255.255.248.0', '/255.255.0.0']#
- next()#
- univention.testing.ucsschool.computer.random_ip(ip_iter: ~univention.testing.ucsschool.computer.IpIter = <univention.testing.ucsschool.computer.IpIter object>) str[source]#
- univention.testing.ucsschool.computer.random_network(ip_iter: ~univention.testing.ucsschool.computer.IpIter = <univention.testing.ucsschool.computer.IpIter object>) str[source]#
- class univention.testing.ucsschool.computer.Computer(school: str, ctype: str)[source]#
Bases:
object
- univention.testing.ucsschool.computer.create_test_computers(lo: LoType, school: str | None = None, nr_windows: int = 1, nr_macos: int = 0, nr_ip_managed_clients: int = 0, nr_linux: int = 0, nr_ubuntu: int = 0) list[Computer][source]#
Utility function to create test computers (~ python import)
univention.testing.ucsschool.computerroom module#
- class univention.testing.ucsschool.computerroom.Room(school, name=None, dn=None, description=None, host_members=None, teacher_computers=None)[source]#
Bases:
object- check_internetRules(client)[source]#
Check if the fetched internetrules match the already defined ones in define internet module. :param client: umc connection :type client: Client(uce.get(‘hostname’))
- univention.testing.ucsschool.computerroom.run_commands(cmdlist, argdict)[source]#
Start all commands in cmdlist and replace formatstrings with arguments in argdict. run_commands([[‘/bin/echo’, ‘%(msg)s’], [‘/bin/echo’, ‘World’]], {‘msg’: ‘Hello’})
- univention.testing.ucsschool.computerroom.add_printer(name, school, hostname, domainname, ldap_base)[source]#
- class univention.testing.ucsschool.computerroom.UmcComputer(school, typ, name=None, ip_address=None, subnet_mask=None, mac_address=None, inventory_number=None)[source]#
Bases:
object
- univention.testing.ucsschool.computerroom.check_change_permissions(filename: str, user_name: str, allowed: bool, samba_workstation: str = '') None[source]#
test if user can change the permissions a given file in a share folder.
univention.testing.ucsschool.conftest module#
- class univention.testing.ucsschool.conftest.GroupType(value)[source]#
Bases:
UCSSchoolType- SchoolClass = 'SchoolClass'#
- WorkGroup = 'WorkGroup'#
Bases:
UCSSchoolType
- class univention.testing.ucsschool.conftest.UserType(value)[source]#
Bases:
UCSSchoolType- SchoolAdmin = 'SchoolAdmin'#
- Staff = 'Staff'#
- Student = 'Student'#
- Teacher = 'Teacher'#
- TeachersAndStaff = 'TeachersAndStaff'#
- univention.testing.ucsschool.conftest.user_ldap_attributes(random_username, model_ucsschool_roles, model_udm_module, model_ldap_object_classes, user_groups)[source]#
- univention.testing.ucsschool.conftest.workgroup_ldap_attributes(mail_domain, random_username, ucr_ldap_base, model_ucsschool_roles, model_udm_module, model_ldap_container, model_ldap_object_classes)[source]#
- univention.testing.ucsschool.conftest.workgroup_school_attributes(workgroup_ldap_attributes)[source]#
univention.testing.ucsschool.csv_test_helper module#
univention.testing.ucsschool.distribution module#
Class Distribution
- class univention.testing.ucsschool.distribution.Distribution(school, connection=None, sender=None, flavor=None, ucr=None, description=None, name=None, distributeType='manual', distributeTime=None, distributeDate=None, collectType='manual', collectTime=None, collectDate=None, files=[], recipients=[])[source]#
Bases:
objectContains the needed functionality for Materials distribution. By default the distribution is manual.
- Parameters:
school (str) – name of the ou
connection (UMC connection object)
ucr (UCR object)
name (str) – name of distribution project to be added later
description (str) – description of distribution project to be added later
sender (str) – name of the creater user (teacher or admin)
flavor (str ('teacher' or 'admin')) – flavor of the acting user
distributeTime (str ('%I:%M')) – time for automatic distribution
distributionDate (str ('%Y-%m-%d)) – date for automatic distribution
collectionTime (str ('%I:%M')) – time for automatic collection
collectionDate (str ('%Y-%m-%d)) – date for automatic collection
distributeType – type of the distribution
collectionTye – type of the collection
files (list of str) – names of material files for the distribution project
recipients (list of group objects) – groups which are included in the distribution project
- property files#
- property files_encoded#
- query(filt='private', pattern='')[source]#
Calles ‘distribution/query’ :param pattern: the pattern to use in the search :type pattern: str
- idir(path)[source]#
Dir a specific path.
- Parameters:
path (str) – wanted path
- Returns:
list of file names
- genData(file_name, content_type, boundary, flavor, override_file_name=None)[source]#
Generates data in the form to be sent via http POST request.
- uploadFile(file_name, content_type=None, override_file_name=None)[source]#
Uploads a file via http POST request.
- put(description=None, distributeType=None, distributeTime=None, distributeDate=None, collectType=None, collectTime=None, collectDate=None, files=[], recipients=[])[source]#
Modifies the already existing project.
- Parameters:
description (str) – description of the project to be added later
distributeTime (str ('%I:%M')) – time for automatic distribution
distributionDate (str ('%Y-%m-%d)) – date for automatic distribution
collectionTime (str ('%I:%M')) – time for automatic collection
collectionDate (str ('%Y-%m-%d)) – date for automatic collection
distributeType – type of the distribution
collectionTye – type of the collection
files (list of str) – names of material files for the distribution project
recipients (list of group objects) – groups which are included in the project
- check_put(previousGetResult)[source]#
Calls ‘distribution/get’ and check the modified project :param previousGetResult: info from previous get :type previousGetResult: dict check changing sates for distribution and collection
- put_fail(before_type, after_type, before_time, after_time, before_atJob, after_atJob)[source]#
Checks if the atjobs are in the expected formats :param before_type: type before using put command :type before_type: str :param after_type: type after using put command :type after_type: str :param before_atJob: atJobNum before using put command :type before_atJob: str or None :param after_atJob: atJobNum after using put command :type after_atJob: str or None :param before_time: time before using put command :type before_time: str :param after_time: time after using put command :type after_time: str
- check_distribute(users)[source]#
Checks if the distribution was successful by checking the file system.
univention.testing.ucsschool.exam module#
Class Exam
- univention.testing.ucsschool.exam.wait_replications_check_rejected_uniqueMember(existing_rejects)[source]#
- class univention.testing.ucsschool.exam.Exam(school, room, examEndTime, recipients, name=None, directory=None, files=None, shareMode='home', internetRule='none', customRule='', connection=None)[source]#
Bases:
objectContains the needed functionality for exam module.
- Parameters:
school (str) – name of the school
room (str) – dn of room of the exam
examEndTime (str in format "HH:mm") – exam end time
name (str) – name of the exam to be created later
recipients (list of str) – names of the classes to make the exam
directory (str) – name of the directory for the exam, default=name
files (list of str) – list of files to be uploaded to the exam directory
sharemode (str either "home" or "all") – sharemode
internetRule (str) – name of the internet Rule to be applied in the exam
customRule (str) – cutom internet rule
connection (UMC connection object)
- UMC_SCHOOLEXAM_LOG_PATH = '/var/log/univention/management-console-module-schoolexam.log'#
- save(update=False, fields=None)[source]#
Saves an exam. If fields is a list only the given values are set in the request
- genData(file_name, content_type, boundary, override_file_name=None)[source]#
Generates data in the form to be sent via http POST request.
univention.testing.ucsschool.import_factory_test_classes module#
Classes to test subclassing / factory code of import script
- class univention.testing.ucsschool.import_factory_test_classes.NullImport(dry_run: bool | None = True)[source]#
Bases:
MassImportThis MassImport does not import users.
- Parameters:
dry_run (bool) – set to False to actually commit changes to LDAP
- class univention.testing.ucsschool.import_factory_test_classes.UniventionPasswordExporter(*arg, **kwargs)[source]#
Bases:
NewUserPasswordCsvExporterExport password table as if all passwords were ‘univention’.
Create a CSV file writer.
- Parameters:
- serialize(user)[source]#
Make a dict of attr_name->strings from an import object. IMPLEMENTME to dump a single object (user/computer/error) delivered by the iterator from get_iter().
- Parameters:
obj – object to serialize
- Returns:
attr_name->strings that will be used to write the output file
- Return type:
- class univention.testing.ucsschool.import_factory_test_classes.AnonymizeResultExporter(*arg, **kwargs)[source]#
Bases:
UserImportCsvResultExporterExport import job results with wrong names and birthday.
- class univention.testing.ucsschool.import_factory_test_classes.BirthdayUserImport(dry_run=True)[source]#
Bases:
UserImportPrevent deletion of users on their birthday.
- Parameters:
dry_run (bool) – set to False to actually commit changes to LDAP
- do_delete(user)[source]#
Delete or deactivate a user.
IMPLEMENTME to add or change a deletion variant.
- Parameters:
user (ImportUser) – user to be deleted
- Returns:
whether the deletion worked
- Return type:
- class univention.testing.ucsschool.import_factory_test_classes.FooUsernameHandler(max_length: int, dry_run: bool = True)[source]#
Bases:
UsernameHandlerAdds [FOO] modifier. Always appends “foo” to a username -> works only once per username!
- Parameters:
max_length (int) – created usernames will be no longer
than this :param bool dry_run: if False use LDAP to store already-used usernames if True store for one run only in memory
- property counter_variable_to_function#
Subclass->override this to support other variables than [ALWAYSCOUNTER] and [COUNTER2] or change their meaning. Add/Modify corresponding methods in your subclass. Variables have to start with ‘[’, end with ‘]’ and must be all upper case.
- Returns:
mapping: variable name -> function
- Return type:
- class univention.testing.ucsschool.import_factory_test_classes.JsonWriter(*arg, **kwargs)[source]#
Bases:
BaseWriterCrude JSON writer
Create a writer.
- Parameters:
univention.testing.ucsschool.importgroups module#
- class univention.testing.ucsschool.importgroups.ImportFile(use_cli_api, use_python_api)[source]#
Bases:
object
- class univention.testing.ucsschool.importgroups.GroupImport(ou_name, nr_groups=20)[source]#
Bases:
object
univention.testing.ucsschool.importnetworks module#
- class univention.testing.ucsschool.importnetworks.ImportFile(use_cli_api, use_python_api)[source]#
Bases:
object
- class univention.testing.ucsschool.importnetworks.NetworkImport(ou_name, nr_networks=5)[source]#
Bases:
object
univention.testing.ucsschool.importou module#
- univention.testing.ucsschool.importou.create_ou_cli(ou, dc=None, dc_administrative=None, sharefileserver=None, ou_displayname=None, alter_dhcpd_base=None)[source]#
- univention.testing.ucsschool.importou.create_ou_python_api(ou, dc, dc_administrative, sharefileserver, ou_displayname, alter_dhcpd_base=None)[source]#
- univention.testing.ucsschool.importou.create_and_verify_ou(ucr, ou, dc, sharefileserver, dc_administrative=None, ou_displayname=None, singlemaster=False, noneducational_create_objects=False, district_enable=False, default_dcs=None, dhcp_dns_clearou=False, do_cleanup=True, unset_dhcpd_base=True, alter_dhcpd_base_option=None, use_cli_api=True, use_python_api=False)[source]#
- univention.testing.ucsschool.importou.verify_ou(ou, dc, ucr, sharefileserver, dc_administrative, must_exist)[source]#
- univention.testing.ucsschool.importou.check_group_membership(ou, dc_name, base_dn, lo, must_exist)[source]#
- univention.testing.ucsschool.importou.check_dhcp(ou_base, dc_name, singlemaster, dhcp_dns_clearou, ucr, must_exist)[source]#
- univention.testing.ucsschool.importou.verify_dc(ou, dc_name, dc_type, base_dn=None, must_exist=True)[source]#
Arguments: dc_name: name of the domaincontroller (cn) dc_type: type of the domaincontroller (‘educational’ or ‘administrative’)
- univention.testing.ucsschool.importou.generate_import_ou_basics_test_data(use_cli_api=True, use_python_api=False)[source]#
- univention.testing.ucsschool.importou.import_ou_with_existing_dc(use_cli_api=True, use_python_api=False)[source]#
univention.testing.ucsschool.importprinters module#
- class univention.testing.ucsschool.importprinters.ImportFile(use_cli_api, use_python_api)[source]#
Bases:
object
- class univention.testing.ucsschool.importprinters.PrinterImport(ou_name, nr_printers=20)[source]#
Bases:
object
univention.testing.ucsschool.importusers module#
- class univention.testing.ucsschool.importusers.Person(school, role, **kwargs)[source]#
Bases:
object- property homedir#
- property roles#
- class univention.testing.ucsschool.importusers.UserImport(school_name=None, nr_students=20, nr_teachers=10, nr_staff=5, nr_teacher_staff=3)[source]#
Bases:
object
univention.testing.ucsschool.importusers_cli_v2 module#
- exception univention.testing.ucsschool.importusers_cli_v2.TestFailed(msg, stack)[source]#
Bases:
Exception
- univention.testing.ucsschool.importusers_cli_v2.reset_notifier_restart_burst_limit()[source]#
Avoid “univention-directory-notifier.service: Failed with result ‘start-limit-hit’.” errors due to too many notifier restarts. This resets the burst limit counter, which includes successful service starts (even though the option is called “reset-failed”).
- class univention.testing.ucsschool.importusers_cli_v2.PyHooks(hook_basedir=None)[source]#
Bases:
object
- class univention.testing.ucsschool.importusers_cli_v2.ImportTestbase[source]#
Bases:
object- ou_A = <univention.testing.ucsschool.ucs_test_school.Bunch object>#
- ou_B = <univention.testing.ucsschool.ucs_test_school.Bunch object>#
- ou_C = <univention.testing.ucsschool.ucs_test_school.Bunch object>#
- use_ou_cache = True#
- all_roles = ('staff', 'student', 'teacher', 'teacher_and_staff')#
- classmethod pugre_timestamp_ldap2udm(ldap_val)[source]#
Convert ‘20090101000000Z’ to ‘2009-01-01’. Ignores timezones.
- classmethod pugre_timestamp_udm2ldap(udm_val)[source]#
Convert ‘2009-01-01’ to ‘20090101000000Z’. Ignores timezones.
- wait_for_drs_replication_of_membership(group_dn, member_uid, is_member=True, try_resync=True, **kwargs)[source]#
wait_for_drs_replication() of a user to become a member of a group. :param group: str: DN of a group :param member_uid: str: username :param is_member: bool: whether the user should be a member or not :param try_resync: bool: if waiting for drs replication didn’t succeed, run “/usr/share/univention-s4-connector/resync_object_from_ucs.py <group_dn>” and wait again :param kwargs: dict: will be passed to wait_for_drs_replication() with a modified ‘ldap_filter’ :return: None | <ldb result>
- class univention.testing.ucsschool.importusers_cli_v2.CLI_Import_v2_Tester[source]#
Bases:
ImportTestbase- ldap_date_format = '%Y%m%d%H%M%SZ'#
- udm_date_format = '%Y-%m-%d'#
- create_config_json(values=None, config=None)[source]#
Creates a config file for “ucs-school-user-import”. Default values may be overridden via a dict called values. >>> values = {‘user_role’: ‘teacher’, ‘input:type’: ‘csv’ } >>> create_config_json(values=values) ‘/tmp/config.dkgfcsdz’ >>> create_config_json(values=values, config=DEFAULT_CONFIG) ‘/tmp/config.dkgfcsdz’
- create_csv_file(person_list, sisopi_school=None, mapping=None, fn_csv=None, prefix_schools=True)[source]#
Create CSV file for given persons >>> from univention.testing.ucsschool.importusers import Person >>> create_csv_file([Person(‘schoolA’, ‘student’), Person(‘schoolB’, ‘teacher’)]) ‘/tmp/import.sldfhgsg.csv’ >>> create_csv_file([Person(‘schoolA’, ‘student’), Person(‘schoolB’, ‘teacher’)],
fn_csv=’/tmp/import.foo.csv’)
‘/tmp/import.foo.csv’ >>> create_csv_file([Person(‘schoolA’, ‘student’), Person(‘schoolB’, ‘teacher’)],
headers={‘firstname’: ‘Vorname’, …})
‘/tmp/import.cetjdfgj.csv’
univention.testing.ucsschool.importusers_http module#
- class univention.testing.ucsschool.importusers_http.HttpApiImportTester[source]#
Bases:
ImportTestbase- default_config_path = '/usr/share/ucs-school-import/configs/ucs-school-testuser-http-import.json'#
- create_import_security_group(ou_dn: str, allowed_ou_names: List[str] | None = None, roles: List[str] | None = None, user_dns: List[str] | None = None) Tuple[str, str][source]#
Create a import security group.
- Parameters:
- Returns:
group_dn, group_name
- Return type:
- property default_config#
- run_http_import_through_python_client(client: Client, filename: str, school: str, role: str, dryrun: bool | None = True, timeout: int | None = 600, config: Dict[str, str] | None = None) ResourceRepresentation.UserImportJobResource[source]#
Run an import through the Python client of the HTTP-API.
- Parameters:
client (ucsschool.http_api.client.Client) – an instance of ucsschool.http_api.client.Client
filename (str) – the CSV file to import
school (str) – OU to import into
role (str) – UCS@school user role
dryrun (bool) – whether to do a dry-run or a real import
timeout (int) – seconds to wait for the import to finish
config (dict) – if not None: configuration to temporarily write to /var/lib/ucs-school-import/configs/user_import_http-api.json
- Returns:
UserImportJob resource representation object
- Return type:
univention.testing.ucsschool.internetrule module#
Class InternetRule
All the operations related to internet rules
- class univention.testing.ucsschool.internetrule.InternetRule(connection=None, ucr=None, name=None, typ=None, domains=None, wlan=None, priority=None)[source]#
Bases:
objectContains the needed functionality for internet rules. By default they are randomly formed
- Parameters:
connection (UMC connection object)
ucr (UCR object)
name (str) – name of the internet rule to be created later
typ (str='whitelist' or 'blacklist') – type of the internet rule to be created later
domains ([str]) – list of the internet rule to be created later
wlan (bool) – if the internet rule supports wlan
priority ([int]) – priority of the internet rule [0,10]
- get(should_exist)[source]#
gets internet rule via UMCP
- Parameters:
should_exist (bool) – True if the rule is expected to be found
- put(new_name=None, new_type=None, new_domains=None, new_wlan=None, new_priority=None)[source]#
Modify internet rule via UMCP
with no args passed this only reset the rule properties
- checkUcr(should_match)[source]#
check ucr for internet rule
Fetch the values from ucr and check if it matches the correct values for the rule
- Parameters:
should_match (bool)
univention.testing.ucsschool.klasse module#
- class univention.testing.ucsschool.klasse.Klasse(school, connection=None, ucr=None, name=None, users=None, description=None)[source]#
Bases:
objectContains the needed functionality for classes in an already created OU, By default they are randomly formed except the OU, should be provided
- Parameters:
univention.testing.ucsschool.radius module#
univention.testing.ucsschool.randomdomain module#
univention.testing.ucsschool.school module#
univention.testing.ucsschool.schoolroom module#
- class univention.testing.ucsschool.schoolroom.ComputerRoom(school, name=None, description=None, host_members=[], teacher_computers=[], connection=None)[source]#
Bases:
object- assert_backend_role() None[source]#
Checks for the presence/absence of the veyon backend role in the rooms ldap object.
- Raises:
AssertionError – If the assertion is not fulfilled.
- get(should_exist=True)[source]#
gets school room via UMCP
- Parameters:
should_exist (bool) – True if the school room is expected to be found
- check_get(expected_attrs)[source]#
checks if the result of get command matches the expected attributes.
- class univention.testing.ucsschool.schoolroom.ComputerRoomSaml(*args, **kwargs)[source]#
Bases:
ComputerRoom
univention.testing.ucsschool.simplecurl module#
- class univention.testing.ucsschool.simplecurl.SimpleCurl(proxy, username=None, password=None, bFollowLocation=1, maxReDirs=5, connectTimout=10, timeOut=10, port=3128, auth=pycurl.HTTPAUTH_BASIC, cookie=None)[source]#
Bases:
objectpycurl simple class implementation
- Parameters:
univention.testing.ucsschool.test_samba4 module#
- class univention.testing.ucsschool.test_samba4.TestSamba4[source]#
Bases:
objectTest class constructor
- create_and_run_process(cmd, stdin=None, std_input=None, shell=False, stdout=-1)[source]#
Creates a process as a Popen instance with a given ‘cmd’ and executes it. When stdin is needed, it can be provided with kwargs. To write to a file an istance can be provided to stdout.
- start_stop_service(service, action)[source]#
Starts, stops or restarts the given ‘service’ depending on the given ‘action’ is ‘start’, ‘stop’, ‘restart’ respectively.
- dc_master_has_samba4()[source]#
Returns ‘True’ when Primary Directory Node has Samba4 according to ‘service=Samba 4’
- is_a_school_branch_site(host_dn)[source]#
Returns True if the given ‘host_dn’ is located in the School branch site.
- grep_for_key(grep_in, key)[source]#
Runs grep on given ‘grep_in’ with a given ‘key’. Returns the output.
- get_udm_list_dcs(dc_type, with_samba4=True, with_ucsschool=False)[source]#
Runs the “udm computers/’dc_type’ list” and returns the output. If ‘with_samba4’ is ‘True’ returns only those running Samba 4.
- get_udm_list_dc_slaves_with_samba4(with_ucsschool=False)[source]#
Returns the output of “udm computers/domaincontroller_slave list –filter service=Samba 4” command.
- select_school_ou(schoolname_only=False)[source]#
Returns the first found School OU from the list of Replica Directory Nodes in domain.
univention.testing.ucsschool.ucs_test_school module#
API for testing UCS@school and cleaning up after performed tests
- univention.testing.ucsschool.ucs_test_school.force_ucsschool_logger_colorized_if_has_tty()[source]#
Force the logger “ucsschool” returned by
ucsschool.models.utils.get_stream_handler()(and used inadd_stream_logger_to_schoollib()) to colorize terminal output in case our process has a TTY or our parents process if it’s called “ucs-test” and has a TTY.If ucs-test is run by Jenkins, it won’t have the TTY itself, in which case the output won’t be colorized.
- exception univention.testing.ucsschool.ucs_test_school.SchoolMissingOU[source]#
Bases:
SchoolError
- exception univention.testing.ucsschool.ucs_test_school.SchoolLDAPError[source]#
Bases:
SchoolError
- class univention.testing.ucsschool.ucs_test_school.UCSTestSchool[source]#
Bases:
object- ucr = <Proxy at 0x7f8eeb5d3000 wrapping <univention.testing.ucr.UCSTestConfigRegistry object> at 0x7f8eeb599090 with factory <function UCSTestSchool.<lambda>>>#
- LDAP_BASE = <Proxy at 0x7f8eebbccfc0 wrapping 'dc=example,dc=org' at 0x7f8eeaac9a20 with factory <function UCSTestSchool.<lambda>>>#
- PATH_CMD_BASE = '/usr/share/ucs-school-import/scripts'#
- PATH_CMD_CREATE_OU = '/usr/share/ucs-school-import/scripts/create_ou'#
- CN_STUDENT = <Proxy at 0x7f8eeb7bc140 wrapping 'schueler' at 0x7f8f13355030 with factory <function UCSTestSchool.<lambda>>>#
- CN_TEACHERS = <Proxy at 0x7f8eeb7bf940 wrapping 'lehrer' at 0x7f8f13354530 with factory <function UCSTestSchool.<lambda>>>#
- CN_TEACHERS_STAFF = <Proxy at 0x7f8eeb5c8880 wrapping 'lehrer und mitarbeiter' at 0x7f8eeb5e3b40 with factory <function UCSTestSchool.<lambda>>>#
- CN_ADMINS = <Proxy at 0x7f8eeb5cb7c0 wrapping 'admins' at 0x7f8f1339b170 with factory <function UCSTestSchool.<lambda>>>#
- CN_STAFF = <Proxy at 0x7f8eebf3b740 wrapping 'mitarbeiter' at 0x7f8f13355a30 with factory <function UCSTestSchool.<lambda>>>#
- classmethod open_ldap_connection(binddn=None, bindpw=None, ldap_server=None, admin=False, machine=False)[source]#
Opens a new LDAP connection using the given user LDAP DN and password. The connection is established to the given server or (if None is given) to the server defined by the UCR variable ldap/server/name is used. If admin is set to True, a connection is setup by getAdminConnection(). If machine is set to True, a connection to the Primary Directory Node is setup by getMachoneConnection().
- cleanup(wait_for_replication=True)[source]#
Cleanup all objects created by the UCS@school test environment
- cleanup_ou(ou_name: str, wait_for_replication: bool | None = True, retry: bool | None = True) bool[source]#
Removes the given school ou and all its corresponding objects like groups
- remove_ucsschool_role_from_dcs(ou_name: str) None[source]#
Remove ucschoolRole on DCs (only in case of singleserver and name_edudc != ucr[“hostname”])
- create_ou(ou_name: str | None = None, name_edudc: str | None = None, name_admindc: str | None = None, displayName: str | None = '', name_share_file_server: str | None = None, use_cli: bool | None = False, wait_for_replication: bool | None = True, use_cache: bool | None = True) Tuple[str, str][source]#
Creates a new OU with random or specified name. The function may also set a specified displayName. If “displayName” is None, a random displayName will be set. If “displayName” equals to the empty string (‘’), the displayName won’t be set. “name_edudc” may contain the optional name for an educational Replica Directory Node. “name_admindc” may contain the optional name for an administrative Replica Directory Node. If name_share_file_server is set, the class share file server and the home share file server will be set. If use_cli is set to True, the old CLI interface is used. Otherwise the UCS@school python library is used. If use_cache is True (default) and an OU was created in a previous test with the same arguments, it will be reused. -> If ou_name and displayName are None, instead of creating new random names, the existing test-OU will be returned. PLEASE NOTE: if name_edudc is set to the hostname of the Primary Directory Node or Backup Directory Node, name_edudc will be unset automatically, because it’s not allowed to specify the hostname of the Primary Directory Node or any Backup Directory Node in any situation!
- Return value: (ou_name, ou_dn)
ou_name: name of the created OU ou_dn: DN of the created OU object
- create_multiple_ous(num: int, name_edudc: str | None = None, name_admindc: str | None = None, displayName: str | None = '', name_share_file_server: str | None = None, use_cli: bool | None = False, wait_for_replication: bool | None = True, use_cache: bool | None = True) List[Tuple[str, str]][source]#
Create num OUs with each the same arguments and a random ou_name, without either effectively dodging the OU-cache or each time getting the same OU (with use_cache=True). All arguments except num plus a random name for the ou (argument “ou_name”) will be passed to create_ou().
- Parameters:
num – int - number or OUs to create
- Returns:
list - list of tuples returned by create_ou()
- get_ou_base_dn(ou_name)[source]#
Returns the LDAP DN for the given school OU name (the district mode will be considered).
- get_user_container(ou_name, is_teacher=False, is_staff=False)[source]#
Returns user container for specified user role and ou_name.
Return the DN of the share object for the specified working group.
- create_teacher(*args, **kwargs)[source]#
Accepts same arguments as
create_user(), and sets is_staff and `is_teacher`accordingly.
- create_student(*args, **kwargs)[source]#
Accepts same arguments as
create_user(), and sets is_staff and `is_teacher`accordingly.
- create_staff(*args, **kwargs)[source]#
Accepts same arguments as
create_user(), and sets is_staff and `is_teacher`accordingly.
- create_teacher_and_staff(*args, **kwargs)[source]#
Accepts same arguments as
create_user(), and sets is_staff and `is_teacher`accordingly.
- create_user(ou_name: str, schools: List[str] | None = None, username: str | None = None, firstname: str | None = None, lastname: str | None = None, classes: str | None = None, mailaddress: str | None = None, is_teacher: bool | None = False, is_staff: bool | None = False, is_active: bool | None = True, password: str | None = 'univention', ucsschool_roles: List | None = None, wait_for_replication: bool | None = True, check_password_policies: bool | None = False) Tuple[str, str][source]#
Create a user in specified OU with given attributes. If attributes are not specified, random values will be used for username, firstname and lastname. If password is not None, the given password will be set for this user.
- Return value: (user_name, user_dn)
user_name: name of the created user user_dn: DN of the created user object
- create_school_admin(ou_name: str, schools: List[str] | None = None, is_staff: bool | None = None, is_teacher: bool | None = None, wait_for_replication: bool | None = True, *args, **kwargs) Tuple[str, str][source]#
Accepts same arguments as
create_user().
- create_domain_admin(ou_name: str, username: str | None = None, password: str | None = 'univention') Tuple[str, str][source]#
- create_global_user(username: str | None = None, password: str | None = 'univention') Tuple[str, str][source]#
- create_school_class(ou_name: str, class_name: str | None = None, description: str | None = None, users: List[str] | None = None, wait_for_replication: bool | None = True) Tuple[str, str][source]#
- create_workgroup(ou_name, workgroup_name=None, description=None, users=None, wait_for_replication=True)[source]#
Creates a new workgroup in specified ou <ou_name>. If no name for the workgroup is specified, a random name is used. <name> has to be of format “<OU>-<WGNAME>” or “<WGNAME>”. Group members may also be specified a list of user DNs in <users>.
- create_computerroom(ou_name, name=None, description=None, host_members=None, wait_for_replication=True, teacher_computers=[])[source]#
Create a room in specified OU with given attributes. If attributes are not specified, random values will be used for roomname and description.
- Return value: (room_name, room_dn)
room_name: name of the created room room_dn: DN of the created room object
- class univention.testing.ucsschool.ucs_test_school.NameDnObj(name: str = None, dn: str = None)[source]#
Bases:
object
- class univention.testing.ucsschool.ucs_test_school.AutoMultiSchoolEnv_Generic[source]#
Bases:
object
- class univention.testing.ucsschool.ucs_test_school.AutoMultiSchoolEnv[source]#
Bases:
UCSTestSchool
- class univention.testing.ucsschool.ucs_test_school.OUCloner(lo: LoType)[source]#
Bases:
objectCreate a OU bypassing UDM.
Objects are mostly OK to work with. As UDM is bypasswd, GIDs, UIDs, Samba IDs, usernames and krb5PrincipalName are not trustworthy. Do NOT use this in production!
oc = OUCloner(lo) oc.clone_ou(“DEMOSCHOOL”, “testou1234”)
- clone_ou(ori_ou: str, new_ou: str) None[source]#
Create the school OU new_ou from LDAP data related to`ori_ou`.
- static replace_case_sesitive_and_lower(s: str, ori: str, new: str) str[source]#
Replace the string ori in s with new. Do it both case-sensitive and with both lower-case.
- clone_object(dn_ori: str, attrs_ori: Dict[str, List[str]], ori_ou: str, new_ou: str) None[source]#
Create a clone of the object at dn_ori in the OU new_ou.
Attributes are kept unchanged, except: cn, displayName, gidNumber, krb5PrincipalName, memberUid, sambaSID, uid, uidNumber and uniqueMember. Group members are removed and added later in update_group_members().
univention.testing.ucsschool.user module#
- class univention.testing.ucsschool.user.User(school, role, school_classes, workgroups=None, mode='A', username=None, firstname=None, lastname=None, password=None, mail=None, expiration_date=None, schools=None, connection=None, birthday=None)[source]#
Bases:
PersonContains the needed functuality for users in the UMC module schoolwizards/users.
- Parameters:
school (str) – school name of the user
role (str ['student', 'teacher', 'staff', 'teacherAndStaff']) – role of the user
school_classes (dict) – dictionary of school -> list of names of the class which contain the user
workgroups (dict) – dictionary of school -> list of names of the workgroups which contain the user
- property ucsschool_roles#
univention.testing.ucsschool.workgroup module#
- class univention.testing.ucsschool.workgroup.Workgroup(school, connection=None, ulConnection=None, ucr=None, name=None, description=None, members=None, create_share=True, create_email=False, email='', allowed_email_senders_groups=None, allowed_email_senders_users=None)[source]#
Bases:
objectContains the needed functionality for workgroups in an already created OU, By default they are randomly formed except the OU, should be provided
- Parameters:
- create(expect_creation_fails_due_to_duplicated_name=False)[source]#
Creates object workgroup
- Parameters:
expect_creation_fails_due_to_duplicated_name (bool) – if user allow duplicate names no exception is raised, no group is created either
- addMembers(memberListdn, options=None)[source]#
Add members to workgroup
- Parameters:
memberListdn (list) – list of the new members
options (None)
- removeMembers(memberListdn, options=None)[source]#
Remove members from workgroup
- Parameters:
memberListdn (list) – list of the removed members
options (None)
- set_members(new_members, options=None)[source]#
Set members for workgroup
- Parameters:
new_members (list) – list of the new members