예제 #1
0
    def test_administrators(self):
        self.user = um_utils.user(self.admin, 'quantel@')
        result = um_utils.login(self.user)
        if (result == 0 or result == 1):
            self.user.loggedin = True
        self.assertTrue((result == 0 or result == 1),
                        'Test Failed: User could not log in.')

        # Delete all existing licenses
        db_utils.deleteAllLicenses(self.connection, self.cur)

        for x in range(0, 7):
            # Check user every minute to see if still logged in
            print 'Sleeping for 60 secs.................'
            time.sleep(60)

            # Check that user is still logged in
            if (db_utils.isUserLoggedIn(self.connection, self.cur, self.user)):
                print 'User still logged in after %d minutes' % (x + 1)
            self.assertTrue((db_utils.isUserLoggedIn(self.connection, self.cur,
                                                     self.user)),
                            'Test Failed: User has been logged out')

        print 'Sleeping for 2 secs.................'
        time.sleep(2)
예제 #2
0
    def setUpClass(inst):
        print 'Start of test: test_license_invalid_version'
        # List of editors i.e. users that do not have admin rights
        inst.editors = [
            'chloe.anderson', 'chloe.garcia', 'chloe.jackson', 'chloe.johnson',
            'chloe.jones', 'chloe.lee'
        ]
        # List of managers i.e. users with manager rights
        inst.managers = [
            'maria.a', 'maria.b', 'maria.c', 'maria.d', 'maria.e', 'maria.f',
            'maria.g'
        ]
        # List of administrators i.e. users with administrator rights
        inst.admins = [
            'avaa.johnsona', 'avaa.whitea', 'avac.whitec', 'avad.johnsond',
            'avaf.whitef', 'avag.johnsong', 'avag.wilsong'
        ]

        # Set up connection to database
        inst.connection = db_utils.connectToDb()
        inst.cur = inst.connection.cursor()

        # Delete all existing licenses
        db_utils.deleteAllLicenses(inst.connection, inst.cur)

        # Install license with an invalid version number
        inst.maxUsers = db_utils.addUserLicenseInvalidVersion(
            inst.connection, inst.cur)
        print 'License installed with an invalid version'
예제 #3
0
    def setUpClass(inst):
        print 'Start of test: test_remove_license_table'
        # List of editors i.e. users that do not have admin rights
        inst.editors = [
            'chloe.anderson', 'chloe.garcia', 'chloe.jackson', 'chloe.johnson',
            'chloe.jones', 'chloe.lee'
        ]
        # List of managers i.e. users with manager rights
        inst.managers = [
            'maria.a', 'maria.b', 'maria.c', 'maria.d', 'maria.e', 'maria.f',
            'maria.g'
        ]
        # List of administrators i.e. users with administrator rights
        inst.admins = [
            'avaa.johnsona', 'avaa.whitea', 'avac.whitec', 'avad.johnsond',
            'avaf.whitef', 'avag.johnsong', 'avag.wilsong'
        ]

        # Set up connection to database
        inst.connection = db_utils.connectToDb()
        inst.cur = inst.connection.cursor()

        # Delete all existing licenses
        db_utils.deleteAllLicenses(inst.connection, inst.cur)

        # Delete the license table from the database
        db_utils.deleteLicencesTable(inst.connection, inst.cur)
        inst.maxUsers = 0
        print 'All licenses deleted and license tabble removed from db'
