@@ -1217,8 +1217,10 @@ mod configured_as_whitelisted {
1217
1217
1218
1218
use bittorrent_primitives:: info_hash:: InfoHash ;
1219
1219
use torrust_tracker_test_helpers:: configuration;
1220
+ use uuid:: Uuid ;
1220
1221
1221
- use crate :: common:: logging:: { self } ;
1222
+ use crate :: common:: fixtures:: random_info_hash;
1223
+ use crate :: common:: logging:: { self , logs_contains_a_line_with} ;
1222
1224
use crate :: servers:: http:: asserts:: { assert_is_announce_response, assert_torrent_not_in_whitelist_error_response} ;
1223
1225
use crate :: servers:: http:: client:: Client ;
1224
1226
use crate :: servers:: http:: requests:: announce:: QueryBuilder ;
@@ -1230,14 +1232,24 @@ mod configured_as_whitelisted {
1230
1232
1231
1233
let env = Started :: new ( & configuration:: ephemeral_listed ( ) . into ( ) ) . await ;
1232
1234
1233
- let info_hash = InfoHash :: from_str ( "9c38422213e30bff212b30c360d26f9a02136422" ) . unwrap ( ) ;
1235
+ let request_id = Uuid :: new_v4 ( ) ;
1236
+ let info_hash = random_info_hash ( ) ;
1234
1237
1235
1238
let response = Client :: new ( * env. bind_address ( ) )
1236
- . announce ( & QueryBuilder :: default ( ) . with_info_hash ( & info_hash) . query ( ) )
1239
+ . announce_with_header (
1240
+ & QueryBuilder :: default ( ) . with_info_hash ( & info_hash) . query ( ) ,
1241
+ "x-request-id" ,
1242
+ & request_id. to_string ( ) ,
1243
+ )
1237
1244
. await ;
1238
1245
1239
1246
assert_torrent_not_in_whitelist_error_response ( response) . await ;
1240
1247
1248
+ assert ! (
1249
+ logs_contains_a_line_with( & [ "ERROR" , & format!( "{info_hash}" ) , "is not whitelisted" ] ) ,
1250
+ "Expected logs to contain: ERROR ... {info_hash} is not whitelisted"
1251
+ ) ;
1252
+
1241
1253
env. stop ( ) . await ;
1242
1254
}
1243
1255
@@ -1272,7 +1284,8 @@ mod configured_as_whitelisted {
1272
1284
use torrust_tracker_primitives:: peer:: fixture:: PeerBuilder ;
1273
1285
use torrust_tracker_test_helpers:: configuration;
1274
1286
1275
- use crate :: common:: logging:: { self } ;
1287
+ use crate :: common:: fixtures:: random_info_hash;
1288
+ use crate :: common:: logging:: { self , logs_contains_a_line_with} ;
1276
1289
use crate :: servers:: http:: asserts:: assert_scrape_response;
1277
1290
use crate :: servers:: http:: client:: Client ;
1278
1291
use crate :: servers:: http:: responses:: scrape:: { File , ResponseBuilder } ;
@@ -1284,7 +1297,7 @@ mod configured_as_whitelisted {
1284
1297
1285
1298
let env = Started :: new ( & configuration:: ephemeral_listed ( ) . into ( ) ) . await ;
1286
1299
1287
- let info_hash = InfoHash :: from_str ( "9c38422213e30bff212b30c360d26f9a02136422" ) . unwrap ( ) ;
1300
+ let info_hash = random_info_hash ( ) ;
1288
1301
1289
1302
env. add_torrent_peer (
1290
1303
& info_hash,
@@ -1306,6 +1319,11 @@ mod configured_as_whitelisted {
1306
1319
1307
1320
assert_scrape_response ( response, & expected_scrape_response) . await ;
1308
1321
1322
+ assert ! (
1323
+ logs_contains_a_line_with( & [ "ERROR" , & format!( "{info_hash}" ) , "is not whitelisted" ] ) ,
1324
+ "Expected logs to contain: ERROR ... {info_hash} is not whitelisted"
1325
+ ) ;
1326
+
1309
1327
env. stop ( ) . await ;
1310
1328
}
1311
1329
0 commit comments