Skip to content

Commit 3f862b6

Browse files
committed
test: new test for downloading a torrent using the canonical info hash
1 parent cad72ae commit 3f862b6

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

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

+28-1
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ mod for_guests {
414414
use crate::common::contexts::torrent::responses::TorrentListResponse;
415415
use crate::common::http::Query;
416416
use crate::e2e::environment::TestEnv;
417-
use crate::e2e::web::api::v1::contexts::torrent::steps::upload_random_torrent_to_index;
417+
use crate::e2e::web::api::v1::contexts::torrent::steps::{upload_random_torrent_to_index, upload_test_torrent};
418418
use crate::e2e::web::api::v1::contexts::user::steps::new_logged_in_user;
419419

420420
#[tokio::test]
@@ -475,6 +475,33 @@ mod for_guests {
475475
assert_eq!(response.status, 200);
476476
}
477477

478+
#[tokio::test]
479+
async fn it_should_allow_guests_to_download_a_torrent_file_searching_by_canonical_info_hash() {
480+
let mut env = TestEnv::new();
481+
env.start(api::Version::V1).await;
482+
483+
if !env.provides_a_tracker() {
484+
println!("test skipped. It requires a tracker to be running.");
485+
return;
486+
}
487+
488+
let download_client = Client::unauthenticated(&env.server_socket_addr().unwrap());
489+
490+
let uploader = new_logged_in_user(&env).await;
491+
492+
let upload_client = Client::authenticated(&env.server_socket_addr().unwrap(), &uploader.token);
493+
494+
// Upload
495+
let test_torrent = random_torrent();
496+
497+
let canonical_infohash = upload_test_torrent(&upload_client, &test_torrent).await.unwrap().to_string();
498+
499+
// Download
500+
let response = download_client.download_torrent(&canonical_infohash).await;
501+
502+
assert_eq!(response.status, 200);
503+
}
504+
478505
#[tokio::test]
479506
async fn it_should_allow_guests_to_get_torrents() {
480507
let mut env = TestEnv::new();

0 commit comments

Comments
 (0)