diff --git a/tests/e2e/web/api/v1/contexts/torrent/contract.rs b/tests/e2e/web/api/v1/contexts/torrent/contract.rs index 909ec230..e09cc24d 100644 --- a/tests/e2e/web/api/v1/contexts/torrent/contract.rs +++ b/tests/e2e/web/api/v1/contexts/torrent/contract.rs @@ -414,7 +414,7 @@ mod for_guests { use crate::common::contexts::torrent::responses::TorrentListResponse; use crate::common::http::Query; use crate::e2e::environment::TestEnv; - use crate::e2e::web::api::v1::contexts::torrent::steps::upload_random_torrent_to_index; + use crate::e2e::web::api::v1::contexts::torrent::steps::{upload_random_torrent_to_index, upload_test_torrent}; use crate::e2e::web::api::v1::contexts::user::steps::new_logged_in_user; #[tokio::test] @@ -475,6 +475,33 @@ mod for_guests { assert_eq!(response.status, 200); } + #[tokio::test] + async fn it_should_allow_guests_to_download_a_torrent_file_searching_by_canonical_info_hash() { + let mut env = TestEnv::new(); + env.start(api::Version::V1).await; + + if !env.provides_a_tracker() { + println!("test skipped. It requires a tracker to be running."); + return; + } + + let download_client = Client::unauthenticated(&env.server_socket_addr().unwrap()); + + let uploader = new_logged_in_user(&env).await; + + let upload_client = Client::authenticated(&env.server_socket_addr().unwrap(), &uploader.token); + + // Upload + let test_torrent = random_torrent(); + + let canonical_infohash = upload_test_torrent(&upload_client, &test_torrent).await.unwrap().to_string(); + + // Download + let response = download_client.download_torrent(&canonical_infohash).await; + + assert_eq!(response.status, 200); + } + #[tokio::test] async fn it_should_allow_guests_to_get_torrents() { let mut env = TestEnv::new();