Exemple #1
0
    def test_editUser(self):
        page = Users.editPage(self.avatarId, self.db, 'root',
                              self.testSambaDomain)
        page.addSlash = False
        testutil.renderPage(page)

        submitData = {
            'userSettings.uid': u'root',
            'userPermissions.employeeType': True,
            'userPermissions.tumsUser': None,
            'userSettings.userPassword': None,
            'mailSettings.vacation': None,
            'mailSettings.mailAlternateAddress0': None,
            'userPermissions.tumsAdmin': True,
            'mailSettings.mailForwardingAddress0': None,
            'userPermissions.accountStatus': True,
            'userPermissions.employeeType': True,
            'userSettings.sn': u'root',
            'homeDirectory': ['/home/colin'],
            'userSettings.givenName': u'rooter'
        }
        form = None

        for i in range(10):
            submitData['mailSettings.mailAlternateAddress%s' % i] = None
            submitData['mailSettings.mailForwardingAddress%s' % i] = None

        U = page.submitForm(self.aContext, form, submitData)
        self.assertIn("/Users/Edit/thusa.co.za/root/Completed",
                      self.flattenUrl(U, page))

        return U
Exemple #2
0
    def test_deleteUser(self):
        page = Users.deletePage(self.avatarId, self.db)
        page.addSlash = False
        testutil.renderPage(page)
        U = page.locateChild(None, ['thusa.co.za', 'test01'])
        self.assertIn("/Users", self.flattenUrl(U[0], page))

        return U
Exemple #3
0
    def test_addGroup(self):
        page = Users.addGroups(self.avatarId, self.testSambaDomain,
                               self.testUser, self.db)
        page.addSlash = False
        testutil.renderPage(page)
        submitData = {'groupName': 'test01'}
        U = page.submitForm(self.aContext, None, submitData)
        self.assertIn('/Users/Groups/thusa.co.za/test',
                      self.flattenUrl(U, page))

        return U
Exemple #4
0
    def thive_user(self, messageId, params, data):
        """ User record updated/new. 
            if the user exists, initialise a call to Users.editPage otherwise 
            pass to Users.addPage

            Plain text password is passed from server down to client node.
        """
        locator = params[0]  # A resource locator (userid@domain)
        type = params[1]

        newdata = {}
        for kv in data.split('`'):
            if kv:
                k, v = kv.split(':', 1)
                newdata[k] = v
        tumsUser = []
        squid = False
        admin = False

        for i in newdata['emp'].split('+'):
            if 'squid' in i:
                squid = True
            if 'tumsAdmin' in i:
                admin = True
            if 'tumsUser' in i:
                tumsUser = i.strip(']').split('[')[-1].split(
                    ',')  # list in brackets.

        flags = {
            'vpn': False,
            'ftpE': False,
            'ftpG': False,
            'copyto': u"",
        }

        flagsi = newdata['flags'].split('+')
        f = ['vpn', 'ftpE', 'ftpG']
        for n, d in enumerate(flagsi[0]):
            flags[f[n]] = d == "-"

        if len(flagsi) > 1:
            flags['copyto'] = flagsi[1]

        submitData = {
            'userPermissions.employeeType': squid,
            'userPermissions.tumsUser': tumsUser,
            'userPermissions.tumsAdmin': admin,
            'userPermissions.accountStatus': newdata['active'] == "active",
            'userSettings.uid': newdata['name'],
            'userSettings.userPassword': newdata['password'],
            'userSettings.sn': unicode(newdata['sn']),
            'userSettings.givenName': unicode(newdata['giveName']),
            'mailSettings.vacation': newdata['vacation'],
            'mailSettings.vacen': newdata['vacEnable'] == "True",
            'userPermissions.copyto': flags['copyto'],
            'userAccess.vpnEnabled': flags['vpn'],
            'userAccess.ftpEnabled': flags['ftpE'],
            'userAccess.ftpGlobal': flags['ftpG'],
        }

        # Initialise all the psuedo-fields
        for i in range(10):
            submitData['mailSettings.mailAlternateAddress%s' % i] = u""
            submitData['mailSettings.mailForwardingAddress%s' % i] = u""

        # Teardown our real data
        for n, d in enumerate(newdata['mailAlias'].split('+')):
            submitData['mailSettings.mailAlternateAddress%s' % n] = unicode(d)

        for n, d in enumerate(newdata['mailForward'].split('+')):
            submitData['mailSettings.mailForwardingAddress%s' % n] = unicode(d)

        # Dummy form
        form = None
        #print submitData

        # decide which instance to create
        if type == "new":
            # Add new user (Not implemented on Thebe yet...
            addInstance = Users.addPage()
            p = addInstance.submitForm(None, None, submitData)
        else:
            #print "Edit ", locator
            # Alteration of existing user.
            try:
                editInstance = Users.editPage(None, (None, None, None, None),
                                              locator.split('@')[0],
                                              newdata['domain'])
                p = editInstance.submitForm(None, None, submitData)
            except Exception, e:
                print e, "ERROR"
Exemple #5
0
 def test_Users(self):
     page = Users.Page(self.avatarId, self.db)
     page.addSlash = False
     return testutil.renderPage(page)
Exemple #6
0
 def test_editGroupMembership(self):
     page = Users.editGroups(self.avatarId, self.db, self.testUser,
                             self.testSambaDomain)
     page.addSlash = False
     return testutil.renderPage(page)