univention.testing.ucsschool package

Submodules

univention.testing.ucsschool.acl module

exception univention.testing.ucsschool.acl.FailAcl[source]

Bases: exceptions.Exception

exception univention.testing.ucsschool.acl.FailCmd[source]

Bases: exceptions.Exception

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: univention.testing.ucsschool.acl.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': 's3auhde6lb'}
class univention.testing.ucsschool.acl.CreateDCSlaveInContainer(container_dn, **kwargs)[source]

Bases: univention.testing.ucsschool.acl.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': 'xyubw7tlpa'}
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]

Slave-Controller duerfen Eintraege Ihrer ou lesen und schreiben (Passwortaenderungen etc.) Lehrer und Memberserver 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 DC-Slave und Memberserver joinen (benoetigt Passwortaenderung)

univention.testing.ucsschool.bb_api module

univention.testing.ucsschool.computerroom module

univention.testing.ucsschool.distribution module

Class Distribution

class univention.testing.ucsschool.distribution.Distribution(school, connection=None, sender=None, flavor=None, ucr=None, description=None, name=None, distributeType='manual', distributeTime=None, distributeDate=None, collectType='manual', collectTime=None, collectDate=None, files=[], recipients=[])[source]

Bases: 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
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 form
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

exception univention.testing.ucsschool.exam.StartFail[source]

Bases: exceptions.Exception

exception univention.testing.ucsschool.exam.FinishFail[source]

Bases: exceptions.Exception

exception univention.testing.ucsschool.exam.SaveFail[source]

Bases: exceptions.Exception

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=[], 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) – name 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) –
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: univention.testing.ucsschool.exam.Exam

univention.testing.ucsschool.import_factory_test_classes module

univention.testing.ucsschool.importcomputers module

univention.testing.ucsschool.importgroups module

univention.testing.ucsschool.importnetworks module

univention.testing.ucsschool.importou module

univention.testing.ucsschool.importprinters module

univention.testing.ucsschool.importusers module

univention.testing.ucsschool.importusers_cli_v2 module

univention.testing.ucsschool.importusers_http module

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.kelvin_api module

univention.testing.ucsschool.klasse module

exception univention.testing.ucsschool.klasse.GetFail[source]

Bases: exceptions.Exception

exception univention.testing.ucsschool.klasse.GetCheckFail[source]

Bases: exceptions.Exception

exception univention.testing.ucsschool.klasse.CreateFail[source]

Bases: exceptions.Exception

exception univention.testing.ucsschool.klasse.QueryCheckFail[source]

Bases: exceptions.Exception

exception univention.testing.ucsschool.klasse.RemoveFail[source]

Bases: exceptions.Exception

exception univention.testing.ucsschool.klasse.EditFail[source]

Bases: exceptions.Exception

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]
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.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.schoolroom module

exception univention.testing.ucsschool.schoolroom.FailQuery[source]

Bases: exceptions.Exception

exception univention.testing.ucsschool.schoolroom.FailPut[source]

Bases: exceptions.Exception

exception univention.testing.ucsschool.schoolroom.FailGet[source]

Bases: exceptions.Exception

exception univention.testing.ucsschool.schoolroom.FailAdd[source]

Bases: exceptions.Exception

exception univention.testing.ucsschool.schoolroom.FailCheckPut[source]

Bases: exceptions.Exception

exception univention.testing.ucsschool.schoolroom.FailCheckGet[source]

Bases: exceptions.Exception

exception univention.testing.ucsschool.schoolroom.FailCheckQuery[source]

Bases: exceptions.Exception

exception univention.testing.ucsschool.schoolroom.FailRemove[source]

Bases: exceptions.Exception

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]
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: univention.testing.ucsschool.schoolroom.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=<class 'sphinx.ext.autodoc.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)[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 DC-Master 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 DC-Slaves 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 DC-Master 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.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()[source]
exception univention.testing.ucsschool.ucs_test_school.SchoolError[source]

Bases: exceptions.Exception

exception univention.testing.ucsschool.ucs_test_school.SchoolMissingOU[source]

Bases: univention.testing.ucsschool.ucs_test_school.SchoolError

