@@ -7,7 +7,7 @@ use key::repository::persisted::DatabaseKeyRepository;
7
7
use torrust_tracker_configuration:: Core ;
8
8
use torrust_tracker_primitives:: DurationSinceUnixEpoch ;
9
9
10
- use super :: databases:: { self , Database } ;
10
+ use super :: databases:: { self } ;
11
11
use super :: error:: PeerKeyError ;
12
12
use crate :: CurrentClock ;
13
13
@@ -29,12 +29,13 @@ pub struct Facade {
29
29
30
30
impl Facade {
31
31
#[ must_use]
32
- pub fn new ( config : & Core , database : & Arc < Box < dyn Database > > ) -> Self {
33
- let db_key_repository = Arc :: new ( DatabaseKeyRepository :: new ( database) ) ;
34
- let in_memory_key_repository = Arc :: new ( InMemoryKeyRepository :: default ( ) ) ;
35
-
32
+ pub fn new (
33
+ config : & Core ,
34
+ db_key_repository : & Arc < DatabaseKeyRepository > ,
35
+ in_memory_key_repository : & Arc < InMemoryKeyRepository > ,
36
+ ) -> Self {
36
37
Self {
37
- authentication_service : service:: Service :: new ( config, & in_memory_key_repository) ,
38
+ authentication_service : service:: Service :: new ( config, in_memory_key_repository) ,
38
39
keys_handler : KeysHandler :: new ( & db_key_repository. clone ( ) , & in_memory_key_repository. clone ( ) ) ,
39
40
}
40
41
}
@@ -145,20 +146,22 @@ mod tests {
145
146
146
147
mod the_tracker_configured_as_private {
147
148
149
+ use std:: sync:: Arc ;
148
150
use std:: time:: Duration ;
149
151
150
152
use torrust_tracker_configuration:: v2_0_0:: core:: PrivateMode ;
153
+ use torrust_tracker_configuration:: Configuration ;
151
154
use torrust_tracker_test_helpers:: configuration;
152
155
153
156
use crate :: core:: authentication;
157
+ use crate :: core:: authentication:: key:: repository:: in_memory:: InMemoryKeyRepository ;
158
+ use crate :: core:: authentication:: key:: repository:: persisted:: DatabaseKeyRepository ;
154
159
use crate :: core:: services:: initialize_database;
155
160
156
161
fn instantiate_authentication_facade ( ) -> authentication:: Facade {
157
162
let config = configuration:: ephemeral_private ( ) ;
158
163
159
- let database = initialize_database ( & config) ;
160
-
161
- authentication:: Facade :: new ( & config. core , & database. clone ( ) )
164
+ instantiate_authentication_facade_with_configuration ( & config)
162
165
}
163
166
164
167
fn instantiate_authentication_facade_with_checking_keys_expiration_disabled ( ) -> authentication:: Facade {
@@ -168,9 +171,16 @@ mod tests {
168
171
check_keys_expiration : false ,
169
172
} ) ;
170
173
171
- let database = initialize_database ( & config) ;
172
-
173
- authentication:: Facade :: new ( & config. core , & database. clone ( ) )
174
+ instantiate_authentication_facade_with_configuration ( & config)
175
+ }
176
+
177
+ fn instantiate_authentication_facade_with_configuration ( config : & Configuration ) -> authentication:: Facade {
178
+ let database = initialize_database ( config) ;
179
+
180
+ let db_key_repository = Arc :: new ( DatabaseKeyRepository :: new ( & database) ) ;
181
+ let in_memory_key_repository = Arc :: new ( InMemoryKeyRepository :: default ( ) ) ;
182
+
183
+ authentication:: Facade :: new ( & config. core , & db_key_repository. clone ( ) , & in_memory_key_repository. clone ( ) )
174
184
}
175
185
176
186
#[ tokio:: test]
0 commit comments