def test_validate_files(self): os.chdir(self.test_directory) config = ConfigService.initialize_config(TEST_CONFIG_FILE_PATH) FileService.validate_files(config) if "*" in config.FILES: for file in config.FILES: assert file in glob.glob("*.csv")
def test_encrypt_files(self): config = ConfigService.initialize_config(TEST_CONFIG_FILE_PATH) mock_keys = { ApiKeys.SALT_KEYS: [{ "value": "test-salt-key" }], ApiKeys.ENCRYPTION_KEY: "_hSmVyMTLi-Qo_rmISp8jrH5Aob7frHp1X-28sxQZAU=" } FileService.validate_files(config) HashService.hash_files(config, mock_keys) EncryptionService.encrypt_files(config, mock_keys) assert len(config.ENCRYPTED_FILES) > 0 os.remove(config.ENCRYPTED_FILES[0]) os.remove(config.HASHED_FILES[0]) os.chdir(self.test_directory)
def run(input_file, log_file, mode): """Entry point for the INOIS application.""" log_level = logging.DEBUG if log_file else logging.CRITICAL log_location = log_file if log_file else "inois.log" logging.basicConfig(format='%(asctime)s (%(levelname)s): %(message)s', filename=log_location, level=log_level) application_mode = mode if mode == ApplicationModeKeys.SEARCH else ApplicationModeKeys.UPLOAD logging.info( Notifications.APPLICATION_STARTED.format(application_mode, datetime.now())) print("\n" + Notifications.APPLICATION_STARTED.format( application_mode, datetime.now())) print(Banner.TEXT) config = ConfigService.initialize_config(input_file=input_file) session = AuthenticationService(config).get_authorization() FileService.validate_files(config) keys = KeyService.get_keys(config, session) if application_mode == ApplicationModeKeys.UPLOAD: HashService.hash_files(config, keys) FileService.delete_chunked_files(config) EncryptionService.encrypt_files(config, keys) FileService.delete_hashed_files(config) UploadService.upload_files(config, session) FileService.delete_encrypted_files(config) elif application_mode == ApplicationModeKeys.SEARCH: search_queries = HashService.hash_records_for_search(config, keys) SearchService.search_on_all_queries(search_queries, session) os.chdir(config.LAUNCH_DIRECTORY) logging.info(Notifications.APPLICATION_TERMINATED.format(datetime.now())) print("\n" + Notifications.APPLICATION_TERMINATED.format(datetime.now()))