exception univention.testing.ucsschool.ucs_test_school.SchoolLDAPError[source]

Bases: univention.testing.ucsschool.ucs_test_school.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 0x7fa10de3fdd0 wrapping <univention.testing.ucr.UCSTestConfigRegistry object> at 0x7fa1177d6b50 with factory <function <lambda>>>
_test_ous = {}
LDAP_BASE = <Proxy at 0x7fa10de3fe60 wrapping None at 0x55a3c73eb4d0 with factory <function <lambda>>>
PATH_CMD_BASE = '/usr/share/ucs-school-import/scripts'
PATH_CMD_CREATE_OU = '/usr/share/ucs-school-import/scripts/create_ou'
PATH_CMD_IMPORT_USER = '/usr/share/ucs-school-import/scripts/import_user'
CN_STUDENT = <Proxy at 0x7fa10de3fe18 wrapping 'schueler' at 0x7fa12805aa80 with factory <function <lambda>>>
CN_TEACHERS = <Proxy at 0x7fa10de3fd88 wrapping 'lehrer' at 0x7fa12805a3c0 with factory <function <lambda>>>
CN_TEACHERS_STAFF = <Proxy at 0x7fa10de3f200 wrapping 'lehrer und mitarbeiter' at 0x7fa10f89c8b0 with factory <function <lambda>>>
CN_ADMINS = <Proxy at 0x7fa10de3f1b8 wrapping 'admins' at 0x7fa1280566c0 with factory <function <lambda>>>
CN_STAFF = <Proxy at 0x7fa10de3fb90 wrapping 'mitarbeiter' at 0x7fa12805a960 with factory <function <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 master is setup by getMachoneConnection().

_remove_udm_object(module, dn, raise_exceptions=False)[source]

Tries to remove UDM object specified by given dn. Return None on success or error message.

_set_password(userdn, password, raise_exceptions=False)[source]

Tries to set a password for the given user. Return None on success or error message.

cleanup(wait_for_replication=True)[source]

Cleanup all objects created by the UCS@school test environment

cleanup_ou(ou_name, wait_for_replication=True)[source]

Removes the given school ou and all its corresponding objects like groups

classmethod check_name_edudc(name_edudc)[source]
create_ou(ou_name=None, name_edudc=None, name_admindc=None, displayName='', name_share_file_server=None, use_cli=False, wait_for_replication=True, use_cache=True)[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 dc slave. “name_admindc” may contain the optional name for an administrative dc slave. 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 master or backup, name_edudc will be unset automatically,

because it’s not allowed to specify the hostname of the master or any backup 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, name_edudc=None, name_admindc=None, displayName='', name_share_file_server=None, use_cli=False, wait_for_replication=True, use_cache=True)[source]

Create num OUs with each the same arguments and a random ou_name, without either effectively dodging the OU-cache or each time getting the same OU (with use_cache=True). All arguments except num plus a random name for the ou (argument “ou_name”) will be passed to create_ou().

Parameters:num – int - number or OUs to create
Returns:list - list of tuples returned by create_ou()
get_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, schools=None, username=None, firstname=None, lastname=None, classes=None, mailaddress=None, is_teacher=False, is_staff=False, is_active=True, password='univention', use_cli=False, wait_for_replication=True)[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, schools=None, is_staff=None, is_teacher=None, wait_for_replication=True, *args, **kwargs)[source]

Accepts same arguments as create_user().

create_domain_admin(ou_name, username=None, password='univention')[source]
create_global_user(username=None, password='univention')[source]
create_school_class(ou_name, class_name=None, description=None, users=None, wait_for_replication=True)[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_ucc()[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=None, dn=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: univention.testing.ucsschool.ucs_test_school.UCSTestSchool

create_multi_env_global_objects()[source]
create_multi_env_school_objects()[source]

univention.testing.ucsschool.user module

univention.testing.ucsschool.workgroup module

class univention.testing.ucsschool.workgroup.Workgroup(school, connection=None, ulConnection=None, ucr=None, name=None, description=None, members=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 – if user allow duplicate names no exception is

raised, no group is created either :type expect_creation_fails_due_to_duplicated_name: bool

_create()[source]
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) –
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]