예제 #4
0
    def setUpClass(inst):
        print 'Start of test: test_valid_license'
        # List of editors i.e. users that do not have admin rights
        inst.editors = [
            'chloe.anderson', 'chloe.garcia', 'chloe.jackson', 'chloe.johnson',
            'chloe.jones', 'chloe.lee'
        ]
        # List of managers i.e. users with manager rights
        inst.managers = [
            'maria.a', 'maria.b', 'maria.c', 'maria.d', 'maria.e', 'maria.f',
            'maria.g', 'maria.h', 'maria.i', 'maria.j', 'maria.k', 'maria.l'
        ]
        # List of administrators i.e. users with administrator rights
        inst.admins = [
            'avaa.johnsona', 'avaa.whitea', 'avac.whitec', 'avad.johnsond',
            'avaf.whitef', 'avag.johnsong', 'avag.wilsong', 'avai.robinsoni',
            'aval.wilsonl', 'avag.whiteg', 'avah.wilsonh', 'avam.robinsonm'
        ]

        # Set up connection to database
        inst.connection = db_utils.connectToDb()
        inst.cur = inst.connection.cursor()

        # Delete all existing licenses
        db_utils.deleteAllLicenses(inst.connection, inst.cur)

        # Install license for five users and set the value of maxManagers
        inst.maxUsers = db_utils.addFiveUserLicense(inst.connection, inst.cur)
        print 'License installed for %d users' % inst.maxUsers
예제 #5
0
    def tearDownClass(inst):
        # Delete license and reinstall license for twenty-five users
        db_utils.deleteAllLicenses(inst.connection, inst.cur)
        maxUsers = db_utils.addTwentyFiveUserLicense(inst.connection, inst.cur)
        print 'License installed for %d users' % maxUsers

        # Close connection to database
        db_utils.closeConnection(inst.connection, inst.cur)
예제 #6
0
 def setUpClass(inst):
     print 'Start of test: test_login'
     # Username to be used for this test
     username = '******'
     inst.user = um_utils.user(username, 'quantel@')
     
     # Set up connection to database
     inst.connection = db_utils.connectToDb()    
     inst.cur = inst.connection.cursor()
      
     # Delete all existing licenses and install license for five users
     db_utils.deleteAllLicenses(inst.connection, inst.cur)
     inst.maxUsers = db_utils.addFiveUserLicense(inst.connection, inst.cur)
     print 'License installed for %d users' % inst.maxUsers  
예제 #7
0
    def setUpClass(inst):
        print 'Start of test: test_remove_license'
        # Name of administrator to be used for this test
        inst.admin = 'avaa.johnsona'
        # Name of editor to be used for this test
        inst.editor = 'chloe.anderson'
        # Name of manager to be used for this test
        inst.manager = 'maria.a'

        # Set up connection to database
        inst.connection = db_utils.connectToDb()
        inst.cur = inst.connection.cursor()

        # Delete all existing licenses
        db_utils.deleteAllLicenses(inst.connection, inst.cur)
예제 #8
0
    def test_editors(self):
        self.user = um_utils.user(self.editor, 'quantel@')
        result = um_utils.login(self.user)
        print 'Result = %d' % result
        if (result == 0 or result == 1):
            self.user.loggedin = True
        self.assertTrue((result == 0 or result == 1),
                        'Test Failed: User could not log in.')

        # Delete all existing licenses
        db_utils.deleteAllLicenses(self.connection, self.cur)

        for x in range(0, 5):
            # Check user every minute to see if still logged in
            print 'Sleeping for 60 secs.................'
            time.sleep(60)

            # Check that user is still logged in
            if (db_utils.isUserLoggedIn(self.connection, self.cur, self.user)):
                print 'User still logged in after %d minutes' % (x + 1)
            self.assertTrue(
                (db_utils.isUserLoggedIn(self.connection, self.cur,
                                         self.user)),
                'Test Failed: User has been logged out after %d minutes' %
                (x + 1))

        # If still logged in after five minutes, wait another 120 seconds and check that user has been logged out
        print 'Sleeping for 120 secs.................'
        time.sleep(120)
        if (db_utils.isUserLoggedIn(self.connection, self.cur,
                                    self.user) == False):
            print 'User has been successfully logged out'

        self.assertFalse(
            db_utils.isUserLoggedIn(self.connection, self.cur, self.user),
            'Test Failed: User has not been logged out after seven minutes')

        print 'Sleeping for 2 secs.................'
        time.sleep(2)
예제 #9
0
 def setUp(inst):
     # Delete all existing licenses at the start of each test
     db_utils.deleteAllLicenses(inst.connection, inst.cur)