diff --git a/admin/test/scripts/test_module.py b/admin/test/scripts/test_module.py index f245b14..208a50a 100644 --- a/admin/test/scripts/test_module.py +++ b/admin/test/scripts/test_module.py @@ -210,6 +210,11 @@ def mocked_lava_get_full_media_info(_media_ref_id): all_artifacts_info = getattr(module, '__artifacts_v2__', {}) artifact_info = all_artifacts_info.get(artifact_name, {}) + # The case zip is extracted into temp_dir, so temp_dir is this run's + # equivalent of the seeker's data folder. Without it get_relative_path + # is a no-op here and a path column records the recorder's own + # directory instead of the extraction-relative path. + Context.set_data_folder(str(temp_dir)) Context.set_report_folder(str(mock_report_folder_path)) Context.set_seeker(mock_seeker) Context.set_files_found(all_files) diff --git a/scripts/context.py b/scripts/context.py index 0903738..89a5862 100644 --- a/scripts/context.py +++ b/scripts/context.py @@ -36,6 +36,24 @@ def set_output_params(output_params): Context._output_params = output_params Context._data_folder = getattr(output_params, 'data_folder', None) + @staticmethod + def set_data_folder(data_folder): + """ + Sets the folder the seeker stages evidence into, without the rest of the + output parameters. + + A normal run gets this from set_output_params. The test harness has no + OutputParameters: it extracts a case zip into its own temporary directory + and runs artifacts against that. Without this, _data_folder stays None and + get_relative_path returns every path unchanged, so an artifact that leaks + an absolute path and one that reports a relative path record identical + output and no fixture can tell them apart. + + Args: + data_folder (str): The folder evidence is staged into. + """ + Context._data_folder = data_folder + @staticmethod def set_report_folder(report_folder): """