示例#1
0
	def __init__(self, school, role, school_classes, mode='A', username=None, firstname=None, lastname=None, password=None, mail=None, schools=None):
		super(User, self).__init__(school, role)

		if username:
			self.username = username
			self.dn = self.make_dn()
		if firstname:
			self.firstname = firstname
		if lastname:
			self.lastname = lastname
		if mail:
			self.mail = mail
		if school_classes:
			self.school_classes = school_classes
		self.schools = schools or [self.school]
		self.typ = 'teachersAndStaff' if self.role == 'teacher_staff' else self.role
		self.mode = mode

		utils.wait_for_replication()
		self.ucr = ucr_test.UCSTestConfigRegistry()
		self.ucr.load()
		host = self.ucr.get('ldap/master')
		self.client = Client(host)
		account = utils.UCSTestDomainAdminCredentials()
		admin = account.username
		passwd = account.bindpw
		self.password = password if password else passwd
		self.client.authenticate(admin, passwd)
示例#2
0
 def __init__(self, quota_type="usrquota", fs_type="ext4"):
     ucr = ucr_test.UCSTestConfigRegistry()
     ucr.load()
     self.my_fqdn = '%s.%s' % (ucr.get('hostname'), ucr.get('domainname'))
     account = utils.UCSTestDomainAdminCredentials()
     self.umc_client = Client(self.my_fqdn,
                              username=account.username,
                              password=account.bindpw)
     self.share_name = uts.random_name()
     self.username = uts.random_name()
     self.quota_type = quota_type
     self.fs_type = fs_type
     self.quota_policy = {
         "inodeSoftLimit":
         '10',
         "inodeHardLimit":
         '15',
         "spaceSoftLimit":
         str(1024**2),
         "spaceHardLimit":
         str(2048**2),
         "reapplyQuota":
         'TRUE',
         "name":
         uts.random_name(),
         "position":
         'cn=userquota,cn=shares,cn=policies,%s' % ucr.get('ldap/base'),
     }
示例#3
0
 def __init__(self, school, user_type):
     self.school = school
     self.user_type = user_type
     self.ucr = ucr_test.UCSTestConfigRegistry()
     self.ucr.load()
     host = self.ucr.get('hostname')
     self.client = Client(host)
     account = utils.UCSTestDomainAdminCredentials()
     admin = account.username
     passwd = account.bindpw
     self.client.authenticate(admin, passwd)
示例#4
0
	def __init__(self, quota_type="usrquota", fs_type="ext4"):
		ucr = ucr_test.UCSTestConfigRegistry()
		ucr.load()
		self.ldap_base = ucr.get('ldap/base')
		self.my_fqdn = '%s.%s' % (ucr.get('hostname'), ucr.get('domainname'))
		account = utils.UCSTestDomainAdminCredentials()
		self.umc_client = Client(self.my_fqdn, username=account.username, password=account.bindpw)
		self.share_name = uts.random_name()
		self.share_name2 = uts.random_name()
		self.username = uts.random_name()
		self.quota_type = quota_type
		self.fs_type = fs_type
示例#5
0
def test_simpleauthaccount_authentication(udm, ucr):
    """Check whether a simple-auth-account can authenticate against LDAP and UMC"""
    password = '******'
    dn, username = udm.create_ldap_user(password=password)
    utils.verify_ldap_object(dn)

    print('created user %r with dn=%r' % (username, dn))
    lo = univention.admin.uldap.access(binddn=dn, bindpw=password)
    assert dn in lo.lo.lo.whoami_s()
    assert username == lo.get(dn)['uid'][0].decode('utf-8')
    print('successfully did LDAP bind.')

    client = Client(ucr['hostname'], username, password)
    ldap_base = client.umc_get('ucr', ['ldap/base']).result
    print(ldap_base)
    assert ldap_base, 'Could not do any random UMC request'
    print('successfully did UMC authentication')
示例#6
0
 def __init__(self,
              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=[]):
     account = utils.UCSTestDomainAdminCredentials()
     admin = account.username
     passwd = account.bindpw
     self.school = school
     self.name = name if name else uts.random_string()
     self.description = description if description else uts.random_string()
     if distributeTime:
         self.distributeTime = distributeTime
     else:
         self.distributeTime = time.strftime('%I:%M')
     if distributeDate:
         self.distributeDate = distributeDate
     else:
         self.distributeDate = time.strftime('%Y-%m-%d')
     self.collectTime = collectTime if collectTime else time.strftime(
         '%I:%M')
     self.collectDate = collectDate if collectDate else time.strftime(
         '%Y-%m-%d')
     self.distributeType = distributeType
     self.collectType = collectType
     self.files = files
     self.recipients = recipients
     self.ucr = ucr if ucr else ucr_test.UCSTestConfigRegistry()
     self.sender = sender if sender else admin
     self.flavor = flavor if flavor else 'admin'
     if connection:
         self.client = connection
     else:
         self.client = Client(None, admin, passwd)
示例#7
0
    def create_umc_connection_authenticate(self):
        """
		Creates UMC connection and authenticates to DC-Master with the test
		user credentials.
		"""
        if not self.ldap_master:
            self.ldap_master = self.UCR.get('ldap/master')

        try:
            self.client = Client(self.ldap_master, self.admin_username,
                                 self.admin_password)
        except (ConnectionError, HTTPError) as exc:
            print(
                "An HTTP Error occured while trying to authenticate to UMC: %r"
                % exc)
            print "Waiting 10 seconds and making another attempt"
            sleep(10)
            self.client.authenticate(self.admin_username, self.admin_password)
示例#8
0
 def __init__(self,
              school,
              typ,
              name=None,
              ip_address=None,
              subnet_mask=None,
              mac_address=None,
              inventory_number=None):
     self.school = school
     self.typ = typ
     self.name = name if name else uts.random_name()
     self.ip_address = ip_address if ip_address else random_ip()
     self.subnet_mask = subnet_mask if subnet_mask else '255.255.255.0'
     self.mac_address = mac_address.lower() if mac_address else random_mac()
     self.inventory_number = inventory_number if inventory_number else ''
     self.ucr = ucr_test.UCSTestConfigRegistry()
     self.ucr.load()
     host = self.ucr.get('ldap/master')
     self.client = Client(host)
     account = utils.UCSTestDomainAdminCredentials()
     admin = account.username
     passwd = account.bindpw
     self.client.authenticate(admin, passwd)
示例#9
0
 def __init__(self, username, password):
     self._client = Client()
     self.username = username
     self.password = password
def umc_client():
	return Client(language="en_US")