Skip to content

Commit d29fe5b

Browse files
committed
test: new test for admin users to download a torrent searching by canonical info hash
1 parent 5783556 commit d29fe5b

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ mod and_admins {
13711371
e2e::{
13721372
environment::TestEnv,
13731373
web::api::v1::contexts::{
1374-
torrent::steps::upload_random_torrent_to_index,
1374+
torrent::steps::{upload_random_torrent_to_index, upload_test_torrent},
13751375
user::steps::{new_logged_in_admin, new_logged_in_user},
13761376
},
13771377
},
@@ -1444,5 +1444,36 @@ mod and_admins {
14441444

14451445
assert_eq!(response.status, 200);
14461446
}
1447+
1448+
#[tokio::test]
1449+
async fn it_should_allow_admin_users_to_download_a_torrent_file_searching_by_canonical_info_hash() {
1450+
let mut env = TestEnv::new();
1451+
env.start(api::Version::V1).await;
1452+
1453+
if !env.provides_a_tracker() {
1454+
println!("test skipped. It requires a tracker to be running.");
1455+
return;
1456+
}
1457+
1458+
let uploader = new_logged_in_user(&env).await;
1459+
1460+
let upload_client = Client::authenticated(&env.server_socket_addr().unwrap(), &uploader.token);
1461+
1462+
let admin = new_logged_in_admin(&env).await;
1463+
1464+
let download_client = Client::authenticated(&env.server_socket_addr().unwrap(), &admin.token);
1465+
1466+
// Upload
1467+
1468+
let test_torrent = random_torrent();
1469+
1470+
let canonical_infohash = upload_test_torrent(&upload_client, &test_torrent).await.unwrap().to_string();
1471+
1472+
// Download
1473+
1474+
let response = download_client.download_torrent(&canonical_infohash).await;
1475+
1476+
assert_eq!(response.status, 200);
1477+
}
14471478
}
14481479
}

0 commit comments

Comments
 (0)