コード例 #1
0
    def test_managers(self):
        # Empty list to be filled with user objects
        self.users = []  
        
        maxManagers = self.maxUsers + 5
        # Get the number of users already logged in
        count = db_utils.getNumberOfActiveUsers(self.connection, self.cur)
    
        print 'Max users allowed: %d' % self.maxUsers
        print 'Max managers allowed: %d' % maxManagers
        print 'Number of users already logged in: %d' % count
        print 'Opening browsers........'

        for manager in self.managers:
            # For each manager, create a user object and add object to users list
            self.users.append(um_utils.user(manager, 'quantel@'))
           
        # Keep trying to log in each of the editors. Once the max number of users have been logged in, no further logins should be allowed.
        for user in self.users:
            result = um_utils.login(user)
            if (result == 0 or result == 1):
                user.loggedin = True 
            count = db_utils.getNumberOfActiveUsers(self.connection, self.cur)
            print '\tNumber of active users (max: %d): %d' % (maxManagers, count)
            self.assertFalse ((count > maxManagers), 'Test Failed: Max number of users exceded.')
                
        print 'Sleeping for 2 secs.................'
        time.sleep( 2 )
コード例 #2
0
    def test_administrators(self):
        # Empty list to be filled with user objects
        self.users = []
        if (self.maxUsers > 0):
            print 'License is valid!!!!!!'
            print 'License start date should not yet have occured'
            print 'Replace the license in um_utils.py'
        
        maxAdmins = self.maxUsers + 5
        # Get the number of users already logged in
        count = db_utils.getNumberOfActiveUsers(self.connection, self.cur)
    
        print 'Max users allowed: %d' % self.maxUsers
        print 'Max administrators allowed: %d' % maxAdmins
        print 'Number of users already logged in: %d' % count
        print 'Opening browsers........'

        for admin in self.admins:
            # For each administrator, create a user object and add object to users list
            self.users.append(um_utils.user(admin, 'quantel@'))
           
        # Keep trying to log in each of the editors. Once the max number of users have been logged in, no further logins should be allowed.
        for user in self.users:
            result = um_utils.login(user)
            if (result == 0 or result == 1):
                user.loggedin = True 
            count = db_utils.getNumberOfActiveUsers(self.connection, self.cur)
            print '\tNumber of active users (max: %d): %d' % (maxAdmins, count)
            self.assertFalse ((count > maxAdmins), 'Test Failed: Max number of users exceded.')
                
        print 'Sleeping for 2 secs.................'
        time.sleep( 2 )
コード例 #3
0
    def test_editors(self):
        # Empty list to be filled with user objects
        self.users = []

        # Get the number of users already logged in
        count = db_utils.getNumberOfActiveUsers(self.connection, self.cur)

        print 'Max users allowed: %d' % self.maxUsers
        print 'Number of users already logged in: %d' % count
        print 'Opening browsers........'

        for editor in self.editors:
            # For each editor, create a user object and add object to users list
            self.users.append(um_utils.user(editor, 'quantel@'))

        # Keep trying to log in each of the editors. If any editor can log in, the test has failed.
        for user in self.users:
            result = um_utils.login(user)
            if (result == 0 or result == 1):
                user.loggedin = True
            self.assertTrue((result > 1),
                            'Test Failed: User successfully logged in.')

        print 'Sleeping for 2 secs.................'
        time.sleep(2)
コード例 #4
0
    def test_administrators(self):
        # Empty list to be filled with user objects
        self.users = []
        maxAdmins = self.maxUsers + 5
        print 'Maximum number of administrators = %d' % maxAdmins
        count = db_utils.getNumberOfActiveUsers(self.connection, self.cur)

        print 'Max users allowed: %d' % self.maxUsers
        print 'Max administrators allowed: %d' % maxAdmins
        print 'Number of users already logged in: %d' % count
        print 'Opening browsers........'

        for admin in self.admins:
            # For each administrator, create a user object and add object to users list
            self.users.append(um_utils.user(admin, 'quantel@'))

        # Keep trying to log in each of the editors. Once the max number of users have been logged in, no further logins should be allowed.
        for user in self.users:
            result = um_utils.login(user)
            if (result == 0 or result == 1):
                user.loggedin = True
                self.assertTrue((
                    db_utils.getNumberOfActiveUsers(self.connection,
                                                    self.cur) > 0
                ), 'Test Failed: Check that you are using the correct SQL DB!!!!!!.'
                                )
            count = db_utils.getNumberOfActiveUsers(self.connection, self.cur)
            if (
                    result == 3
            ):  # Maximum number of users are logged in. Check that the number logged in is correct.
                self.assertFalse((count < maxAdmins),
                                 'Test Failed: User should be able to log in.')
            print '\tNumber of active users (max: %d): %d' % (maxAdmins, count)
            self.assertFalse((count > maxAdmins),
                             'Test Failed: Max number of users exceded.')

        print 'Sleeping for 2 secs.................'
        time.sleep(2)
コード例 #5
0
    def test_valid_license(self):
        # Install license for five users and set the value of maxUsers
        self.maxUsers = db_utils.addFiveUserLicense(self.connection, self.cur)
        print 'License installed for %d users' % self.maxUsers

        # Empty list to be filled with user objects
        self.users = []
        maxAdmins = self.maxUsers + 5
        print 'Maximum number of administrators = %d' % maxAdmins
        count = db_utils.getNumberOfActiveUsers(self.connection, self.cur)

        print 'Max users allowed: %d' % self.maxUsers
        print 'Max administrators allowed: %d' % maxAdmins
        print 'Number of users already logged in: %d' % count
        print 'Opening browsers........'

        for admin in self.admins:
            # For each administrator, create a user object and add object to users list
            self.users.append(um_utils.user(admin, 'quantel@'))
        # Set up emergency admin user
        self.ea = um_utils.user('emergencyadmin', 'faelj*34#7k89@jkl')

        # Keep logging in users until maxAdmins has been reached.
        for user in self.users:
            result = um_utils.login(user)
            if (result == 0 or result == 1):
                user.loggedin = True
            count = db_utils.getNumberOfActiveUsers(self.connection, self.cur)

        # Try and log in as emergency admin
        print '\tNumber of active users (max: %d): %d' % (maxAdmins, count)
        result = um_utils.login(self.ea)
        if (result == 0 or result == 1):
            self.ea.loggedin = True
        self.assertTrue((result == 0), 'Emergency admin unable to log in')

        print 'Sleeping for 2 secs.................'
        time.sleep(2)