Skip to content

Commit 663250b

Browse files
committed
refactor: [torrust#1195] rename methods
1 parent 9c61b26 commit 663250b

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/core/authentication/mod.rs

+16-14
Original file line numberDiff line numberDiff line change
@@ -153,27 +153,29 @@ mod tests {
153153
use crate::core::authentication;
154154
use crate::core::services::initialize_database;
155155

156-
fn instantiate_authentication() -> authentication::Facade {
156+
fn instantiate_authentication_facade() -> authentication::Facade {
157157
let config = configuration::ephemeral_private();
158158

159159
let database = initialize_database(&config);
160+
160161
authentication::Facade::new(&config.core, &database.clone())
161162
}
162163

163-
fn instantiate_authentication_with_checking_keys_expiration_disabled() -> authentication::Facade {
164+
fn instantiate_authentication_facade_with_checking_keys_expiration_disabled() -> authentication::Facade {
164165
let mut config = configuration::ephemeral_private();
165166

166167
config.core.private_mode = Some(PrivateMode {
167168
check_keys_expiration: false,
168169
});
169170

170171
let database = initialize_database(&config);
172+
171173
authentication::Facade::new(&config.core, &database.clone())
172174
}
173175

174176
#[tokio::test]
175177
async fn it_should_remove_an_authentication_key() {
176-
let authentication = instantiate_authentication();
178+
let authentication = instantiate_authentication_facade();
177179

178180
let expiring_key = authentication
179181
.generate_auth_key(Some(Duration::from_secs(100)))
@@ -194,7 +196,7 @@ mod tests {
194196

195197
#[tokio::test]
196198
async fn it_should_load_authentication_keys_from_the_database() {
197-
let authentication = instantiate_authentication();
199+
let authentication = instantiate_authentication_facade();
198200

199201
let expiring_key = authentication
200202
.generate_auth_key(Some(Duration::from_secs(100)))
@@ -222,13 +224,13 @@ mod tests {
222224
use std::time::Duration;
223225

224226
use crate::core::authentication::tests::the_tracker_configured_as_private::{
225-
instantiate_authentication, instantiate_authentication_with_checking_keys_expiration_disabled,
227+
instantiate_authentication_facade, instantiate_authentication_facade_with_checking_keys_expiration_disabled,
226228
};
227229
use crate::core::authentication::Key;
228230

229231
#[tokio::test]
230232
async fn it_should_authenticate_a_peer_with_the_key() {
231-
let authentication = instantiate_authentication();
233+
let authentication = instantiate_authentication_facade();
232234

233235
let peer_key = authentication
234236
.generate_auth_key(Some(Duration::from_secs(100)))
@@ -242,7 +244,7 @@ mod tests {
242244

243245
#[tokio::test]
244246
async fn it_should_accept_an_expired_key_when_checking_expiration_is_disabled_in_configuration() {
245-
let authentication = instantiate_authentication_with_checking_keys_expiration_disabled();
247+
let authentication = instantiate_authentication_facade_with_checking_keys_expiration_disabled();
246248

247249
let past_timestamp = Duration::ZERO;
248250

@@ -258,13 +260,13 @@ mod tests {
258260
mod pre_generated_keys {
259261

260262
use crate::core::authentication::tests::the_tracker_configured_as_private::{
261-
instantiate_authentication, instantiate_authentication_with_checking_keys_expiration_disabled,
263+
instantiate_authentication_facade, instantiate_authentication_facade_with_checking_keys_expiration_disabled,
262264
};
263265
use crate::core::authentication::{AddKeyRequest, Key};
264266

265267
#[tokio::test]
266268
async fn it_should_authenticate_a_peer_with_the_key() {
267-
let authentication = instantiate_authentication();
269+
let authentication = instantiate_authentication_facade();
268270

269271
let peer_key = authentication
270272
.add_peer_key(AddKeyRequest {
@@ -281,7 +283,7 @@ mod tests {
281283

282284
#[tokio::test]
283285
async fn it_should_accept_an_expired_key_when_checking_expiration_is_disabled_in_configuration() {
284-
let authentication = instantiate_authentication_with_checking_keys_expiration_disabled();
286+
let authentication = instantiate_authentication_facade_with_checking_keys_expiration_disabled();
285287

286288
let peer_key = authentication
287289
.add_peer_key(AddKeyRequest {
@@ -299,11 +301,11 @@ mod tests {
299301
mod with_permanent_and {
300302

301303
mod randomly_generated_keys {
302-
use crate::core::authentication::tests::the_tracker_configured_as_private::instantiate_authentication;
304+
use crate::core::authentication::tests::the_tracker_configured_as_private::instantiate_authentication_facade;
303305

304306
#[tokio::test]
305307
async fn it_should_authenticate_a_peer_with_the_key() {
306-
let authentication = instantiate_authentication();
308+
let authentication = instantiate_authentication_facade();
307309

308310
let peer_key = authentication.generate_permanent_auth_key().await.unwrap();
309311

@@ -314,12 +316,12 @@ mod tests {
314316
}
315317

316318
mod pre_generated_keys {
317-
use crate::core::authentication::tests::the_tracker_configured_as_private::instantiate_authentication;
319+
use crate::core::authentication::tests::the_tracker_configured_as_private::instantiate_authentication_facade;
318320
use crate::core::authentication::{AddKeyRequest, Key};
319321

320322
#[tokio::test]
321323
async fn it_should_authenticate_a_peer_with_the_key() {
322-
let authentication = instantiate_authentication();
324+
let authentication = instantiate_authentication_facade();
323325

324326
let peer_key = authentication
325327
.add_peer_key(AddKeyRequest {

0 commit comments

Comments
 (0)