def test_fixConfigOwnerships(): configfile = open(Auth.config, "w") configfile.close() assert Utils.GetLPID() != os.stat(Auth.config).st_gid assert True == Utils.FixFilePermissions(Auth.config)[1] assert Utils.GetLPID() == os.stat(Auth.config).st_gid
def test_getLPID(): assert int(Utils.GetLPID()) > 0 assert Utils.GetLPID() != None import grp workingPrintGroupName = 'lp' try: grp.getgrnam(workingPrintGroupName) except: workingPrintGroupName = 'cups' pass assert Utils.GetLPID('brokendefault', 'brokenalternative', False) == None assert int(Utils.GetLPID('brokendefault', workingPrintGroupName, False)) > 0 assert Utils.GetLPID('brokendefault', workingPrintGroupName, False) != None
def test_setupAuthOwnership(): assert Auth.SetupAuth(False, testUserIds=['test']) == (False, False) # ensure ownership is correct after creating config assert Utils.GetLPID() == os.stat(Auth.config).st_gid # add dummy details storage = multistore_file.get_credential_storage( Auth.config, Auth.clientid, 'testuseraccount', ['https://www.googleapis.com/auth/cloudprint']) credentials = client.OAuth2Credentials( 'test', Auth.clientid, 'testsecret', 'testtoken', 1, 'https://www.googleapis.com/auth/cloudprint', 'testaccount1') storage.put(credentials) # ensure ownership is correct after populating config assert Utils.GetLPID() == os.stat(Auth.config).st_gid
def test_getLPID(): assert int(Utils.GetLPID()) > 0 assert Utils.GetLPID() is not None import grp workingPrintGroupName = 'lp' try: grp.getgrnam(workingPrintGroupName) except: workingPrintGroupName = 'cups' pass assert Utils.GetLPID('brokendefault', 'brokenalternative', False) is None assert int( Utils.GetLPID( 'brokendefault', workingPrintGroupName, False)) > 0 assert Utils.GetLPID( 'brokendefault', workingPrintGroupName, False) is not None # test blacklist works assert Utils.GetLPID( workingPrintGroupName, 'brokenalternative', True, [workingPrintGroupName, 'brokendefault', 'adm', 'wheel', 'root'], True) is None