Skip to content

Commit

Permalink
test: new test for registered users to upload torrents
Browse files Browse the repository at this point in the history
  • Loading branch information
mario-nt committed Oct 3, 2024
1 parent d2b1270 commit b1c1b55
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/e2e/web/api/v1/contexts/torrent/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,38 @@ mod for_authenticated_users {

assert_eq!(response.status, 403);
}
mod authorization {
use torrust_index::web::api;

use crate::common::client::Client;
use crate::common::contexts::torrent::fixtures::random_torrent;
use crate::common::contexts::torrent::forms::UploadTorrentMultipartForm;
use crate::e2e::environment::TestEnv;
use crate::e2e::web::api::v1::contexts::user::steps::new_logged_in_user;

#[tokio::test]
async fn it_should_allow_registered_users_to_upload_torrents() {
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 registered_user = new_logged_in_user(&env).await;

let client = Client::authenticated(&env.server_socket_addr().unwrap(), &registered_user.token);

let test_torrent = random_torrent();

let form: UploadTorrentMultipartForm = test_torrent.index_info.into();

let response = client.upload_torrent(form.into()).await;

assert_eq!(response.status, 200);
}
}
}

mod and_torrent_owners {
Expand Down

0 comments on commit b1c1b55

Please sign in to comment.