@@ -65,54 +65,31 @@ mod tests {
65
65
66
66
use torrust_tracker_test_helpers:: configuration;
67
67
68
- use crate :: app_test:: initialize_tracker_dependencies;
69
- use crate :: core:: announce_handler:: AnnounceHandler ;
70
- use crate :: core:: scrape_handler:: ScrapeHandler ;
71
- use crate :: core:: services:: initialize_whitelist_manager;
72
- use crate :: core:: whitelist;
68
+ use super :: Authorization ;
69
+ use crate :: core:: services:: { initialize_database, initialize_whitelist_manager} ;
73
70
use crate :: core:: whitelist:: manager:: WhiteListManager ;
71
+ use crate :: core:: whitelist:: repository:: in_memory:: InMemoryWhitelist ;
74
72
75
- #[ allow( clippy:: type_complexity) ]
76
- fn whitelisted_tracker ( ) -> (
77
- Arc < AnnounceHandler > ,
78
- Arc < whitelist:: authorization:: Authorization > ,
79
- Arc < WhiteListManager > ,
80
- Arc < ScrapeHandler > ,
81
- ) {
73
+ fn initialize_whitelist_services ( ) -> ( Arc < Authorization > , Arc < WhiteListManager > ) {
82
74
let config = configuration:: ephemeral_listed ( ) ;
83
75
84
- let (
85
- database,
86
- in_memory_whitelist,
87
- whitelist_authorization,
88
- _authentication_service,
89
- in_memory_torrent_repository,
90
- db_torrent_repository,
91
- _torrents_manager,
92
- ) = initialize_tracker_dependencies ( & config) ;
93
-
76
+ let database = initialize_database ( & config) ;
77
+ let in_memory_whitelist = Arc :: new ( InMemoryWhitelist :: default ( ) ) ;
78
+ let whitelist_authorization = Arc :: new ( Authorization :: new ( & config. core , & in_memory_whitelist. clone ( ) ) ) ;
94
79
let whitelist_manager = initialize_whitelist_manager ( database. clone ( ) , in_memory_whitelist. clone ( ) ) ;
95
80
96
- let announce_handler = Arc :: new ( AnnounceHandler :: new (
97
- & config. core ,
98
- & in_memory_torrent_repository,
99
- & db_torrent_repository,
100
- ) ) ;
101
-
102
- let scrape_handler = Arc :: new ( ScrapeHandler :: new ( & whitelist_authorization, & in_memory_torrent_repository) ) ;
103
-
104
- ( announce_handler, whitelist_authorization, whitelist_manager, scrape_handler)
81
+ ( whitelist_authorization, whitelist_manager)
105
82
}
106
83
107
84
mod configured_as_whitelisted {
108
85
109
86
mod handling_authorization {
110
87
use crate :: core:: core_tests:: sample_info_hash;
111
- use crate :: core:: whitelist:: authorization:: tests:: whitelisted_tracker ;
88
+ use crate :: core:: whitelist:: authorization:: tests:: initialize_whitelist_services ;
112
89
113
90
#[ tokio:: test]
114
91
async fn it_should_authorize_the_announce_and_scrape_actions_on_whitelisted_torrents ( ) {
115
- let ( _announce_handler , whitelist_authorization, whitelist_manager, _scrape_handler ) = whitelisted_tracker ( ) ;
92
+ let ( whitelist_authorization, whitelist_manager) = initialize_whitelist_services ( ) ;
116
93
117
94
let info_hash = sample_info_hash ( ) ;
118
95
@@ -125,7 +102,7 @@ mod tests {
125
102
126
103
#[ tokio:: test]
127
104
async fn it_should_not_authorize_the_announce_and_scrape_actions_on_not_whitelisted_torrents ( ) {
128
- let ( _announce_handler , whitelist_authorization, _whitelist_manager, _scrape_handler ) = whitelisted_tracker ( ) ;
105
+ let ( whitelist_authorization, _whitelist_manager) = initialize_whitelist_services ( ) ;
129
106
130
107
let info_hash = sample_info_hash ( ) ;
131
108
0 commit comments