@@ -428,33 +428,15 @@ mod for_guests {
428
428
assert_eq ! ( response. status, 404 ) ;
429
429
}
430
430
431
- #[ tokio:: test]
432
- async fn it_should_not_allow_guests_to_delete_torrents ( ) {
433
- let mut env = TestEnv :: new ( ) ;
434
- env. start ( api:: Version :: V1 ) . await ;
435
-
436
- if !env. provides_a_tracker ( ) {
437
- println ! ( "test skipped. It requires a tracker to be running." ) ;
438
- return ;
439
- }
440
-
441
- let client = Client :: unauthenticated ( & env. server_socket_addr ( ) . unwrap ( ) ) ;
442
-
443
- let uploader = new_logged_in_user ( & env) . await ;
444
- let ( test_torrent, _uploaded_torrent) = upload_random_torrent_to_index ( & uploader, & env) . await ;
445
-
446
- let response = client. delete_torrent ( & test_torrent. file_info_hash ( ) ) . await ;
447
-
448
- assert_eq ! ( response. status, 401 ) ;
449
- }
450
-
451
431
mod authorization {
452
432
use torrust_index:: web:: api;
453
433
454
434
use crate :: common:: client:: Client ;
455
435
use crate :: common:: contexts:: torrent:: fixtures:: random_torrent;
456
436
use crate :: common:: contexts:: torrent:: forms:: UploadTorrentMultipartForm ;
457
437
use crate :: e2e:: environment:: TestEnv ;
438
+ use crate :: e2e:: web:: api:: v1:: contexts:: torrent:: steps:: upload_random_torrent_to_index;
439
+ use crate :: e2e:: web:: api:: v1:: contexts:: user:: steps:: new_logged_in_user;
458
440
459
441
#[ tokio:: test]
460
442
async fn it_should_not_allow_guests_to_upload_torrents ( ) {
@@ -471,6 +453,26 @@ mod for_guests {
471
453
472
454
assert_eq ! ( response. status, 401 ) ;
473
455
}
456
+
457
+ #[ tokio:: test]
458
+ async fn it_should_not_allow_guests_to_delete_torrents ( ) {
459
+ let mut env = TestEnv :: new ( ) ;
460
+ env. start ( api:: Version :: V1 ) . await ;
461
+
462
+ if !env. provides_a_tracker ( ) {
463
+ println ! ( "test skipped. It requires a tracker to be running." ) ;
464
+ return ;
465
+ }
466
+
467
+ let client = Client :: unauthenticated ( & env. server_socket_addr ( ) . unwrap ( ) ) ;
468
+
469
+ let uploader = new_logged_in_user ( & env) . await ;
470
+ let ( test_torrent, _uploaded_torrent) = upload_random_torrent_to_index ( & uploader, & env) . await ;
471
+
472
+ let response = client. delete_torrent ( & test_torrent. file_info_hash ( ) ) . await ;
473
+
474
+ assert_eq ! ( response. status, 401 ) ;
475
+ }
474
476
}
475
477
}
476
478
0 commit comments