From 49ff3a3f265d4f3f2de2d8978c420cd6f09216ec Mon Sep 17 00:00:00 2001 From: Vince Rose Date: Tue, 30 Jan 2024 23:12:10 -0700 Subject: [PATCH] fix new test for sqlite --- empire/test/test_agents.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/empire/test/test_agents.py b/empire/test/test_agents.py index 85ab9fe28..4c4d7d1a8 100644 --- a/empire/test/test_agents.py +++ b/empire/test/test_agents.py @@ -258,7 +258,7 @@ def test_update_dir_list(session_local, models, agent, main: MainMenu): def test_update_dir_list_with_existing_joined_file( - session_local, models, agent, main: MainMenu + session_local, models, agent, main: MainMenu, empire_config ): with session_local.begin() as db: message = { @@ -286,7 +286,7 @@ def test_update_dir_list_with_existing_joined_file( download_path = Path("empire/test/avatar.png") file.downloads.append( models.Download( - location=download_path.absolute(), + location=str(download_path.absolute()), filename=download_path.name, size=download_path.stat().st_size, ) @@ -299,8 +299,13 @@ def test_update_dir_list_with_existing_joined_file( db, agent, "C:\\Users\\vinnybod\\Desktop\\test.txt" ) - assert file.id != file2.id - assert len(file2.downloads) == 0 + if empire_config.database.use != "sqlite": + # sqlite reuses ids and apparently doesn't cascade the delete to the + # association table. This can result in files being linked to the wrong + # download after refreshing a directory for sqlite. + assert file.id != file2.id + assert len(file2.downloads) == 0 + assert file.name == file2.name db.query(models.AgentFile).delete()