univention.testing.ucsschool package

Contents

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: object

Create 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: CreateContextManager

Create 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: CreateContextManager

Create 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: object

Acl class

contains the basic functuality to test acls for the common container in ucsschool may change with time.

Parameters:
  • school (str) – school name

  • auth_dn (str) – dn of the authentication actor

  • access_allowance (str) – the expected access result - ALLOWED or DENIED

assert_acl(target_dn, access, attrs, access_allowance=None)[source]#

Test ACL rule:

Parameters:
  • target_dn (str) – Target dn to test access to

  • attrs (list[str]) – names of the attributes to test acl against

  • access (str) – type of access - read, write or none

assert_base_dn(access)[source]#

General acces rule = all read

assert_student(stu_dn, access)[source]#

Lehrer und OU-Admins duerfen Schueler-Passwoerter aendern

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_student_group(access)[source]#
assert_share_object_access(share_dn, access, access_allowance='ALLOWED')[source]#

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.

assert_shares(shares_dn, access)[source]#

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_gid_temps(access)[source]#
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

assert_dhcp(client, access, modify_only_attrs=False)[source]#

Check access to DHCP host objects.

By default, all attributes are checked. If modify_only_attrs is True, only attributes that are required to modify the DHCP host object are checked.

assert_member_server(access)[source]#

Mitglieder der lokalen Administratoren duerfen den Replica Directory Node und Managed Node joinen (benoetigt Passwortaenderung)

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_network() str[source]#
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]#
univention.testing.ucsschool.computer.random_mac() str[source]#
class univention.testing.ucsschool.computer.Computer(school: str, ctype: str)[source]#

Bases: object

get_args()[source]#
set_network_address()[source]#
set_inventory_numbers()[source]#
expected_attributes()[source]#
verify()[source]#
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)

class univention.testing.ucsschool.computer.Computers(lo: LoType, school: str, nr_windows: int = 1, nr_macos: int = 0, nr_ipmanagedclient: int = 0, nr_linux: int = 0, nr_ubuntu: int = 0)[source]#

Bases: object

create() list[Computer][source]#
static get_dns(computers: list[Computer]) list[str][source]#
static get_hostnames(computers: list[Computer]) list[str][source]#

univention.testing.ucsschool.computerroom module#

exception univention.testing.ucsschool.computerroom.CmdCheckFail[source]#

Bases: Exception

univention.testing.ucsschool.computerroom.retry_cmd(func)[source]#
class univention.testing.ucsschool.computerroom.Room(school, name=None, dn=None, description=None, host_members=None, teacher_computers=None)[source]#

Bases: object

get_room_user(client)[source]#
check_room_user(client, expected_user)[source]#
aquire_room(client)[source]#
checK_room_aquire(client, expected_answer)[source]#
get_room_computers(client)[source]#
check_room_computers(client, expected_computer_list)[source]#
set_room_settings(client, new_settings)[source]#
get_room_settings(client)[source]#
check_room_settings(client, expected_settings)[source]#
get_internetRules(client)[source]#
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’))

