@@ -410,7 +410,7 @@ mod for_guests {
410
410
411
411
use crate :: common:: client:: Client ;
412
412
use crate :: common:: contexts:: torrent:: fixtures:: random_torrent;
413
- use crate :: common:: contexts:: torrent:: forms:: UploadTorrentMultipartForm ;
413
+ use crate :: common:: contexts:: torrent:: forms:: { UpdateTorrentFrom , UploadTorrentMultipartForm } ;
414
414
use crate :: common:: contexts:: torrent:: responses:: TorrentListResponse ;
415
415
use crate :: common:: http:: Query ;
416
416
use crate :: e2e:: environment:: TestEnv ;
@@ -568,6 +568,39 @@ mod for_guests {
568
568
569
569
assert_eq ! ( response. status, 200 ) ;
570
570
}
571
+
572
+ #[ tokio:: test]
573
+ async fn it_should_not_allow_guest_users_to_update_torrents ( ) {
574
+ let mut env = TestEnv :: new ( ) ;
575
+ env. start ( api:: Version :: V1 ) . await ;
576
+
577
+ if !env. provides_a_tracker ( ) {
578
+ println ! ( "test skipped. It requires a tracker to be running." ) ;
579
+ return ;
580
+ }
581
+
582
+ let uploader = new_logged_in_user ( & env) . await ;
583
+ let ( test_torrent, _uploaded_torrent) = upload_random_torrent_to_index ( & uploader, & env) . await ;
584
+
585
+ let client = Client :: unauthenticated ( & env. server_socket_addr ( ) . unwrap ( ) ) ;
586
+
587
+ let new_title = format ! ( "{}-new-title" , test_torrent. index_info. title) ;
588
+ let new_description = format ! ( "{}-new-description" , test_torrent. index_info. description) ;
589
+
590
+ let response = client
591
+ . update_torrent (
592
+ & test_torrent. file_info_hash ( ) ,
593
+ UpdateTorrentFrom {
594
+ title : Some ( new_title. clone ( ) ) ,
595
+ description : Some ( new_description. clone ( ) ) ,
596
+ category : None ,
597
+ tags : None ,
598
+ } ,
599
+ )
600
+ . await ;
601
+
602
+ assert_eq ! ( response. status, 401 ) ;
603
+ }
571
604
}
572
605
}
573
606
0 commit comments