Skip to content

Commit d2b1270

Browse files
committed
test: new authorization test for guests updating torrents
1 parent 9df66e6 commit d2b1270

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

tests/e2e/web/api/v1/contexts/torrent/contract.rs

+34-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ mod for_guests {
410410

411411
use crate::common::client::Client;
412412
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};
414414
use crate::common::contexts::torrent::responses::TorrentListResponse;
415415
use crate::common::http::Query;
416416
use crate::e2e::environment::TestEnv;
@@ -568,6 +568,39 @@ mod for_guests {
568568

569569
assert_eq!(response.status, 200);
570570
}
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+
}
571604
}
572605
}
573606

0 commit comments

Comments
 (0)