univention.testing package#
Subpackages#
- univention.testing.browser package
- Submodules
- univention.testing.browser.appcenter module
- univention.testing.browser.generic_udm_module module
- univention.testing.browser.ldap_directory module
- univention.testing.browser.lib module
UCSLanguageInteractionsUMCBrowserTestUMCBrowserTest.langUMCBrowserTest.set_language()UMCBrowserTest.base_urlUMCBrowserTest.ldap_baseUMCBrowserTest.domainnameUMCBrowserTest.check_for_no_module_available_popup()UMCBrowserTest.login()UMCBrowserTest.end_umc_session()UMCBrowserTest.logout()UMCBrowserTest.systemd_restart_service()UMCBrowserTest.restart_umc()
- univention.testing.browser.packagemanagement module
PackageActionPackageManagementPackageManagement.navigate()PackageManagement.find_small_package()PackageManagement.search_for_package()PackageManagement.do_package_action()PackageManagement.handle_confirmation_dialog()PackageManagement.handle_action_dialog()PackageManagement.install_package()PackageManagement.uninstall_package()PackageManagement.verify_package_status()
- univention.testing.browser.policies module
- univention.testing.browser.portal module
- univention.testing.browser.process_overview module
- univention.testing.browser.selfservice module
- univention.testing.browser.sidemenu module
- univention.testing.browser.suggestion module
- univention.testing.browser.systemdiagnostics module
- univention.testing.browser.udm_users module
- univention.testing.browser.univentionconfigurationregistry module
- univention.testing.format package
- univention.testing.pytest_univention_playwright package
check_for_backtrace()print_path_in_jenkins()save_screenshot()save_trace()- Submodules
- univention.testing.pytest_univention_playwright.fixtures module
suppress_notifications()pytest_runtest_makereport()ucs_browser_context_args()ucs_browser_type_launch_args()browser_context_args()browser_type_launch_args()udm_module_scope()ucr_module()user_module()side_menu_license()side_menu_user()self_service()ldap_directory()kill_univention_management_console_module()kill_module_processes_module()kill_module_processes()setup_browser_context()context_module_scope()umc_browser_test_module()umc_browser_test()teardown_umc_browser_test()app_center_cache()
- univention.testing.selenium package
UMCSeleniumTestUMCSeleniumTest.BROWSERSUMCSeleniumTest.crop_screenshot_to_element()UMCSeleniumTest.do_login()UMCSeleniumTest.end_umc_session()UMCSeleniumTest.notifications_visible()UMCSeleniumTest.open_module()UMCSeleniumTest.open_traceback()UMCSeleniumTest.press_notifications_button()UMCSeleniumTest.restart_umc()UMCSeleniumTest.save_browser_log()UMCSeleniumTest.save_screenshot()UMCSeleniumTest.search_module()UMCSeleniumTest.set_viewport_size()UMCSeleniumTest.show_notifications()
- Submodules
- univention.testing.selenium.appcenter module
- univention.testing.selenium.base module
UMCSeleniumTestUMCSeleniumTest.BROWSERSUMCSeleniumTest.restart_umc()UMCSeleniumTest.set_viewport_size()UMCSeleniumTest.save_screenshot()UMCSeleniumTest.open_traceback()UMCSeleniumTest.crop_screenshot_to_element()UMCSeleniumTest.save_browser_log()UMCSeleniumTest.show_notifications()UMCSeleniumTest.notifications_visible()UMCSeleniumTest.press_notifications_button()UMCSeleniumTest.do_login()UMCSeleniumTest.end_umc_session()UMCSeleniumTest.open_module()UMCSeleniumTest.search_module()
- univention.testing.selenium.checks_and_waits module
ChecksAndWaitsChecksAndWaits.wait_for_text()ChecksAndWaits.wait_for_any_text_in_list()ChecksAndWaits.wait_for_text_to_disappear()ChecksAndWaits.wait_for_button()ChecksAndWaits.wait_until_all_dialogues_closed()ChecksAndWaits.wait_until_all_standby_animations_disappeared()ChecksAndWaits.wait_until_standby_animation_appears()ChecksAndWaits.wait_until_standby_animation_appears_and_disappears()ChecksAndWaits.wait_until_progress_bar_finishes()ChecksAndWaits.wait_until_element_visible()ChecksAndWaits.wait_until()ChecksAndWaits.get_gallery_items()ChecksAndWaits.get_all_visible_elements()ChecksAndWaits.elements_invisible()ChecksAndWaits.elements_visible()ChecksAndWaits.wait_for_element_by_css_selector()
- univention.testing.selenium.interactions module
InteractionsInteractions.click_text()Interactions.click_checkbox_of_grid_entry()Interactions.click_checkbox_of_dojox_grid_entry()Interactions.click_grid_entry()Interactions.click_tree_entry()Interactions.click_button()Interactions.click_buttons()Interactions.click_search_button()Interactions.click_tile()Interactions.click_tile_menu_icon()Interactions.click_tab()Interactions.open_side_menu()Interactions.close_side_menu()Interactions.click_side_menu_entry()Interactions.click_side_menu_back()Interactions.click_element()Interactions.enter_input()Interactions.enter_input_combobox()Interactions.enter_input_date()Interactions.submit_input()Interactions.get_input()Interactions.get_all_enabled_elements()Interactions.upload_image()Interactions.drag_and_drop()Interactions.drag_and_drop_by_offset()
- univention.testing.selenium.udm module
- univention.testing.selenium.utils module
- univention.testing.ucsschool package
- Submodules
- univention.testing.ucsschool.acl module
run_commands()CreateContextManagerCreateGroupInContainerCreateDCSlaveInContainerAclAcl.assert_acl()Acl.assert_base_dn()Acl.assert_student()Acl.assert_room()Acl.assert_teacher_group()Acl.assert_student_group()Acl.assert_share_object_access()Acl.assert_shares()Acl.assert_temps()Acl.assert_gid_temps()Acl.assert_ou()Acl.assert_global_containers()Acl.assert_computers()Acl.assert_user()Acl.assert_dhcp()Acl.assert_member_server()
- univention.testing.ucsschool.computer module
- univention.testing.ucsschool.computerroom module
CmdCheckFailretry_cmd()RoomRoom.get_room_user()Room.check_room_user()Room.aquire_room()Room.checK_room_aquire()Room.get_room_computers()Room.check_room_computers()Room.set_room_settings()Room.get_room_settings()Room.check_room_settings()Room.get_internetRules()Room.check_internetRules()Room.check_atjobs()Room.check_displayTime()Room.test_time_settings()Room.check_home_read()Room.check_home_write()Room.check_marktplatz_read()Room.check_marktplatz_write()Room.check_share_access()Room.check_share_behavior()Room.test_share_access_settings()Room.check_smb_print()Room.check_print_behavior()Room.test_printMode_settings()Room.checK_internetrules()Room.test_internetrules_settings()Room.test_settings()Room.check_behavior()
get_banpage()clean_folder()run_commands()add_printer()remove_printer()set_windows_pc_password()UmcComputercreate_homedirs()check_change_permissions()check_share_read()check_share_write()
- univention.testing.ucsschool.conftest module
UCSSchoolTypeGroupTypeShareTypeUserTypemodel_ldap_object_classes()model_school_object_class()model_ucsschool_roles()model_udm_module()model_ldap_container()user_groups()random_int()random_username()ucr()fqdn()admin_username()admin_password()machine_account_dn()machine_password()schoolenv()create_ou()lo()udm_session()create_import_user()get_import_user()mail_domain()ucr_domainname()ucr_hostname()ucr_is_singlemaster()ucr_ldap_base()user_ldap_attributes()user_school_attributes()workgroup_ldap_attributes()workgroup_school_attributes()workgroup_share_ldap_attributes()workgroup_share_school_attributes()random_logger()restart_services()schedule_restart_services()restart_umc()schedule_restart_umc()stop_module_process()copy_file()check_pdfprinter_spool_permissions()list_pdfprinter_jobs()send_pdfprinter_job()
- univention.testing.ucsschool.csv_test_helper module
- univention.testing.ucsschool.distribution module
DistributionDistribution.filesDistribution.files_encodedDistribution.query()Distribution.get()Distribution.idir()Distribution.genData()Distribution.uploadFile()Distribution.add()Distribution.check_add()Distribution.put()Distribution.check_put()Distribution.put_fail()Distribution.distribute()Distribution.check_distribute()Distribution.collect()Distribution.check_collect()Distribution.remove()Distribution.check_remove()Distribution.checkFiles()Distribution.adopt()Distribution.check_adopt()Distribution.getUserFilesPath()
- univention.testing.ucsschool.exam module
get_dir_files()get_s4_rejected()check_s4_rejected()check_proof_uniqueMember()wait_replications_check_rejected_uniqueMember()ExamExam.UMC_SCHOOLEXAM_LOG_PATHExam.start()Exam.save()Exam.get()Exam.delete()Exam.finish()Exam.genData()Exam.uploadFile()Exam.get_internetRules()Exam.fetch_internetRule()Exam.get_schools()Exam.fetch_school()Exam.get_groups()Exam.fetch_groups()Exam.get_lessonEnd()Exam.fetch_lessonEnd()Exam.collect()Exam.check_collect()Exam.check_upload()Exam.check_distribute()
ExamSaml
- univention.testing.ucsschool.import_factory_test_classes module
- univention.testing.ucsschool.importgroups module
- univention.testing.ucsschool.importnetworks module
- univention.testing.ucsschool.importou module
DCNotFoundDCMembershipDCisMemberOfGroupDhcpdLDAPBaseDhcpServerLocationcreate_mail_domain()remove_ou()get_school_base()get_school_ou_from_dn()create_ou_cli()create_ou_python_api()move_domaincontroller_to_ou_cli()get_ou_base()create_and_verify_ou()verify_ou()check_group_membership()check_dhcp()verify_dc()parametrization_id_base64_decode()generate_import_ou_basics_test_data()import_ou_with_existing_dc()import_3_ou_in_a_row()import_ou_alter_dhcpd_base_flag()
- univention.testing.ucsschool.importprinters module
- univention.testing.ucsschool.importusers module
PersonPerson.make_dn()Person.homedirPerson.make_school_base()Person.append_random_groups()Person.set_mode_to_modify()Person.set_mode_to_delete()Person.set_active()Person.set_inactive()Person.is_active()Person.update()Person.move_school_classes()Person.map_to_dict()Person.get_csv_line()Person.append_random_class()Person.append_random_working_group()Person.is_student()Person.is_teacher()Person.is_staff()Person.is_teacher_staff()Person.expected_attributes()Person.get_samba_home_path_server()Person.get_profile_path_server()Person.rolesPerson.verify()Person.update_from_ldap()Person.set_random_birthday()
StudentTeacherStaffTeacherStaffImportFileUserImportcreate_and_verify_users()create_windows_profile_server()create_home_server()import_users_basics()get_mail_domain()NonPrefixPerson
- univention.testing.ucsschool.importusers_cli_v2 module
ImportExceptionTestFailedreset_notifier_restart_burst_limit()ConfigDictPyHooksImportTestbaseImportTestbase.ou_AImportTestbase.ou_BImportTestbase.ou_CImportTestbase.use_ou_cacheImportTestbase.all_rolesImportTestbase.cleanup()ImportTestbase.save_ldap_status()ImportTestbase.diff_ldap_status()ImportTestbase.pugre_timestamp_ldap2udm()ImportTestbase.pugre_timestamp_udm2ldap()ImportTestbase.check_new_and_removed_users()ImportTestbase.fail()ImportTestbase.create_ous()ImportTestbase.setup_testenv()ImportTestbase.run()ImportTestbase.test()ImportTestbase.wait_for_drs_replication_of_membership()
CLI_Import_v2_TesterCLI_Import_v2_Tester.ldap_date_formatCLI_Import_v2_Tester.udm_date_formatCLI_Import_v2_Tester.cleanup()CLI_Import_v2_Tester.create_config_json()CLI_Import_v2_Tester.create_csv_file()CLI_Import_v2_Tester.check_for_non_empty_config()CLI_Import_v2_Tester.check_for_non_empty_pyhooks()CLI_Import_v2_Tester.run_import()
UniqueObjectTester
- univention.testing.ucsschool.importusers_http module
- univention.testing.ucsschool.internetrule module
- univention.testing.ucsschool.klasse module
- univention.testing.ucsschool.radius module
- univention.testing.ucsschool.randomdomain module
- univention.testing.ucsschool.school module
- univention.testing.ucsschool.schoolroom module
- univention.testing.ucsschool.simplecurl module
- univention.testing.ucsschool.test_samba4 module
TestSamba4TestSamba4.return_code_result_skip()TestSamba4.remove_samba_warnings()TestSamba4.create_and_run_process()TestSamba4.start_stop_service()TestSamba4.dc_master_has_samba4()TestSamba4.is_a_school_branch_site()TestSamba4.grep_for_key()TestSamba4.sed_for_key()TestSamba4.get_udm_list_dcs()TestSamba4.get_udm_list_dc_slaves_with_samba4()TestSamba4.select_school_ou()TestSamba4.get_samba_sam_ldb_path()TestSamba4.get_ucr_test_credentials()TestSamba4.create_umc_connection_authenticate()TestSamba4.delete_samba_gpo()
- univention.testing.ucsschool.ucs_test_school module
syntax_date2_dateformat()udm_formula_for_shadowExpire()force_ucsschool_logger_colorized_if_has_tty()get_ucsschool_logger()SchoolErrorSchoolMissingOUSchoolLDAPErrorBunchUCSTestSchoolUCSTestSchool.ucrUCSTestSchool.LDAP_BASEUCSTestSchool.PATH_CMD_BASEUCSTestSchool.PATH_CMD_CREATE_OUUCSTestSchool.CN_STUDENTUCSTestSchool.CN_TEACHERSUCSTestSchool.CN_TEACHERS_STAFFUCSTestSchool.CN_ADMINSUCSTestSchool.CN_STAFFUCSTestSchool.open_ldap_connection()UCSTestSchool.cleanup()UCSTestSchool.cleanup_ou()UCSTestSchool.remove_dcs_from_global_groups()UCSTestSchool.remove_ucsschool_role_from_dcs()UCSTestSchool.cleanup_default_containers()UCSTestSchool.check_name_edudc()UCSTestSchool.create_ou()UCSTestSchool.create_multiple_ous()UCSTestSchool.cleanup_old_template_ous()UCSTestSchool.cloned_ou()UCSTestSchool.get_district()UCSTestSchool.get_ou_base_dn()UCSTestSchool.get_user_container()UCSTestSchool.get_workinggroup_dn()UCSTestSchool.get_workinggroup_share_dn()UCSTestSchool.create_teacher()UCSTestSchool.create_student()UCSTestSchool.create_exam_student()UCSTestSchool.create_staff()UCSTestSchool.create_teacher_and_staff()UCSTestSchool.create_user()UCSTestSchool.create_school_admin()UCSTestSchool.create_domain_admin()UCSTestSchool.create_global_user()UCSTestSchool.create_school_class()UCSTestSchool.create_workgroup()UCSTestSchool.create_computerroom()UCSTestSchool.create_windows()UCSTestSchool.create_mac()UCSTestSchool.create_ip_managed_client()UCSTestSchool.create_school_dc_slave()UCSTestSchool.delete_test_ous()UCSTestSchool.load_test_ous()UCSTestSchool.store_test_ous()UCSTestSchool.get_ldap_status()UCSTestSchool.diff_ldap_status()
NameDnObjAutoMultiSchoolEnv_GenericAutoMultiSchoolEnv_SchoolAutoMultiSchoolEnvOUClonerOUCloner.clone_ou()OUCloner.pre_clone()OUCloner.post_clone()OUCloner.replace_case_sesitive_and_lower()OUCloner.get_max_rid()OUCloner.get_max_gid_uid()OUCloner.new_username()OUCloner.new_computer_name()OUCloner.clone_object()OUCloner.clone_ou_objects()OUCloner.update_group_members()OUCloner.clone_global_groups()OUCloner.update_global_groups()
- univention.testing.ucsschool.user module
- univention.testing.ucsschool.workgroup module
Submodules#
univention.testing.active_directory module#
Library for AD/Samba connections.
Includes objects and functionality for: * Users * Shares * Domain password settings
The library uses the CLI tools samba-tool and smbclient as backend.
- exception univention.testing.active_directory.SambaToolException[source]#
Bases:
ActiveDirectoryException
- exception univention.testing.active_directory.SmbClientException[source]#
Bases:
ActiveDirectoryException
- exception univention.testing.active_directory.LogonFailureException[source]#
Bases:
ActiveDirectoryException
- exception univention.testing.active_directory.AccountLockedOutException[source]#
Bases:
ActiveDirectoryException
- exception univention.testing.active_directory.NotLockedOutException[source]#
Bases:
ActiveDirectoryException
- class univention.testing.active_directory.ActiveDirectorySettings(*, host: str | None = None, admin_username: str | None = None, admin_password: str | None = None, is_local_connect: bool = False)[source]#
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- class univention.testing.active_directory.DomainPasswordsettingsData(*, password_complexity: str | None = None, store_plaintext_passwords: str | None = None, password_history_length: int | None = None, minimum_password_length: int | None = None, minimum_password_age: int | None = None, maximum_password_age: int | None = None, account_lockout_duration: int | None = None, account_lockout_threshold: int | None = None, reset_account_lockout_after: int | None = None)[source]#
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- class univention.testing.active_directory.UserData(*, dn: str | None = None, name: str | None = None, password: str | None = None, bad_pwd_count: int | None = None, bad_password_time: int | None = None, lockout_time: int | None = None)[source]#
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- class univention.testing.active_directory.ActiveDirectory(settings: ActiveDirectorySettings)[source]#
Bases:
object
- class univention.testing.active_directory.SambaTool(settings: ActiveDirectorySettings)[source]#
Bases:
ActiveDirectoryAbstract base class for samba tool calls.
- class univention.testing.active_directory.SmbClient(settings: ActiveDirectorySettings)[source]#
Bases:
ActiveDirectoryAbstract base class for SMB client calls.
- class univention.testing.active_directory.DomainPasswordSettings(settings: ActiveDirectorySettings)[source]#
Bases:
SambaTool- set(domain_passwordsettings: DomainPasswordsettingsData)[source]#
- class univention.testing.active_directory.User(settings: ActiveDirectorySettings)[source]#
Bases:
SambaTool
Bases:
SmbClient
univention.testing.apptest module#
- class univention.testing.apptest.Session(display_num: str, base_url: str, screenshot_path: str, driver)[source]#
Bases:
object
- univention.testing.apptest.config() dict[str, str][source]#
Test wide Configuration aka UCR Used to get some defaults if not environment variables are given. But if UCR is not avaiable, returns an empty dict…
- univention.testing.apptest.udm(hostname: str, config, admin_username: str, admin_password: str)[source]#
A UDM instance (REST client)
- univention.testing.apptest.selenium_screenshot_path() str[source]#
Path where selenium should save screenshots
univention.testing.codes module#
Public interface for test resultes.
- class univention.testing.codes.Reason(value)[source]#
Bases:
Enum- UNKNOWN = (-1, 'E', 'Test failed', 'RED')#
- SKIP = (77, 'S', 'Test skipped', 'BLUE')#
- OKAY = (100, 'O', 'Test passed', 'GREEN')#
- FIXED_EXPECTED = (101, 'O', 'Test passed', 'GREEN')#
- FIXED_UNEXPECTED = (102, 'O', 'Test passed', 'GREEN')#
- FAIL = (110, 'F', 'Test failed', 'RED')#
- FAIL_UNEXPECTED = (111, 'F', 'Test failed', 'RED')#
- FAIL_TRANSIENT = (120, 'F', 'Test failed', 'RED')#
- FAIL_EXPECTED = (121, 'F', 'Test failed', 'RED')#
- UNAVAILABLE = (122, 'E', 'Test failed', 'RED')#
- IMMATURE = (130, 'S', 'Test failed', 'RED')#
- VERSION_MISMATCH = (131, 'S', 'Test skipped (wrong version)', 'BLUE')#
- VERSION_TOO_OLD = (132, 'S', 'Test skipped (version too old)', 'BLUE')#
- VERSION_TOO_NEW = (133, 'S', 'Test skipped (version too new)', 'BLUE')#
- ROLE_MISMATCH = (134, 'S', 'Test skipped (role mismatch)', 'BLUE')#
- JOIN = (135, 'S', 'Test skipped (system not joined)', 'BLUE')#
- JOINED = (136, 'S', 'Test skipped (system is joined)', 'BLUE')#
- INSTALL = (137, 'S', 'Test skipped (missing software)', 'BLUE')#
- INSTALLED = (138, 'S', 'Test skipped (conflicting software)', 'BLUE')#
- DANGER = (139, 'S', 'Test skipped (too dangerous)', 'BLUE')#
- INTERNAL = (140, 'E', 'Test failed', 'RED')#
- ABORT = (141, 'S', 'Test aborted', 'RED')#
- APP_MISMATCH = (142, 'S', 'Test skipped (app mismatch)', 'BLUE')#
- property color#
univention.testing.conftest module#
conftest plugin for pytest runner in ucs-test
univention.testing.connector_common module#
- univention.testing.connector_common.random_string(length: int = 10, alpha: bool = False, numeric: bool = False, charset: str = '', encoding: str = 'utf-8') str[source]#
- univention.testing.connector_common.random_bytestring(length: int = 10, alpha: bool = False, numeric: bool = False, charset: str = '') bytes[source]#
- univention.testing.connector_common.normalize_dn(dn: str) str[source]#
Normalize a given dn. This removes some escaping of special chars in the DNs. Note: The CON-LDAP returns DNs with escaping chars, OpenLDAP does not.
>>> normalize_dn(r"cn=peter\#,cn=groups") 'cn=peter#,cn=groups'
- class univention.testing.connector_common.TestUser(user, rename={}, container=None, selection=None)[source]#
Bases:
object
- class univention.testing.connector_common.TestGroup(group, rename={}, container=None)[source]#
Bases:
object
- class univention.testing.connector_common.TestObject(obj, rename={}, container=None)[source]#
Bases:
object
- class univention.testing.connector_common.NormalWindows[source]#
Bases:
TestObject
- class univention.testing.connector_common.NormalContainer[source]#
Bases:
TestObject
- class univention.testing.connector_common.NormalOU[source]#
Bases:
TestObject
- univention.testing.connector_common.map_udm_user_to_con(user)[source]#
Map a UDM user given as a dictionary of property:values mappings to a dictionary of attributes:values mappings as required by the CON-LDAP. Note: This expects the properties from the UDM users/user module and not OpenLDAP-attributes!.
- univention.testing.connector_common.map_udm_group_to_con(group)[source]#
Map a UDM group given as a dictionary of property:values mappings to a dictionary of attributes:values mappings as required by the CON-LDAP. Note: This expects the properties from the UDM groups/group module and not OpenLDAP-attributes!.
- univention.testing.connector_common.map_udm_windows_to_con(windows)[source]#
Map a UDM computers/windows given as a dictionary of property:values mappings to a dictionary of attributes:values mappings as required by the CON-LDAP. Note: This expects the properties from the UDM computers/windows module and not OpenLDAP-attributes!.
- univention.testing.connector_common.map_udm_container_to_con(container)[source]#
Map a UDM container/* given as a dictionary of property:values mappings to a dictionary of attributes:values mappings as required by the CON-LDAP. Note: This expects the properties from the UDM container/* module and not OpenLDAP-attributes!.
- univention.testing.connector_common.map_udm_ou_to_con(container)[source]#
Map a UDM container/* given as a dictionary of property:values mappings to a dictionary of attributes:values mappings as required by the CON-LDAP. Note: This expects the properties from the UDM container/* module and not OpenLDAP-attributes!.
- univention.testing.connector_common.create_udm_user(udm, con, user, wait_for_sync, verify=True)[source]#
- univention.testing.connector_common.delete_udm_user(udm, con, udm_user_dn, con_user_dn, wait_for_sync)[source]#
- univention.testing.connector_common.create_con_user(con, udm_user, wait_for_sync, basic_con_user=None)[source]#
- univention.testing.connector_common.delete_con_user(con, con_user_dn, udm_user_dn, wait_for_sync)[source]#
univention.testing.coverage module#
Code coverage measurement for ucs-test
- class univention.testing.coverage.Coverage(options: Namespace)[source]#
Bases:
object- COVERAGE_PTH = '/usr/lib/python3/dist-packages/ucstest-coverage.pth'#
- COVERAGE_PTH_CONTENT = 'import univention.testing.coverage; univention.testing.coverage.Coverage.startup()'#
- COVERAGE_DEBUG_PATH = '/tmp/ucs-test-coverage'#
- coverage = None#
- COVERAGE_DEBUG = False#
- start() None[source]#
Start measuring of coverage. Only called by ucs-test-framework once. Sets up the configuration.
- write_config_file() None[source]#
Write a Python .pth file which is invoked before any Python process
- restart_python_services() None[source]#
Restart currently running Python services, so that they start/stop measuring code
- stop() None[source]#
Stop coverage measuring. Only called by ucs-test-framework once. Stores the results.
- classmethod get_argument_group(parser: ArgumentParser) _ArgumentGroup[source]#
The option group for ucs-test-framework
univention.testing.data module#
Test case, environment, result and related classes.
- class univention.testing.data.TestCase(filename: str)[source]#
Bases:
objectTest case.
- logger = <Logger test.case (DEBUG)>#
- RE_NL = re.compile(b'[\\r\\n]+')#
- check(environment: TestEnvironment) list[Verdict][source]#
Check if the test case should run.
- pytest_check(environment: TestEnvironment) list[str][source]#
- run(result: TestResult) None[source]#
Run the test case and fill in result.
- class univention.testing.data.TestEnvironment(interactive: bool = True, logfile: str | None = None)[source]#
Bases:
objectTest environment for running test cases.
Handels system data, requirements checks, test output.
- logger = <Logger test.env (DEBUG)>#
- dump(stream: ~typing.IO[str] = <colorama.ansitowin32.StreamWrapper object>) None[source]#
Dump environment information.
- class univention.testing.data.TestFormatInterface(stream: ~typing.IO[str] = <colorama.ansitowin32.StreamWrapper object>)[source]#
Bases:
objectFormat UCS Test result.
- begin_run(environment: TestEnvironment, count: int = 1) None[source]#
Called before first test.
- end_test(result: TestResult) None[source]#
Called after each test.
- format(result: TestResult) None[source]#
Format single test.
- class univention.testing.data.TestResult(case: TestCase, environment: TestEnvironment)[source]#
Bases:
objectTest result from running a test case.
- dump(stream: ~typing.IO[str] = <colorama.ansitowin32.StreamWrapper object>) None[source]#
Dump test result data.
univention.testing.debian_package module#
- exception univention.testing.debian_package.BuildRuntimeError[source]#
Bases:
RuntimeError
- exception univention.testing.debian_package.InstallRuntimeError[source]#
Bases:
RuntimeError
- exception univention.testing.debian_package.UninstallRuntimeError[source]#
Bases:
RuntimeError
univention.testing.decorators module#
- class univention.testing.decorators.WaitForNonzeroResultOrTimeout(func: Callable[[...], Any], timeout: int = 90)[source]#
Bases:
object
univention.testing.errors module#
UCS Test errors.
univention.testing.fixtures_recyclebin module#
Common functions/fixtures for recyclebin tests.
Create a share for testing homeShare attributes
- univention.testing.fixtures_recyclebin.deleted_object_user_properties(ldap_base) SimpleNamespace[source]#
univention.testing.internal module#
Internal functions for test finding and setup.
- class univention.testing.internal.UCSVersion(ver: str | tuple[int, int, int, int])[source]#
Bases:
objectUCS version.
>>> UCSVersion("1.0") < UCSVersion("2.0") True >>> UCSVersion("1.0") < UCSVersion("1.0") False >>> UCSVersion("1.0") <= UCSVersion("1.0") True >>> UCSVersion("2.0") <= UCSVersion("1.0") False >>> UCSVersion("1.0") == UCSVersion("1.0") True >>> UCSVersion("1.0") == UCSVersion("2.0") False >>> UCSVersion("1.0") != UCSVersion("2.0") True >>> UCSVersion("1.0") != UCSVersion("1.0") False >>> UCSVersion("1.0") >= UCSVersion("1.0") True >>> UCSVersion("1.0") >= UCSVersion("2.0") False >>> UCSVersion("2.0") > UCSVersion("1.0") True >>> UCSVersion("1.0") > UCSVersion("1.0") False >>> UCSVersion("1.0") == UCSVersion((1, 0, INF, INF)) True >>> UCSVersion("1.0-0-0") == UCSVersion((1, 0, 0, 0)) True >>> UCSVersion("") Traceback (most recent call last): ... ValueError: Version does not match: "" >>> UCSVersion("0") Traceback (most recent call last): ... ValueError: Version does not match: "0" >>> UCSVersion("1") Traceback (most recent call last): ... ValueError: Version does not match: "1" >>> UCSVersion("1.2") UCSVersion('=1.2') >>> UCSVersion("1.2-3") UCSVersion('=1.2-3') >>> UCSVersion("1.2-3-4") UCSVersion('=1.2-3-4') >>> UCSVersion("1.2-3-4-5") Traceback (most recent call last): ... ValueError: Version does not match: "1.2-3-4-5" >>> UCSVersion(None) Traceback (most recent call last): ... TypeError: None >>> UCSVersion(1) Traceback (most recent call last): ... TypeError: 1 >>> UCSVersion(1.5) Traceback (most recent call last): ... TypeError: 1.5
- RE_VERSION = re.compile('^(<|<<|<=|=|==|>=|>|>>)?([1-9][0-9]*)\\.([0-9]+)(?:-([0-9]*)(?:-([0-9]+))?)?$')#
- match(other: Self) bool[source]#
Check if other matches the criterion. >>> UCSVersion(‘>1.2-3’).match(UCSVersion(‘1.2-4’)) True >>> UCSVersion(‘>1.2-3’).match(UCSVersion(‘1.2-3-4’)) False >>> UCSVersion(‘>1.2-3-5’).match(UCSVersion(‘1.2-3-4’)) False >>> UCSVersion(‘>=1.2-3’).match(UCSVersion(‘1.2-3-4’)) True
- univention.testing.internal.get_sections() dict[str, str][source]#
Return dictionary section-name -> section-directory.
univention.testing.ldap_glue module#
- univention.testing.ldap_glue.get_rdn(dn)[source]#
>>> get_rdn(r'a=b\,c+d=e,f=g+h=i\,j') 'a=b\\,c+d=e' >>> get_rdn(r'a=b') 'a=b'
- univention.testing.ldap_glue.get_parent_dn(dn)[source]#
>>> get_parent_dn(r'a=b\,c+d=e,f=g+h=i\,j') 'f=g+h=i\\,j' >>> get_parent_dn(r'a=b')
- class univention.testing.ldap_glue.LDAPConnection(no_starttls=False)[source]#
Bases:
objecthelper functions to modify LDAP-objects intended as glue for shell-scripts
- class univention.testing.ldap_glue.ADConnection(configbase='connector')[source]#
Bases:
LDAPConnectionhelper functions to modify AD-objects
- createuser(username, position=None, **attributes)[source]#
Create a AD user with attributes as given by the keyword-args attributes. The created user will be populated with some defaults if not otherwise set.
Returns the dn of the created user.
- group_create(groupname, position=None, **attributes)[source]#
Create a AD group with attributes as given by the keyword-args attributes. The created group will be populated with some defaults if not otherwise set.
Returns the dn of the created group.
- windows_create(name, position=None, **attributes)[source]#
Create a AD windows with attributes as given by the keyword-args attributes. The created windows will be populated with some defaults if not otherwise set.
Returns the dn of the created windows.
- verify_object(dn, expected_attributes)[source]#
Verify an object exists with the given dn and attributes in the AD-LDAP. Setting expected_attributes to None requires the object to not exist. expected_attributes is a dictionary of attribute:list-of-values.
This will throw an AssertionError in case of a mismatch.
univention.testing.ldif module#
This program compares LDAP host entries with a local comparative ldif file. All differences will be displayed at the console.
- class univention.testing.ldif.Ldif(src: Iterable[bytes], exclude: set[str] = {'createTimestamp', 'creatorsName', 'entryCSN', 'entryUUID', 'modifiersName', 'modifyTimestamp', 'structuralObjectClass'})[source]#
Bases:
objectAbstract class for LDIF source.
- RE = re.compile('\n ^\n (?:\n ([0-9]+(?:\\.[0-9]+)*) # ldap-oid\n |([A-Za-z][\\-0-9A-Za-z]*) # AttributeType\n ) # AttributeDescription\n (;[\\-0-9A-Za-z]+)* # OP, re.VERBOSE)#
- OPERATIONAL = {'createTimestamp', 'creatorsName', 'entryCSN', 'entryUUID', 'modifiersName', 'modifyTimestamp', 'structuralObjectClass'}#
- split(line: str) tuple[str, str][source]#
Split attribute and value. Options are stripped. Base64 encoded values are decoded.
- Parameters:
line (str) – The line to split.
- Returns:
A tuple (name, value).
>>> Ldif(b'').split('a:') == ('a', u'') True >>> Ldif(b'').split('a: b') == ('a', u'b') True >>> Ldif(b'').split('a:: YWFh') == ('a', u'aaa') True >>> Ldif(b'').split('a;b:c') == ('a', u'c') True >>> Ldif(b'').split('a;b;c::YWFh') == ('a', u'aaa') True >>> Ldif(b'').split('a:: ACB/') == ('a', u'\\u0000 \\u007f') True
- class univention.testing.ldif.LdifFile(filename: str)[source]#
Bases:
objectLDIF source from local file.
- class univention.testing.ldif.LdifSlapcat[source]#
Bases:
objectLDIF source from local LDAP.
- wait_for_data(proc: Popen) None[source]#
Wait for the remote process to send data.
>>> LdifSlapcat().wait_for_data(subprocess.Popen(('echo',), stdout=subprocess.PIPE)) >>> LdifSlapcat().wait_for_data(subprocess.Popen(('false',), stdout=subprocess.PIPE)) Traceback (most recent call last): ... SlapError: ('Error executing', ['slapcat', '-d0'], 1)
- class univention.testing.ldif.LdifSsh(hostname: str, ssh: str = 'ssh')[source]#
Bases:
LdifSlapcatLDIF source from remote LDAP.
- univention.testing.ldif.stream2object(ldif: Ldif) dict[str, dict[str, list[str]]][source]#
Convert LDIF stream to dictionary of objects.
- Parameters:
ldif (Ldif) – A LDIF stream.
- Returns:
A dictionary mapping distinguished names to a dictionary of key-values.
>>> stream2object([{'dn': ['dc=test']}]) {'dc=test': {}}
- univention.testing.ldif.sort_dn(dname: str) tuple[tuple[str, ...], ...][source]#
Sort by reversed dn.
- Parameters:
dname (str) – distinguished name.
- Returns:
tuple of relative distinguised names.
>>> sort_dn('a=1') (('a=1',),) >>> sort_dn('b=1,a=1') (('a=1',), ('b=1',)) >>> sort_dn('b=2+a=1') (('a=1', 'b=2'),)
- univention.testing.ldif.compare_ldif(lldif: Ldif, rldif: Ldif, options: Values) int[source]#
Compare two LDIF files.
- Parameters:
ldif1 – first LDIF to compare.
ldif2 – second LDIF to compare.
options – command line options.
- univention.testing.ldif.compare_keys(ldata: dict[str, list[str]], rdata: dict[str, list[str]]) Iterator[tuple[Literal[-1, 0, 1], str, str]][source]#
Compare and return attributes of two LDAP objects.
- Parameters:
- Returns:
an iterator of differences as 3-tuples (comparison, key, value).
>>> list(compare_keys({}, {})) [] >>> list(compare_keys({'a': ['1']}, {})) [(-1, 'a', '1')] >>> list(compare_keys({}, {'a': ['1']})) [(1, 'a', '1')] >>> list(compare_keys({'a': ['1']}, {'a': ['1']})) [(0, 'a', '1')] >>> list(compare_keys({'a': ['1']}, {'a': ['2']})) [(1, 'a', '2'), (-1, 'a', '1')]
- univention.testing.ldif.compare_values(attr: str, lvalues: list[str], rvalues: list[str]) Iterator[tuple[Literal[-1, 0, 1], str, str]][source]#
Compare and return values of two multi-valued LDAP attributes.
- Parameters:
- Returns:
an iterator of differences as 3-tuples (comparison, key, value), where comparison<0 if key is missing in lvalues, comparison>0 if key is missing in rvalues, otherwise 0.
>>> list(compare_values('attr', [], [])) [] >>> list(compare_values('attr', ['1', '2'], ['2', '3'])) [(1, 'attr', '3'), (0, 'attr', '2'), (-1, 'attr', '1')]
- univention.testing.ldif.parse_args() tuple[LdifSource, LdifSource, Values][source]#
Parse command line arguments.
univention.testing.license_client module#
A tool to obtain licenses for the UCS test environments.
- exception univention.testing.license_client.CredentialsMissing[source]#
Bases:
ExceptionA custom exception to be raised when a ‘license.secret’ file is not found
- class univention.testing.license_client.ShopParser(log: Logger)[source]#
Bases:
HTMLParserInitialize and reset this instance.
If convert_charrefs is True (the default), all character references are automatically converted to the corresponding Unicode characters.
- class univention.testing.license_client.TestLicenseClient(parser: ArgumentParser | None = None)[source]#
Bases:
objectClass constructor for the test license client and HTMLParser
- create_connection() None[source]#
Creates a HTTPS connection instance on a default port (443) to the ‘self.license_server_url’
- close_connection() None[source]#
Closes the license server connection if the connection instance was created
- get_server_password(secret_file: str = '/etc/license.secret') None[source]#
Opens and reads the ‘secret_file’. Saves the result to a ‘self.server_password’
- get_cookie() None[source]#
Makes a POST request with ‘self.server_username’ and ‘self.server_password’ into login forms and saves the cookie from the response received.
- make_post_request(url: str, body: str, headers: dict[str, str]) HTTPResponse[source]#
Makes a POST request with the given ‘url’, ‘body’, ‘headers’ and returns the response
- make_get_request(url: str, headers: dict[str, str]) HTTPResponse[source]#
Makes a GET request with the given ‘url’, ‘headers’ and returns the response
- get_the_license(body: str) None[source]#
Processes the given ‘body’ with HTMLParser to find the link to a created license file and downloads the license after.
- order_a_license() str[source]#
Makes a POST request with encoded ‘self.license_params’ as a body to order a new license. Returns the response body.
- get_body(response: HTTPResponse) str[source]#
- download_license_file(link_to_license: str) None[source]#
Downloads the license located at filename and saves it to the file ‘self.license_filename’
- update_with_parsed_args(args: dict[str, Any]) None[source]#
Updates the loglevel and license filename settings if given among the parsed arguments. Merges parsed data with default license parameters.
- process_cmd_arguments() None[source]#
Populates self.parser class with positional and optional arguments and processes the user input, checks the date format and than merges it with the default values in the ‘self.license_params’ dictionary
- main(base_dn: str = '', end_date: str = '', server_url: str = '', license_file: str = '') None[source]#
A method to order and download a test license from the license server. ‘base_dn’ and ‘end_date’ should be provided if argument parser is not used. ‘server_url’ is an optional argument for the license shop server. ‘license_file’ is an optional argument for the license filename.
univention.testing.mail module#
- class univention.testing.mail.MailSinkGuard[source]#
Bases:
objectThis class is a simple context manager that stops all attached mail sinks if the context is left.
- with MaiLSinkGuard() as msg:
sink = MailSink(……) msg.add(sink) ….use sink….
- class univention.testing.mail.MailSink(address: str, port: int, filename: str | None = None, target_dir: str | None = None, fqdn: str | None = None)[source]#
Bases:
objectThis class starts an SMTP sink on the specified address/port. Each incoming mail will be written to a single file if target_dir is used. To write all incoming mails into one file, use filename.
>>> ms = MailSink('127.0.0.1', 12345, target_dir='/tmp/') >>> ms.start() <do some stuff> >>> ms.stop()
>>> ms = MailSink('127.0.0.1', 12345, filename='/tmp/sinkfile.eml') >>> ms.start() <do some stuff> >>> ms.stop()
>>> with MailSink('127.0.0.1', 12345, filename='/tmp/sinkfile.eml') as ms: >>> <do some stuff>
univention.testing.network module#
Networking helper that may establish connection redirection for testing network connections/configuration of different programs (e.g. postfix).
WARNING: The networking helper will install special iptables rules that may completely break routing from/to the test system. Especially if the test script does not clean up in error cases!
- exception univention.testing.network.UCSTestNetworkCannotDetermineExternalAddress[source]#
Bases:
UCSTestNetwork
- exception univention.testing.network.UCSTestNetworkCmdFailed[source]#
Bases:
UCSTestNetwork
- exception univention.testing.network.UCSTestNetworkUnknownLoop[source]#
Bases:
UCSTestNetwork
- exception univention.testing.network.UCSTestNetworkUnknownRedirection[source]#
Bases:
UCSTestNetwork
- exception univention.testing.network.UCSTestNetworkNoWithStatement[source]#
Bases:
UCSTestNetwork- message = 'NetworkRedirector has to be used via with statement!'#
- exception univention.testing.network.UCSTestNetworkOnlyOneLoopSupported[source]#
Bases:
UCSTestNetwork- message = 'NetworkRedirector does support only ONE loop at a time!'#
- class univention.testing.network.NetworkRedirector[source]#
Bases:
objectThe NetworkRedirector is able to establish port/connection redirections via iptables. It has to be used via the with-statement.
>>> with NetworkRedirector() as nethelper: >>> nethelper.add_loop('1.2.3.4', '4.3.2.1') >>> nethelper.add_redirection('1.1.1.1', 25, 60025) >>> ... >>> # the following lines are optional! NetworkRedirector does automatic cleanup! >>> nethelper.remove_loop('1.2.3.4', '4.3.2.1') >>> nethelper.remove_redirection('1.1.1.1', 25, 60025)
It is also possible to redirect all traffic to a specific port. The trailing “/0” is important, otherwise the redirection won’t work!
>>> nethelper.add_redirection('0.0.0.0/0', 25, 60025)
- BIN_IPTABLES = '/sbin/iptables'#
- CMD_LIST_LOOP = [['/sbin/iptables', '-t', 'mangle', '%(action)s', 'OUTPUT', '-d', '%(addr1)s', '-j', 'TOS', '--set-tos', '0x04'], ['/sbin/iptables', '-t', 'nat', '%(action)s', 'OUTPUT', '-d', '%(addr1)s', '-j', 'DNAT', '--to-destination', '%(local_external_addr)s'], ['/sbin/iptables', '-t', 'nat', '%(action)s', 'POSTROUTING', '-m', 'tos', '--tos', '0x04', '-j', 'SNAT', '--to-source', '%(addr2)s'], ['/sbin/iptables', '-t', 'mangle', '%(action)s', 'OUTPUT', '-d', '%(addr2)s', '-j', 'TOS', '--set-tos', '0x08'], ['/sbin/iptables', '-t', 'nat', '%(action)s', 'OUTPUT', '-d', '%(addr2)s', '-j', 'DNAT', '--to-destination', '%(local_external_addr)s'], ['/sbin/iptables', '-t', 'nat', '%(action)s', 'POSTROUTING', '-m', 'tos', '--tos', '0x08', '-j', 'SNAT', '--to-source', '%(addr1)s']]#
- CMD_LIST_REDIRECTION = [['/sbin/iptables', '-t', 'nat', '%(action)s', 'OUTPUT', '-p', '%(family)s', '-d', '%(remote_addr)s', '--dport', '%(remote_port)s', '-j', 'DNAT', '--to-destination', '127.0.0.1:%(local_port)s']]#
- run_commands(cmdlist: list[list[str]], argdict: Mapping[str, Any], ignore_errors: bool = False) None[source]#
Start all commands in cmdlist and replace formatstrings with arguments in argdict.
>>> run_commands([['/bin/echo', '%(msg)s'], ['/bin/echo', 'World']], {'msg': 'Hello'})
- add_loop(addr1: str, addr2: str) None[source]#
Add connection loop for addr1 and addr2. Outgoing connections to addr1 will be redirected back to localhost. The redirected connection will appear as it comes from addr2. All outgoing traffic to addr2 will be also redirected back to localhost and will appear as it comes from addr1.
HINT: only one loop may be established at a time!
- remove_loop(addr1: str, addr2: str, ignore_errors: bool = False) None[source]#
Remove previously defined connection loop.
univention.testing.pytest module#
pytest runner for ucs-test
univention.testing.strings module#
- univention.testing.strings.random_string(length: int = 10, alpha: bool = True, numeric: bool = True, charset: str = '', encoding: str = 'utf-8') str[source]#
Get specified number of random characters (ALPHA, NUMERIC or ALPHANUMERIC). Default is an alphanumeric string of 10 characters length. A custom character set may be defined via “charset” as string. The default encoding is UTF-8. If length is 0 or negative, an empty string is returned.
- univention.testing.strings.random_name(length: int = 10) str[source]#
create random name (1 ALPHA, 8 ALPHANUM, 1 ALPHA)
- univention.testing.strings.random_name_special_characters(length: int = 10) str[source]#
create random name (1 UMLAUT, 2 ALPHA, 6 SPECIAL_CHARACTERS + UMLAUT, 1 UMLAUTNUM)
- univention.testing.strings.random_username(length: int = 10) str#
create random name (1 ALPHA, 8 ALPHANUM, 1 ALPHA)
- univention.testing.strings.random_groupname(length: int = 10) str#
create random name (1 ALPHA, 8 ALPHANUM, 1 ALPHA)
- univention.testing.strings.random_ucs_version(min_major: int = 1, max_major: int = 9, min_minor: int = 0, max_minor: int = 99, min_patchlevel: int = 0, max_patchlevel: int = 99) str[source]#
- univention.testing.strings.random_ip(ip_iter: ~collections.abc.Iterator[int] = <range_iterator object>) str[source]#
Returns 110 different ip addresses in the range 11.x.x.x-120.x.x.x
- univention.testing.strings.random_subnet(ip_iter: ~collections.abc.Iterator[int] = <range_iterator object>) str[source]#
Returns 110 different ip addresses in the range 11.x.x.x-120.x.x.x
univention.testing.ucr module#
BETA VERSION
Wrapper around Univention Configuration Registry that is able to revert the UCR status after usage. For usage examples look at the end of this file.
Warning
changes to the ConfigRegistry object will also trigger the evaluation of templates and therefore changes in configuration files created by UCR!
Warning
The API is currently under development and may change before next UCS release!
- class univention.testing.ucr.UCSTestConfigRegistry(*args: Any, **kwargs: Any)[source]#
Bases:
ConfigRegistryExtension to ConfigRegistry to be able to clean up after several changes to UCR variables have been done.
initialise object
univention.testing.ucs_samba module#
- univention.testing.ucs_samba.password_policy(complexity: bool = False, minimum_password_age: int = 0, maximum_password_age: int = 3) Iterator[None][source]#
- univention.testing.ucs_samba.wait_for_drs_replication(ldap_filter: str, attrs: list[str] | str | None = None, base: str | None = None, scope: int = 2, lp: LoadParm | None = None, timeout: int = 360, delta_t: int = 1, verbose: bool = True, should_exist: bool = True, controls: list[str] | None = None) None[source]#
- univention.testing.ucs_samba.force_drs_replication(source_dc: str | None = None, destination_dc: str | None = None, partition_dn: str | None = None, direction: str = 'in') int[source]#
univention.testing.udm module#
ALPHA VERSION
Wrapper around Univention Directory Manager CLI to simplify creation/modification of UDM objects in python. The wrapper automatically removed created objects during wrapper destruction. For usage examples look at the end of this file.
WARNING: The API currently allows only modifications to objects created by the wrapper itself. Also the deletion of objects is currently unsupported. Also not all UDM object types are currently supported.
WARNING2: The API is currently under heavy development and may/will change before next UCS release!
- exception univention.testing.udm.UCSTestUDM_MissingModulename[source]#
Bases:
UCSTestUDM_Exception
- exception univention.testing.udm.UCSTestUDM_MissingDn[source]#
Bases:
UCSTestUDM_Exception
- exception univention.testing.udm.UCSTestUDM_CreateUDMObjectFailed[source]#
Bases:
UCSTestUDM_Exception
- exception univention.testing.udm.UCSTestUDM_CreateUDMUnknownDN[source]#
Bases:
UCSTestUDM_Exception
- exception univention.testing.udm.UCSTestUDM_ModifyUDMObjectFailed[source]#
Bases:
UCSTestUDM_Exception
- exception univention.testing.udm.UCSTestUDM_RestoreUDMObjectFailed[source]#
Bases:
UCSTestUDM_Exception
- exception univention.testing.udm.UCSTestUDM_MoveUDMObjectFailed[source]#
Bases:
UCSTestUDM_Exception
- exception univention.testing.udm.UCSTestUDM_NoModification[source]#
Bases:
UCSTestUDM_Exception
- exception univention.testing.udm.UCSTestUDM_ModifyUDMUnknownDN[source]#
Bases:
UCSTestUDM_Exception
- exception univention.testing.udm.UCSTestUDM_RestoreUDMUnknownDN[source]#
Bases:
UCSTestUDM_Exception
- exception univention.testing.udm.UCSTestUDM_RemoveUDMObjectFailed[source]#
Bases:
UCSTestUDM_Exception
- exception univention.testing.udm.UCSTestUDM_CleanupFailed[source]#
Bases:
UCSTestUDM_Exception
- exception univention.testing.udm.UCSTestUDM_CannotModifyExistingObject[source]#
Bases:
UCSTestUDM_Exception
- exception univention.testing.udm.UCSTestUDM_ListUDMObjectFailed[source]#
Bases:
UCSTestUDM_Exception
- exception univention.testing.udm.UCSTestUDM_GetUDMObjectFailed[source]#
Bases:
UCSTestUDM_Exception
- class univention.testing.udm.UCSTestUDM(language=None)[source]#
Bases:
object- PATH_UDM_CLI_SERVER = '/usr/share/univention-directory-manager-tools/univention-cli-server'#
- PATH_UDM_CLI_CLIENT = '/usr/sbin/udm'#
- PATH_UDM_CLI_CLIENT_WRAPPED = '/usr/sbin/udm-test'#
- COMPUTER_MODULES = ('computers/ubuntu', 'computers/linux', 'computers/windows', 'computers/windows_domaincontroller', 'computers/domaincontroller_master', 'computers/domaincontroller_backup', 'computers/domaincontroller_slave', 'computers/memberserver', 'computers/macos', 'computers/ipmanagedclient')#
- create_object(modulename: str, wait_for_replication: bool = True, check_for_drs_replication: bool = False, wait_for: bool = False, **kwargs: Any) str[source]#
Creates a LDAP object via UDM. Values for UDM properties can be passed via keyword arguments only and have to exactly match UDM property names (case-sensitive!).
- create_with_defaults(modulename: str, **kwargs: Any) tuple[str, dict][source]#
Create any object with as maximum as possible prefilled random default values
- modify_object(modulename: str, wait_for_replication: bool = True, check_for_drs_replication: bool = False, wait_for: bool = False, **kwargs: Any) str[source]#
Modifies a LDAP object via UDM. Values for UDM properties can be passed via keyword arguments only and have to exactly match UDM property names (case-sensitive!). Please note: the object has to be created by create_object otherwise this call will raise an exception!
- Parameters:
modulename (str) – name of UDM module (e.g. ‘users/user’)
- restore_object(modulename: str, wait_for_replication: bool = True, check_for_drs_replication: bool = False, wait_for: bool = False, **kwargs: Any) str[source]#
- move_object(modulename: str, wait_for_replication: bool = True, check_for_drs_replication: bool = False, wait_for: bool = False, **kwargs: Any) str[source]#
- remove_object(modulename: str, wait_for_replication: bool = True, wait_for: bool = False, **kwargs: Any) None[source]#
- wait_for(modulename: str, dn: str, wait_for_replication: bool = True, wait_for_drs_replication: bool = False, wait_for_s4connector: bool = False, everything: bool = False) None[source]#
- create_user(wait_for_replication: bool = True, check_for_drs_replication: bool = True, wait_for: bool = True, **kwargs: Any) tuple[str, str][source]#
Creates a user via UDM CLI. Values for UDM properties can be passed via keyword arguments only and have to exactly match UDM property names (case-sensitive!). Some properties have default values:
- create_ldap_user(wait_for_replication: bool = True, check_for_drs_replication: bool = False, **kwargs: Any) tuple[str, str][source]#
- remove_user(username: str, wait_for_replication: bool = True) None[source]#
Removes a user object from the ldap given it’s username.
- create_group(wait_for_replication: bool = True, check_for_drs_replication: bool = True, **kwargs: Any) tuple[str, str][source]#
Creates a group via UDM CLI. Values for UDM properties can be passed via keyword arguments only and have to exactly match UDM property names (case-sensitive!). Some properties have default values:
- Parameters:
- Returns:
(dn, groupname)
If “groupname” is missing, a random group name will be used.
- class univention.testing.udm.UDM(language=None)[source]#
Bases:
UCSTestUDMUDM interface using the REST API
- PATH_UDM_CLI_CLIENT_WRAPPED = '/usr/sbin/udm-test-rest'#
- univention.testing.udm.verify_udm_object(module: Any, dn: str, expected_properties: Mapping[str, bytes | str | Sequence[str]] | None) None[source]#
Verify an object exists with the given dn in the given UDM module with some properties. Setting expected_properties to None requires the object to not exist. :param dict expected_properties: is a dictionary of (property,value) pairs.
- Raises:
AssertionError – in case of a mismatch.
univention.testing.udm_extensions module#
- univention.testing.udm_extensions.get_extension_name(extension_type: str) str[source]#
Returns a valid extension name for the given extension type. >>> get_extension_name(‘hook’) ‘jcvuardfqx’ >>> get_extension_name(‘syntax’) ‘hwvkm29tde’ >>> get_extension_name(‘module’) ‘ucstest/r3jkljngcp’
- univention.testing.udm_extensions.get_extension_filename(extension_type: str, extension_name: str) str[source]#
- univention.testing.udm_extensions.call_cmd(cmd: Sequence[str], fail_on_error: bool = True) int[source]#
Calls the given cmd (list of strings).
- univention.testing.udm_extensions.call_join_script(name: str, fail_on_error: bool = True) int[source]#
Calls the given join script (e.g. name=’66foobar.inst’). If fail is true, then the function fail() is called if the exitcode is not zero.
- univention.testing.udm_extensions.call_unjoin_script(name: str, fail_on_error: bool = True) int[source]#
Calls the given unjoin script (e.g. name=’66foobar-uninstall.uinst’). If fail is true, then the function fail() is called if the exitcode is not zero.
- univention.testing.udm_extensions.get_syntax_buffer(name: str | None = None, identifier: str | None = None) str[source]#
Returns a UDM syntax with given name (e.g. ‘MySimpleHook’). If name is omitted, a randomly generated name is used.
- univention.testing.udm_extensions.get_hook_buffer(name: str | None = None, identifier: str | None = None) str[source]#
Returns a UDM hook with given name (e.g. ‘MySimpleHook’). If name is omitted, a randomly generated name is used.
- univention.testing.udm_extensions.get_module_buffer(name: str | None = None, identifier: str | None = None) str[source]#
Returns a UDM module with given name (e.g. ‘testing/mytest’). If name is omitted, a randomly generated name is used (‘ucstest/%(randomstring)s’).
- univention.testing.udm_extensions.get_extension_buffer(extension_type: str, name: str | None = None, identifier: str | None = None) str[source]#
Get UDM extension of specified type with specified name. In case the name is omitted, a random name will be used.
- univention.testing.udm_extensions.get_postinst_script_buffer(extension_type: str, filename: str, app_id: str | None = None, version_start: str | None = None, version_end: str | None = None, options: Mapping[str, str | Iterable[str]] | None = None) str[source]#
Returns a postinst script that registers the given file as UDM extension with extension type (‘hook’, ‘syntax’ or ‘module’). Optionally UNIVENTION_APP_ID, UCS version start and UCS version end may be specified.
- univention.testing.udm_extensions.get_postrm_script_buffer(extension_type: str, extension_name: str, package_name: str) str[source]#
Returns an postrm script that deregisters the given UDM extension. The type of the extension has to be specified (‘hook’, ‘syntax’ or ‘module’).
- univention.testing.udm_extensions.get_join_script_buffer(extension_type: str, filename: str, app_id: str | None = None, joinscript_version: int = 1, version_start: str | None = None, version_end: str | None = None, options: Mapping[str, str | Iterable[str]] | None = None) str[source]#
Returns a join script that registers the given file as UDM extension with extension type (‘hook’, ‘syntax’ or ‘module’). Optionally a joinscript version, UNIVENTION_APP_ID, UCS version start and UCS version end may be specified.
- univention.testing.udm_extensions.get_unjoin_script_buffer(extension_type: str, extension_name: str, package_name: str) str[source]#
Returns an unjoin script that deregisters the given UDM extension. The type of the extension has to be specified (‘hook’, ‘syntax’ or ‘module’).
- univention.testing.udm_extensions.get_absolute_extension_filename(extension_type: str, filename: str) str[source]#
Returns the absolute path to an extentension of the given type and filename.
univention.testing.umc module#
- class univention.testing.umc.Client(hostname: str | None = None, username: str | None = None, password: str | None = None, language: str | None = None, timeout: float | None = None, automatic_reauthentication: bool = False)[source]#
Bases:
Client- print_response = True#
- print_request_data = True#
- classmethod get_test_connection(hostname: str | None = None, *args: Any, **kwargs: Any) Self[source]#
- umc_command(*args: Any, **kwargs: Any) Self[source]#
Perform generic UMC command.
- Parameters:
- Returns:
The UMC response.
- Return type:
- class univention.testing.umc.GetHtmlTagValue(tag: str, condition: tuple[str, str], value_name: str)[source]#
Bases:
HTMLParserInitialize and reset this instance.
If convert_charrefs is True (the default), all character references are automatically converted to the corresponding Unicode characters.
- univention.testing.umc.get_html_tag_value(page: str, tag: str, condition: tuple[str, str], value_name: str) str[source]#
- class univention.testing.umc.ClientSaml(hostname: str | None = None, username: str | None = None, password: str | None = None, language: str | None = None, timeout: float | None = None, automatic_reauthentication: bool = False)[source]#
Bases:
Client
- class univention.testing.umc.ClientOIDC(hostname: str | None = None, username: str | None = None, password: str | None = None, language: str | None = None, timeout: float | None = None, automatic_reauthentication: bool = False)[source]#
Bases:
Client
univention.testing.utils module#
Common functions used by tests.
- class univention.testing.utils.UCSTestDomainAdminCredentials(ucr: ConfigRegistry | None = None)[source]#
Bases:
objectThis class fetches the username, the LDAP bind DN and the password for a domain admin user account from UCR. The account may be used for testing.
>>> dummy_ucr = {'ldap/base': 'dc=example,dc=com', 'tests/domainadmin/pwdfile': '/dev/null'} >>> account = UCSTestDomainAdminCredentials(ucr=dummy_ucr) >>> account.username 'Administrator' >>> account.binddn 'uid=Administrator,cn=users,dc=example,dc=com' >>> account.bindpw ''
- univention.testing.utils.get_ldap_connection(admin_uldap: bool = False, primary: bool = False) access[source]#
- univention.testing.utils.retry_on_error(func: ~collections.abc.Callable[[...], ~univention.testing.utils._T], exceptions: tuple[type[Exception], ...] = (<class 'Exception'>,), retry_count: int = 20, delay: float = 10) _T[source]#
This function calls the given function func. If one of the specified exceptions is caught, func is called again until the retry count is reached or any unspecified exception is caught. Between two calls of func retry_on_error waits for delay seconds.
- Parameters:
func – function to be called
exceptions – tuple of exception classes, that cause a rerun of func
retry_count – retry the execution of func max retry_count times
delay – waiting time in seconds between two calls of func
- Returns:
return value of func
- univention.testing.utils.verify_ldap_object(baseDn: str, expected_attr: Mapping[str, Sequence[bytes | str]] | None = None, strict: bool = True, should_exist: bool = True, retry_count: int = 20, delay: float = 10, primary: bool = False, pre_check: Callable[[...], None] | None = None, pre_check_kwargs: dict[str, Any] | None = None, not_expected_attr: dict[str, str] | None = None) None[source]#
Verify [non]existence and attributes of LDAP object.
- Parameters:
baseDn (str) – DN of object to check
expected_attr (dict) – attributes and their values that the LDAP object is expected to have
strict (bool) – value lists of multi-value attributes must be complete
should_exist (bool) – whether the object is expected to exist
retry_count (int) – how often to retry the verification if it fails before raising an exception
delay (float) – waiting time in seconds between retries on verification failures
primary (bool) – whether to connect to the primary (DC master) instead of local LDAP (to be exact: ucr[ldap/server/name], ucr[‘ldap/server/addition’])
pre_check – function to execute before starting verification. Value should be a function object like utils.wait_for_replication.
pre_check_kwargs (dict) – dict with kwargs to pass to pre_check() call
not_expected_attr (dict) – attributes and their values that the LDAP object is NOT expected to have
- Returns:
None
- Raises:
LDAPObjectNotFound – when no object was found at baseDn
LDAPUnexpectedObjectFound – when an object was found at baseDn, but should_exist=False
LDAPObjectValueMissing – when a value listed in expected_attr is missing in the LDAP object
LDAPObjectUnexpectedValue – if strict=True and a multi-value attribute of the LDAP object has more values than were listed in expected_attr or an not_expected_attr was found
- class univention.testing.utils.AutomaticListenerRestart[source]#
Bases:
objectAutomatically restart Univention Directory Listener when leaving the “with” block:
with AutomaticListenerRestart() as alr: with ucr_test.UCSTestConfigRegistry() as ucr: # set some ucr variables, that influence the Univention Directory Listener univention.config_registry.handler_set(['foo/bar=ding/dong'])
- class univention.testing.utils.AutoCallCommand(enter_cmd: Sequence[str] | None = None, exit_cmd: Sequence[str] | None = None, stdout: IO[str] | None = None, stderr: IO[str] | None = None)[source]#
Bases:
objectAutomatically call the given commands when entering/leaving the “with” block. The keyword arguments enter_cmd and exit_cmd are optional:
with AutoCallCommand( enter_cmd=['/etc/init.d/dovecot', 'reload'], exit_cmd=['/etc/init.d/dovecot', 'restart'] ) as acc: with ucr_test.UCSTestConfigRegistry() as ucr: # set some ucr variables, that influence the Univention Directory Listener univention.config_registry.handler_set(['foo/bar=ding/dong'])
In case some filedescriptors for stdout/stderr have to be passed to the executed command, they may be passed as kwarg:
with AutoCallCommand( enter_cmd=['/etc/init.d/dovecot', 'reload'], exit_cmd=['/etc/init.d/dovecot', 'restart'], stderr=open('/dev/zero', 'w') ) as acc: pass
- class univention.testing.utils.FollowLogfile(logfiles: Iterable[str], always: bool = False)[source]#
Bases:
objectPrints the contents of the listed files on exit of the with block if an exception occurred. Set always=True to also print them without exception. You may wish to make the server flush its logs before existing the with block. Use AutoCallCommand inside the block for that:
cmd = ('doveadm', 'log', 'reopen') with FollowLogfile(logfiles=['/var/log/syslog', '/var/log/mail.log']): with utils.AutoCallCommand(enter_cmd=cmd, exit_cmd=cmd): pass with FollowLogfile(logfiles=['/var/log/syslog'], always=True): with utils.AutoCallCommand(enter_cmd=cmd, exit_cmd=cmd): pass
- Parameters:
logfiles – list of absolute filenames to read from
always – bool, if True: print logfile change also if no error occurred (default=False)
- class univention.testing.utils.ReplicationType(value)[source]#
Bases:
IntEnum- LISTENER = 1#
- POSTRUN = 2#
- S4C_FROM_UCS = 3#
- S4C_TO_UCS = 4#
- DRS = 5#
- univention.testing.utils.wait_for_replication_from_master_openldap_to_local_samba(replication_postrun: bool = False, ldap_filter: str | None = None, verbose: bool = True) None[source]#
Wait for all kind of replications
- univention.testing.utils.wait_for_replication_from_local_samba_to_local_openldap(replication_postrun: bool = False, ldap_filter: str | None = None, verbose: bool = True) None[source]#
Wait for all kind of replications
- univention.testing.utils.wait_for(conditions: list[tuple[ReplicationType, Any]] | None = None, verbose: bool = True) None[source]#
Wait for all kind of replications
- univention.testing.utils.get_lid() int[source]#
get_lid() returns the last processed notifier ID of univention-directory-listener.
- univention.testing.utils.wait_for_listener_replication_and_postrun(verbose: bool = True) None[source]#
- univention.testing.utils.fail(log_message: str | None = None, returncode: int = 1) NoReturn[source]#