def test_100_auth_db(self): for kind in self.config_list(): config = self.config_obj(kind, base=False) msg = 'Could not store {0} config'.format(kind) self.assertTrue(self.authm.storeAuthenticationConfig(config), msg) msg = 'Could not store a sample of all configs in auth db' self.assertTrue( (len(self.authm.configIds()) == len(self.config_list())), msg) msg = 'Could not retrieve available configs from auth db' self.assertTrue(len(self.authm.availableAuthMethodConfigs()) > 0, msg) backup = None resetpass, backup = self.authm.resetMasterPassword( 'newpass', self.mpass, True, backup) msg = 'Could not reset master password and/or re-encrypt configs' self.assertTrue(resetpass, msg) # qDebug('Backup db path: {0}'.format(backup)) msg = 'Could not retrieve backup path for reset master password op' self.assertIsNotNone(backup) self.assertTrue(backup != self.authm.authenticationDatabasePath(), msg) msg = 'Could not verify reset master password' self.assertTrue(self.authm.setMasterPassword('newpass', True), msg) msg = 'Could not remove all configs from auth db' self.assertTrue(self.authm.removeAllAuthenticationConfigs(), msg) msg = 'Configs were not removed from auth db' self.assertTrue(len(self.authm.configIds()) == 0, msg) msg = 'Auth db does not exist' self.assertTrue( os.path.exists(self.authm.authenticationDatabasePath()), msg) QTest.qSleep(1000) # necessary for new backup to have different name msg = 'Could not erase auth db' backup = None reserase, backup = \ self.authm.eraseAuthenticationDatabase(True, backup) self.assertTrue(reserase, msg) # qDebug('Erase db backup db path: {0}'.format(backup)) msg = 'Could not retrieve backup path for erase db op' self.assertIsNotNone(backup) self.assertTrue(backup != self.authm.authenticationDatabasePath(), msg) msg = 'Master password not erased from auth db' self.assertTrue( not self.authm.masterPasswordIsSet() and not self.authm.masterPasswordHashInDatabase(), msg) self.set_master_password()
def test_100_auth_db(self): for kind in self.config_list(): config = self.config_obj(kind, base=False) msg = 'Could not store {0} config'.format(kind) self.assertTrue(self.authm.storeAuthenticationConfig(config), msg) msg = 'Could not store a sample of all configs in auth db' self.assertTrue( (len(self.authm.configIds()) == len(self.config_list())), msg) msg = 'Could not retrieve available configs from auth db' self.assertTrue(len(self.authm.availableAuthMethodConfigs()) > 0, msg) backup = None resetpass, backup = self.authm.resetMasterPassword( 'newpass', self.mpass, True, backup) msg = 'Could not reset master password and/or re-encrypt configs' self.assertTrue(resetpass, msg) # qDebug('Backup db path: {0}'.format(backup)) msg = 'Could not retrieve backup path for reset master password op' self.assertIsNotNone(backup) self.assertTrue(backup != self.authm.authenticationDatabasePath(), msg) msg = 'Could not verify reset master password' self.assertTrue(self.authm.setMasterPassword('newpass', True), msg) msg = 'Could not remove all configs from auth db' self.assertTrue(self.authm.removeAllAuthenticationConfigs(), msg) msg = 'Configs were not removed from auth db' self.assertTrue(len(self.authm.configIds()) == 0, msg) msg = 'Auth db does not exist' self.assertTrue(os.path.exists(self.authm.authenticationDatabasePath()), msg) QTest.qSleep(1000) # necessary for new backup to have different name msg = 'Could not erase auth db' backup = None reserase, backup = \ self.authm.eraseAuthenticationDatabase(True, backup) self.assertTrue(reserase, msg) # qDebug('Erase db backup db path: {0}'.format(backup)) msg = 'Could not retrieve backup path for erase db op' self.assertIsNotNone(backup) self.assertTrue(backup != self.authm.authenticationDatabasePath(), msg) msg = 'Master password not erased from auth db' self.assertTrue(not self.authm.masterPasswordIsSet() and not self.authm.masterPasswordHashInDatabase(), msg) self.set_master_password()