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()