Skip to content

Commit 3c046b1

Browse files
committed
refactor: move authorization test for guests to new mod
1 parent e953836 commit 3c046b1

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

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

+26-18
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ mod for_guests {
2323
use crate::common::client::Client;
2424
use crate::common::contexts::category::fixtures::software_predefined_category_id;
2525
use crate::common::contexts::torrent::asserts::assert_expected_torrent_details;
26-
use crate::common::contexts::torrent::fixtures::{random_torrent, TestTorrent};
27-
use crate::common::contexts::torrent::forms::UploadTorrentMultipartForm;
26+
use crate::common::contexts::torrent::fixtures::TestTorrent;
2827
use crate::common::contexts::torrent::requests::InfoHash;
2928
use crate::common::contexts::torrent::responses::{
3029
Category, File, TorrentDetails, TorrentDetailsResponse, TorrentListResponse,
@@ -429,22 +428,6 @@ mod for_guests {
429428
assert_eq!(response.status, 404);
430429
}
431430

432-
#[tokio::test]
433-
async fn it_should_not_allow_guests_to_upload_torrents() {
434-
let mut env = TestEnv::new();
435-
env.start(api::Version::V1).await;
436-
437-
let client = Client::unauthenticated(&env.server_socket_addr().unwrap());
438-
439-
let test_torrent = random_torrent();
440-
441-
let form: UploadTorrentMultipartForm = test_torrent.index_info.into();
442-
443-
let response = client.upload_torrent(form.into()).await;
444-
445-
assert_eq!(response.status, 401);
446-
}
447-
448431
#[tokio::test]
449432
async fn it_should_not_allow_guests_to_delete_torrents() {
450433
let mut env = TestEnv::new();
@@ -464,6 +447,31 @@ mod for_guests {
464447

465448
assert_eq!(response.status, 401);
466449
}
450+
451+
mod authorization {
452+
use torrust_index::web::api;
453+
454+
use crate::common::client::Client;
455+
use crate::common::contexts::torrent::fixtures::random_torrent;
456+
use crate::common::contexts::torrent::forms::UploadTorrentMultipartForm;
457+
use crate::e2e::environment::TestEnv;
458+
459+
#[tokio::test]
460+
async fn it_should_not_allow_guests_to_upload_torrents() {
461+
let mut env = TestEnv::new();
462+
env.start(api::Version::V1).await;
463+
464+
let client = Client::unauthenticated(&env.server_socket_addr().unwrap());
465+
466+
let test_torrent = random_torrent();
467+
468+
let form: UploadTorrentMultipartForm = test_torrent.index_info.into();
469+
470+
let response = client.upload_torrent(form.into()).await;
471+
472+
assert_eq!(response.status, 401);
473+
}
474+
}
467475
}
468476

469477
mod for_authenticated_users {

0 commit comments

Comments
 (0)