check_atjobs(period, expected_existence)[source]#
check_displayTime(client, period)[source]#
test_time_settings(client)[source]#
check_home_read(user, ip_address, passwd='univention', expected_result=0)[source]#
check_home_write(user, ip_address, passwd='univention', expected_result=0)[source]#
check_marktplatz_read(user, ip_address, passwd='univention', expected_result=0)[source]#
check_marktplatz_write(user, ip_address, passwd='univention', expected_result=0)[source]#
check_share_access(user, ip_address, expected_home_result, expected_marktplatz_result)[source]#
check_share_behavior(user, ip_address, shareMode)[source]#
test_share_access_settings(user, ip_address, client)[source]#
check_smb_print(ip, printer, user, expected_result)[source]#
check_print_behavior(user, ip_address, printer, printMode)[source]#
test_printMode_settings(school, user, ip_address, client, ucr)[source]#
checK_internetrules(ucr, user, proxy, custom_domain, global_domains, expected_rule)[source]#
test_internetrules_settings(school, user, user_dn, ip_address, ucr, client)[source]#
test_settings(school, user, user_dn, ip_address, ucr, client)[source]#
check_behavior(partial_old_settings, new_settings, user, ip_address, printer, white_page, global_domains, ucr)[source]#
univention.testing.ucsschool.computerroom.get_banpage(ucr)[source]#
univention.testing.ucsschool.computerroom.clean_folder(path)[source]#
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]#
univention.testing.ucsschool.computerroom.remove_printer(name, school, ldap_base)[source]#
univention.testing.ucsschool.computerroom.set_windows_pc_password(dn, password)[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

create(should_succeed=True, ignore_warning=True)[source]#

Creates object Computer

remove()[source]#

Remove computer

dn()[source]#
get()[source]#

Get Computer

check_get()[source]#
type_name()[source]#
edit(name=None, ip_address=None, subnet_mask=None, mac_address=None, inventory_number=None)[source]#

Edit object computer

query()[source]#

get the list of existing computer in the school

check_query(computer_names)[source]#
verify_ldap(should_exist)[source]#
univention.testing.ucsschool.computerroom.create_homedirs(member_dn_list, open_ldap_co)[source]#
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.computerroom.check_share_read(user, ip_address, share, passwd='univention', filename='/*', expected_result=0)[source]#
univention.testing.ucsschool.computerroom.check_share_write(user, ip_address, share, passwd='univention', remote_filename=None, expected_result=0)[source]#

univention.testing.ucsschool.conftest module#

class univention.testing.ucsschool.conftest.UCSSchoolType(value)[source]#

Bases: Enum

class univention.testing.ucsschool.conftest.GroupType(value)[source]#

Bases: UCSSchoolType

SchoolClass = 'SchoolClass'#
WorkGroup = 'WorkGroup'#
class univention.testing.ucsschool.conftest.ShareType(value)[source]#

Bases: UCSSchoolType

ClassShare = 'ClassShare'#
MarketplaceShare = 'MarketplaceShare'#
WorkGroupShare = 'WorkGroupShare'#
class univention.testing.ucsschool.conftest.UserType(value)[source]#

Bases: UCSSchoolType

SchoolAdmin = 'SchoolAdmin'#
Staff = 'Staff'#
Student = 'Student'#
Teacher = 'Teacher'#
TeachersAndStaff = 'TeachersAndStaff'#
univention.testing.ucsschool.conftest.model_ldap_object_classes()[source]#
univention.testing.ucsschool.conftest.model_school_object_class()[source]#
univention.testing.ucsschool.conftest.model_ucsschool_roles()[source]#
univention.testing.ucsschool.conftest.model_udm_module()[source]#
univention.testing.ucsschool.conftest.model_ldap_container(ucr_ldap_base)[source]#
univention.testing.ucsschool.conftest.user_groups(ucr_ldap_base, model_ldap_container)[source]#
univention.testing.ucsschool.conftest.random_int()[source]#
univention.testing.ucsschool.conftest.random_username()[source]#
univention.testing.ucsschool.conftest.ucr()[source]#

Instance of UCSTestConfigRegistry

univention.testing.ucsschool.conftest.fqdn(ucr)[source]#

hostname.domainname

univention.testing.ucsschool.conftest.admin_username(ucr)[source]#

Username of the Admin account

univention.testing.ucsschool.conftest.admin_password(ucr)[source]#

Password of the Admin account

univention.testing.ucsschool.conftest.machine_account_dn(ucr)[source]#
univention.testing.ucsschool.conftest.machine_password()[source]#
univention.testing.ucsschool.conftest.schoolenv()[source]#
univention.testing.ucsschool.conftest.create_ou(schoolenv, ucr_hostname)[source]#
univention.testing.ucsschool.conftest.lo(schoolenv)[source]#
univention.testing.ucsschool.conftest.udm_session()[source]#
univention.testing.ucsschool.conftest.create_import_user(lo)[source]#
univention.testing.ucsschool.conftest.get_import_user(import_config, lo)[source]#
univention.testing.ucsschool.conftest.mail_domain()[source]#
univention.testing.ucsschool.conftest.ucr_domainname(ucr)[source]#
univention.testing.ucsschool.conftest.ucr_hostname(ucr)[source]#
univention.testing.ucsschool.conftest.ucr_is_singlemaster(ucr)[source]#
univention.testing.ucsschool.conftest.ucr_ldap_base(ucr)[source]#
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.user_school_attributes(user_ldap_attributes)[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.conftest.workgroup_share_ldap_attributes(random_username, ucr_domainname, ucr_hostname, ucr_ldap_base, model_ldap_object_classes, model_ucsschool_roles, model_udm_module)[source]#
univention.testing.ucsschool.conftest.workgroup_share_school_attributes(workgroup_share_ldap_attributes)[source]#
univention.testing.ucsschool.conftest.random_logger()[source]#
univention.testing.ucsschool.conftest.restart_services()[source]#
univention.testing.ucsschool.conftest.schedule_restart_services(restart_services)[source]#
univention.testing.ucsschool.conftest.restart_umc(restart_services)[source]#
univention.testing.ucsschool.conftest.schedule_restart_umc(schedule_restart_services)[source]#
univention.testing.ucsschool.conftest.stop_module_process()[source]#
univention.testing.ucsschool.conftest.copy_file()[source]#

Copy file to target location and cleans up afterwards.

univention.testing.ucsschool.conftest.check_pdfprinter_spool_permissions()[source]#
univention.testing.ucsschool.conftest.list_pdfprinter_jobs()[source]#
univention.testing.ucsschool.conftest.send_pdfprinter_job(ucr, list_pdfprinter_jobs)[source]#

univention.testing.ucsschool.csv_test_helper module#

univention.testing.ucsschool.csv_test_helper.get_test_chars(encoding)[source]#
univention.testing.ucsschool.csv_test_helper.write_formatted_csv(fn_csv, input_encoding, content)[source]#

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: object

Contains 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

get()[source]#

Calls ‘distribute/get’

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.

Parameters:
  • file_name (str) – file name to be uploaded

  • content_type (str ('text/plain',..)) – type of the content of the file

  • boundary (str (-------123091)) – the boundary

  • flavor (str) – flavor of the acting user

uploadFile(file_name, content_type=None, override_file_name=None)[source]#

Uploads a file via http POST request.

Parameters:
  • file_name (str) – file name to be uploaded

  • content_type (str ('text/plain',..)) – type of the content of the file

add()[source]#

Create files and upload them then add the project, calls: ‘distribution/add’

check_add()[source]#

Calls ‘distribution/query’ and check the existance of the added project

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

distribute()[source]#

Calls ‘distribution/distribute’

check_distribute(users)[source]#

Checks if the distribution was successful by checking the file system.

Parameters:

users (list of str) – names of users to have the material distributed for

collect()[source]#

Calls ‘distribution/collect’

check_collect(users)[source]#

Checks if the collection was successful by checking the file system.

Parameters:

users (list of str) – names of users to have the material collected from

remove()[source]#

Calls ‘distribution/remove’

check_remove()[source]#

Calls ‘distribution/query’ and check the existance of the removed project

checkFiles(files)[source]#

Calls ‘distribution/checkfiles’

adopt(project_name)[source]#

Calls ‘distribute/adopt’

check_adopt(project_name)[source]#
getUserFilesPath(user, purpose='distribute', version=1)[source]#

Gets the correct files path for a specific user depending on the value of the ucr variable ucsschool/import/roleshare.

Parameters:
  • user (str) – user name

  • purpose (str ('distribute' or 'collect')) – either for distribution or collection

univention.testing.ucsschool.exam module#

Class Exam

univention.testing.ucsschool.exam.get_dir_files(dir_path, recursive=True)[source]#
univention.testing.ucsschool.exam.get_s4_rejected()[source]#
univention.testing.ucsschool.exam.check_s4_rejected(existing_rejects)[source]#
univention.testing.ucsschool.exam.check_proof_uniqueMember()[source]#
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: object

Contains 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'#
start()[source]#

Starts an exam

save(update=False, fields=None)[source]#

Saves an exam. If fields is a list only the given values are set in the request

get()[source]#

Gets an exam and returns result

delete()[source]#

Deletes an exam and returns result

finish()[source]#

Finish an exam

genData(file_name, content_type, boundary, override_file_name=None)[source]#

Generates data in the form to be sent via http POST request.

Parameters:
  • file_name (str) – file name to be uploaded

  • content_type (str ('text/plain',..)) – type of the content of the file

  • boundary (str (-------123091)) – the boundary

  • flavor (str) – flavor of the acting user

uploadFile(file_name, content_type=None, override_file_name=None)[source]#

Uploads a file via http POST request.

Parameters:
  • file_name (str) – file name to be uploaded

  • content_type (str ('application/octet-stream',..)) – type of the content of the file

get_internetRules()[source]#

Get internet rules

fetch_internetRule(internetRule_name)[source]#
get_schools()[source]#

Get schools

fetch_school(school)[source]#
get_groups()[source]#

Get groups

fetch_groups(group)[source]#
get_lessonEnd()[source]#

Get lessonEnd

fetch_lessonEnd(lessonEnd)[source]#
collect()[source]#

Collect results

check_collect()[source]#
check_upload()[source]#
check_distribute()[source]#
class univention.testing.ucsschool.exam.ExamSaml(*args, **kwargs)[source]#

Bases: Exam

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: MassImport

This MassImport does not import users.

Parameters:

dry_run (bool) – set to False to actually commit changes to LDAP

import_users()[source]#
class univention.testing.ucsschool.import_factory_test_classes.UniventionPasswordExporter(*arg, **kwargs)[source]#

Bases: NewUserPasswordCsvExporter

Export password table as if all passwords were ‘univention’.

Create a CSV file writer.

Parameters:
  • arg (list) – arguments for implementing class

  • kwargs (dict) – arguments for implementing class

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:

dict

class univention.testing.ucsschool.import_factory_test_classes.AnonymizeResultExporter(*arg, **kwargs)[source]#

Bases: UserImportCsvResultExporter

Export import job results with wrong names and birthday.

Parameters:
  • arg (tuple) – ignored

  • kwargs (dict) – ignored

serialize(obj)[source]#

Make a dict of attr_name->strings from an import object.

Parameters:

obj – object to serialize

Returns:

mapping attr_name->strings that will be used to write the output file

Return type:

dict

class univention.testing.ucsschool.import_factory_test_classes.BirthdayUserImport(dry_run=True)[source]#

Bases: UserImport

Prevent 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:

bool

class univention.testing.ucsschool.import_factory_test_classes.FooUsernameHandler(max_length: int, dry_run: bool = True)[source]#

Bases: UsernameHandler

Adds [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:

dict

foo_counter(name_base)[source]#
class univention.testing.ucsschool.import_factory_test_classes.JsonWriter(*arg, **kwargs)[source]#

Bases: BaseWriter

Crude JSON writer

Create a writer.

Parameters:
  • arg (tuple) – arguments for implementing class

  • kwargs (dict) – arguments for implementing class

open(filename, mode='wb')[source]#

Get a handle on the output file or something similar to be used as a context manager. IMPLEMENTME with the method appropriate for the output type.

Parameters:
  • filename (str) – filename to write data to

  • mode (str) – passed to used open() method

Returns:

a context manager

write_obj(obj)[source]#

Write object to output. IMPLEMENTME if it’s not just outfile.write(obj).

Parameters:

obj – object or error to write

Returns:

result of write operation, if any

univention.testing.ucsschool.importgroups module#

class univention.testing.ucsschool.importgroups.Group(school)[source]#

Bases: object

set_mode_to_modify()[source]#
set_mode_to_delete()[source]#
expected_attributes()[source]#
verify()[source]#
class univention.testing.ucsschool.importgroups.ImportFile(use_cli_api, use_python_api)[source]#

Bases: object

write_import()[source]#
run_import(group_import)[source]#
class univention.testing.ucsschool.importgroups.GroupImport(ou_name, nr_groups=20)[source]#

Bases: object

verify()[source]#
modify()[source]#
delete()[source]#
univention.testing.ucsschool.importgroups.create_and_verify_groups(use_cli_api=True, use_python_api=False, nr_groups=5)[source]#
univention.testing.ucsschool.importgroups.import_groups_basics(use_cli_api=True, use_python_api=False)[source]#

univention.testing.ucsschool.importnetworks module#

univention.testing.ucsschool.importnetworks.get_reverse_net(network, netmask)[source]#
class univention.testing.ucsschool.importnetworks.Network(school, prefixlen)[source]#

Bases: object

expected_attributes()[source]#
verify()[source]#
set_mode_to_router()[source]#
class univention.testing.ucsschool.importnetworks.ImportFile(use_cli_api, use_python_api)[source]#

Bases: object

write_import(data)[source]#
run_import(data)[source]#
set_mode_to_router()[source]#
class univention.testing.ucsschool.importnetworks.NetworkImport(ou_name, nr_networks=5)[source]#

Bases: object

verify()[source]#
set_mode_to_router()[source]#
modify()[source]#
univention.testing.ucsschool.importnetworks.create_and_verify_networks(use_cli_api=True, use_python_api=False, nr_networks=5)[source]#
univention.testing.ucsschool.importnetworks.import_networks_basics(use_cli_api=True, use_python_api=False)[source]#

univention.testing.ucsschool.importou module#

exception univention.testing.ucsschool.importou.DCNotFound[source]#

Bases: Exception

exception univention.testing.ucsschool.importou.DCMembership[source]#

Bases: Exception

exception univention.testing.ucsschool.importou.DCisMemberOfGroup[source]#

Bases: Exception

exception univention.testing.ucsschool.importou.DhcpdLDAPBase[source]#

Bases: Exception

exception univention.testing.ucsschool.importou.DhcpServerLocation[source]#

Bases: Exception

univention.testing.ucsschool.importou.create_mail_domain(ucr, udm)[source]#
univention.testing.ucsschool.importou.remove_ou(ou_name)[source]#
univention.testing.ucsschool.importou.get_school_base(ou)[source]#
univention.testing.ucsschool.importou.get_school_ou_from_dn(dn, ucr=None)[source]#
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.move_domaincontroller_to_ou_cli(dc_name, ou)[source]#
univention.testing.ucsschool.importou.get_ou_base(ou, district_enable)[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.parametrization_id_base64_decode(val)[source]#
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.importou.import_3_ou_in_a_row(use_cli_api=True, use_python_api=False)[source]#

Creates 3 OUs in a row

univention.testing.ucsschool.importou.import_ou_alter_dhcpd_base_flag(use_cli_api=True, use_python_api=False)[source]#

univention.testing.ucsschool.importprinters module#

class univention.testing.ucsschool.importprinters.Printer(school)[source]#

Bases: object

set_mode_to_modify()[source]#
set_mode_to_delete()[source]#
expected_attributes()[source]#
verify()[source]#
class univention.testing.ucsschool.importprinters.ImportFile(use_cli_api, use_python_api)[source]#

Bases: object

write_import(data)[source]#
run_import(data)[source]#
class univention.testing.ucsschool.importprinters.PrinterImport(ou_name, nr_printers=20)[source]#

Bases: object

verify()[source]#
modify()[source]#
delete()[source]#
univention.testing.ucsschool.importprinters.create_and_verify_printers(use_cli_api=True, use_python_api=False, nr_printers=5)[source]#
univention.testing.ucsschool.importprinters.import_printers_basics(use_cli_api=True, use_python_api=False)[source]#

univention.testing.ucsschool.importusers module#

class univention.testing.ucsschool.importusers.Person(school, role, **kwargs)[source]#

Bases: object

make_dn()[source]#
property homedir#
make_school_base()[source]#
append_random_groups()[source]#
set_mode_to_modify()[source]#
set_mode_to_delete()[source]#
set_active()[source]#
set_inactive()[source]#
is_active()[source]#
update(**kwargs)[source]#
move_school_classes(old_school, new_school)[source]#
map_to_dict(value_map, prefix_schools=True)[source]#
get_csv_line()[source]#
append_random_class(schools=None)[source]#
append_random_working_group()[source]#
is_student()[source]#
is_teacher()[source]#
is_staff()[source]#
is_teacher_staff()[source]#
expected_attributes()[source]#
get_samba_home_path_server()[source]#
get_profile_path_server()[source]#
property roles#
verify()[source]#
update_from_ldap(lo: access, attrs: List[str], source_uid: str | None = None, record_uid: str | None = None) None[source]#

Fetch attributes listed in attrs and set them on self.

source_uid and record_uid must either be set on self or given.

set_random_birthday()[source]#
class univention.testing.ucsschool.importusers.Student(school)[source]#

Bases: Person

class univention.testing.ucsschool.importusers.Teacher(school)[source]#

Bases: Person

class univention.testing.ucsschool.importusers.Staff(school)[source]#

Bases: Person

class univention.testing.ucsschool.importusers.TeacherStaff(school)[source]#

Bases: Person

class univention.testing.ucsschool.importusers.ImportFile[source]#

Bases: object

write_import()[source]#
run_import(user_import)[source]#
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

verify()[source]#
modify()[source]#
delete()[source]#
univention.testing.ucsschool.importusers.create_and_verify_users(school_name=None, nr_students=3, nr_teachers=3, nr_staff=3, nr_teacher_staff=3)[source]#
univention.testing.ucsschool.importusers.create_windows_profile_server(udm, ou, name)[source]#
univention.testing.ucsschool.importusers.create_home_server(udm, name)[source]#
univention.testing.ucsschool.importusers.import_users_basics()[source]#
univention.testing.ucsschool.importusers.get_mail_domain() str[source]#
class univention.testing.ucsschool.importusers.NonPrefixPerson(school, role, **kwargs)[source]#

Bases: Person

append_random_class(schools=None)[source]#

univention.testing.ucsschool.importusers_cli_v2 module#

exception univention.testing.ucsschool.importusers_cli_v2.ImportException[source]#

Bases: Exception

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.ConfigDict[source]#

Bases: dict

update_entry('foo:bar:baz', 'my value')[source]#
update_entry('foo:bar:ding', False) None
class univention.testing.ucsschool.importusers_cli_v2.PyHooks(hook_basedir=None)[source]#

Bases: object

create_hooks()[source]#
cleanup()[source]#
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')#
cleanup()[source]#
save_ldap_status()[source]#
diff_ldap_status()[source]#
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.

check_new_and_removed_users(exp_new, exp_removed)[source]#
fail(msg, returncode=1)[source]#

Print package versions, traceback and error message.

create_ous(schoolenv)[source]#
setup_testenv(schoolenv)[source]#
run()[source]#
test()[source]#
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'#
cleanup()[source]#
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’

check_for_non_empty_config(raise_exc=True)[source]#
check_for_non_empty_pyhooks(raise_exc=True)[source]#
run_import(args, fail_on_error=True, fail_on_preexisting_config=True, fail_on_preexisting_pyhook=True)[source]#
class univention.testing.ucsschool.importusers_cli_v2.UniqueObjectTester[source]#

Bases: CLI_Import_v2_Tester

cleanup()[source]#
check_unique_obj(obj_name, prefix, next_num)[source]#

check if history object exists

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:
  • ou_dn (str) – DN of OU in which to store the group

  • allowed_ou_names (list) – list of OU names, none if None

  • roles (list) – list of user roles (staff, student…), all if None

  • user_dns (list) – list of DNs of users to add to group, none if None

Returns:

group_dn, group_name

Return type:

Tuple[str, str]

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:

ResourceRepresentation.UserImportJobResource

fail(msg, returncode=1, import_job=None)[source]#

Print import jobs logfile, then print package versions, traceback and error message.

class univention.testing.ucsschool.importusers_http.TempHttpApiConfig(config)[source]#

Bases: object

default_config_path = '/var/lib/ucs-school-import/configs/user_import_http-api.json'#

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: object

Contains 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]

define()[source]#

Define internet rule via UMCP

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

Parameters:
  • new_name (str)

  • new_type (str)

  • new_domains ([str])

  • new_wlan (bool)

  • new_priority (int [0,10])

remove()[source]#

removes internet rule via UMCP

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)

assign(school, groupName, groupType, default=False)[source]#

Assign internet rule via UMCP

Parameters:
  • school (str) – name of the ou

  • groupName (str) – name of the group or class

  • groupType (str) – ‘workgroup’ or ‘class’

  • default (bool) – if the group is assigned to default values

allRules()[source]#

Get all defined rules via UMCP

Returns:

[str] list of rules names

class univention.testing.ucsschool.internetrule.Check(school, groupRuleCouples, connection=None, ucr=None)[source]#

Bases: object

Contains the needed functuality for checks related to internet rules within groups/classes.

Parameters:
  • school (str) – name of the ou

  • groupRuleCouples (tuple(str,str)) – couples of groups and rules assigned to them

  • connection (UMC connection object)

  • ucr (UCR object)

checkRules()[source]#

Check if the assigned internet rules are correct UMCP

checkUcr()[source]#

Check ucr variables for groups/ classes internet rules

univention.testing.ucsschool.klasse module#

class univention.testing.ucsschool.klasse.Klasse(school, connection=None, ucr=None, name=None, users=None, description=None)[source]#

Bases: object

Contains the needed functionality for classes in an already created OU, By default they are randomly formed except the OU, should be provided

Parameters:
  • school (str) – name of the ou

  • connection (UMC connection object)

  • ucr (UCR object)

  • name (str) – name of the class to be created later

  • description (str) – description of the class to be created later

create()[source]#

Creates object class

query()[source]#

get the list of existing classes in the school

check_query(classes_names)[source]#
dn()[source]#
property share_dn#
get()[source]#

Get class

check_get()[source]#
remove()[source]#

Remove class

edit(new_attributes)[source]#

Edit object class

check_existence(should_exist)[source]#
verify()[source]#

univention.testing.ucsschool.radius module#

univention.testing.ucsschool.radius.write_peap_config_file(conf_file, username, password)[source]#
univention.testing.ucsschool.radius.peap_auth(username, password, radius_secret)[source]#
univention.testing.ucsschool.radius.test_peap_auth(username, password, radius_secret, should_succeed=True)[source]#

univention.testing.ucsschool.randomdomain module#

class univention.testing.ucsschool.randomdomain.RandomDomain[source]#

Bases: object

Generates random internet domain names

getDomainList(count)[source]#

Generate list of domains names

Parameters:

count (int) – number of wanted domains

Returns:

[str] domains list

univention.testing.ucsschool.school module#

univention.testing.ucsschool.school.create_dc_slave(udm, school=None)[source]#
class univention.testing.ucsschool.school.School(display_name=None, name=None, dc_name=None, ucr=None, connection=None)[source]#

Bases: object

Contains the needed functuality for schools in the UMC module schoolwizards/schools. By default they are randomly formed.

Parameters:
  • connection (UMC connection object)

  • ucr (UCR object)

  • name (str) – name of the school to be created later

  • display_name (str) – display_name of the school to be created later

create()[source]#

Creates object school

get()[source]#

get the list of existing schools in the school

check_get(attrs)[source]#
query()[source]#

get the list of existing schools in the school

check_query(names)[source]#
dn()[source]#
remove()[source]#

Remove school

edit(new_attributes)[source]#

Edit object school

verify_ldap(should_exist)[source]#
verify_ou(ou, dc, ucr, homesharefileserver, classsharefileserver, dc_administrative, must_exist)[source]#

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

dn()[source]#
add(should_pass=True)[source]#
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.

verify_ldap(must_exist=True)[source]#
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.

query()[source]#

Get all school rooms via UMCP

Returns:

[str] list of school rooms names

check_query(rooms)[source]#
put(new_attributes)[source]#

Modify school room via UMCP

with no args passed this only reset the school room properties

Parameters:

new_attributes (dict)

check_put(new_attributes)[source]#
remove()[source]#

removes school room via UMCP

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: object

pycurl simple class implementation

Parameters:
  • proxy (str) – proxy for the http requests

  • username (str) – to use for http requests

  • password (str) – password for the user provided

  • bFollowLocation (bool)

  • maxReDirs (int)

  • connectTimeout (int)

  • port (int)

  • auth (int) – authentication type

cookies()[source]#
getPage(url, bVerbose=False, postData=None, encoding='UTF-8')[source]#

Gets a http page this method keep trying to fetch the page for 60secs then stops raising and exception if not succeeded.

Parameters:
  • url (str) – url

  • bVerbose (bool) – if verbose

  • postData

Returns:

html page

httpCode()[source]#

HTTP status code

Returns:

int - http_status_code

response(url)[source]#

HTTP status code

Parameters:

url (str) – url

Returns:

int - HTTP status code

close()[source]#

Close the curl connection

univention.testing.ucsschool.test_samba4 module#

class univention.testing.ucsschool.test_samba4.TestSamba4[source]#

Bases: object

Test class constructor

return_code_result_skip()[source]#

Stops the test returning the code 77 (RESULT_SKIP).

remove_samba_warnings(input_str)[source]#

Removes the Samba Warning/Note from the given input_str.

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.

sed_for_key(input, key)[source]#

Runs sed on given ‘input’ 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.

get_samba_sam_ldb_path()[source]#

Returns the ‘sam.ldb’ path using samba conf or defaults.

get_ucr_test_credentials()[source]#

Loads the UCR to get credentials for the test.

create_umc_connection_authenticate()[source]#

Creates UMC connection and authenticates to Primary Directory Node with the test user credentials.

delete_samba_gpo()[source]#

Deletes the Group Policy Object using the ‘samba-tool gpo del’.

univention.testing.ucsschool.ucs_test_school module#

API for testing UCS@school and cleaning up after performed tests

univention.testing.ucsschool.ucs_test_school.syntax_date2_dateformat(userexpirydate)[source]#
univention.testing.ucsschool.ucs_test_school.udm_formula_for_shadowExpire(userexpirydate)[source]#
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 in add_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.

univention.testing.ucsschool.ucs_test_school.get_ucsschool_logger() Logger[source]#
exception univention.testing.ucsschool.ucs_test_school.SchoolError[source]#

Bases: Exception

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.Bunch(**kwds)[source]#

Bases: object

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_dcs_from_global_groups(ou_name: str) None[source]#

Remove DCs from cn=DC-Edukativnetz etc.

remove_ucsschool_role_from_dcs(ou_name: str) None[source]#

Remove ucschoolRole on DCs (only in case of singleserver and name_edudc != ucr[“hostname”])

cleanup_default_containers(ou_name: str) None[source]#
classmethod check_name_edudc(name_edudc)[source]#
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()

cleanup_old_template_ous() None[source]#
cloned_ou(ou_name: str | None = None) Tuple[str, str][source]#
get_district(ou_name)[source]#
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.

get_workinggroup_dn(ou_name, group_name)[source]#

Return the DN of the specified working group.

get_workinggroup_share_dn(ou_name, group_name)[source]#

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_exam_student(*args, **kwargs)[source]#

NOT FUNCTIONAL!

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

create_windows()[source]#
create_mac()[source]#
create_ip_managed_client()[source]#
create_school_dc_slave()[source]#
delete_test_ous()[source]#
classmethod load_test_ous()[source]#
classmethod store_test_ous()[source]#
static get_ldap_status(lo, base='')[source]#
static diff_ldap_status(lo, old_ldap_status, base='')[source]#
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_School[source]#

Bases: object

class univention.testing.ucsschool.ucs_test_school.AutoMultiSchoolEnv[source]#

Bases: UCSTestSchool

create_multi_env_global_objects()[source]#
create_multi_env_school_objects()[source]#
class univention.testing.ucsschool.ucs_test_school.OUCloner(lo: LoType)[source]#

Bases: object

Create 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`.

pre_clone(ori_ou: str, new_ou: str) str[source]#
post_clone(ori_ou: str, new_ou: str) None[source]#
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.

get_max_rid() Tuple[str, int][source]#

Find the highest Samba RID in the domain.

get_max_gid_uid() Tuple[int, int][source]#

Find the highest gidNumber and uidNumber in the domain.

new_username(old_username: str, ori_ou: str, new_ou: str) str[source]#
new_computer_name(old_name: str, ori_ou: str, new_ou: str) str[source]#
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().

clone_ou_objects(ori_ou: str, new_ou: str) None[source]#

Clone the LDAP nodes below ou=$ori_ou,$ldap_base to ou=$new_ou,$ldap_base.

update_group_members(ori_ou: str, new_ou: str) None[source]#
clone_global_groups(ori_ou: str, new_ou: str) None[source]#
update_global_groups(ori_ou: str, new_ou: str) None[source]#

Add DCs and member servers to global groups.

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: Person

Contains 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

append_random_groups()[source]#
create()[source]#

Creates object user

get() Dict[str, Any][source]#

Get user

check_get(expected_attrs=None)[source]#
property ucsschool_roles#
type_name()[source]#
query()[source]#

get the list of existing users in the school

check_query(users_dn)[source]#
remove(remove_from_school=None)[source]#

Remove user

edit(new_attributes)[source]#

Edit object user

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: object

Contains the needed functionality for workgroups in an already created OU, By default they are randomly formed except the OU, should be provided

Parameters:
  • school (str) – name of the ou

  • connection (UMC connection object)

  • ucr (UCR object)

  • name (str) – name of the class to be created later

  • description (str) – description of the class to be created later

  • members ([str=memberdn]) – list of dns of members

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

remove(options=None)[source]#

Removing a Workgroup from ldap

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)

deactivate_email()[source]#

Deactivates the email address for the workgroup via UMC

set_members(new_members, options=None)[source]#

Set members for workgroup

Parameters:

new_members (list) – list of the new members

verify_ldap_attributes()[source]#

checking group attributes in ldap

verify_exists(group_should_exist, share_should_exist)[source]#

check for group and file share objects existance in ldap

dn()[source]#