Skip to content

Commit 01748ad

Browse files
committed
Merge #743: Release Version 3.0.0
8383e3b release: version 3.0.0 (Jose Celano) 7f605b1 fix: clippy errors (Jose Celano) fdf62e9 docs: [#739] fix command to run with docker (Jose Celano) 15adcb9 docs: [#738] fix command (Jose Celano) 17de729 refactor: moved test to authorization mod (Mario) e3baeda test: new authorization test for guests to download a torrent file searching by info hash (Mario) 6df7a7e refactor: moved test to new authorization mod (Mario) 3c046b1 refactor: move authorization test for guests to new mod (Mario) 840e1d8 ci: move testing with MySQL to a new workflow (Jose Celano) b0a458c develop: bump to version 3.0.0-develop (Jose Celano) Pull request description: Release Version 3.0.0 ACKs for top commit: josecelano: ACK 8383e3b Tree-SHA512: 9a623e32ba350fc11798bf18b3f494bb95ced3a012d378447fa64dc658d306de2755d17d15d5a241478d3ecb54ed30e86392f3ec02360753a4fbf9bb64fc52dc
2 parents 7ebf95c + 8383e3b commit 01748ad

File tree

7 files changed

+145
-60
lines changed

7 files changed

+145
-60
lines changed

.github/workflows/e2e.yaml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Temporary execution of E2E tests using MySQL becuase it's failing
2+
# in the `testing.yml` workflows and affects deployments and releases.
3+
# See https://github.com/torrust/torrust-index/issues/580
4+
name: E2E Testing
5+
6+
on:
7+
push:
8+
pull_request:
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
13+
jobs:
14+
e2e:
15+
name: E2E
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
matrix:
20+
toolchain: [stable, nightly]
21+
22+
steps:
23+
- id: checkout
24+
name: Checkout Repository
25+
uses: actions/checkout@v4
26+
27+
- id: setup
28+
name: Setup Toolchain
29+
uses: dtolnay/rust-toolchain@stable
30+
with:
31+
toolchain: ${{ matrix.toolchain }}
32+
33+
- id: cache
34+
name: Enable Job Cache
35+
uses: Swatinem/rust-cache@v2
36+
37+
# Temporary Cleaning to avoid Rust Compiler Bug
38+
- id: clean
39+
name: Make Build Clean
40+
run: cargo clean
41+
42+
- id: test-mysql
43+
name: Run Integration Tests (MySQL)
44+
run: ./contrib/dev-tools/container/e2e/mysql/run-e2e-tests.sh

.github/workflows/testing.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,6 @@ jobs:
156156
name: Run Integration Tests (SQLite)
157157
run: ./contrib/dev-tools/container/e2e/sqlite/run-e2e-tests.sh
158158

159-
- id: test-mysql
160-
name: Run Integration Tests (MySQL)
161-
run: ./contrib/dev-tools/container/e2e/mysql/run-e2e-tests.sh
159+
#- id: test-mysql
160+
# name: Run Integration Tests (MySQL)
161+
# run: ./contrib/dev-tools/container/e2e/mysql/run-e2e-tests.sh

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ license = "AGPL-3.0-only"
2727
publish = true
2828
repository = "https://github.com/torrust/torrust-tracker"
2929
rust-version = "1.72"
30-
version = "3.0.0-rc.1"
30+
version = "3.0.0"
3131

3232
[profile.dev.package.sqlx-macros]
3333
opt-level = 3
@@ -89,7 +89,7 @@ text-to-png = "0"
8989
thiserror = "1"
9090
tokio = { version = "1", features = ["fs", "io-util", "macros", "net", "rt-multi-thread", "signal", "sync", "time"] }
9191
toml = "0"
92-
torrust-index-located-error = { version = "3.0.0-rc.1", path = "packages/located-error" }
92+
torrust-index-located-error = { version = "3.0.0", path = "packages/located-error" }
9393
tower = { version = "0.4", features = ["timeout"] }
9494
tower-http = { version = "0", features = ["compression-full", "cors", "propagate-header", "request-id", "trace"] }
9595
trace = "0.1.7"

src/lib.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,28 @@
112112
//! && mkdir -p ./storage/database
113113
//! ```
114114
//!
115-
//! Then you can run it with: `./target/release/main`
115+
//! Then you can run it with: `./target/release/torrust-index`
116116
//!
117117
//! ## Run with docker
118118
//!
119119
//! You can run the index with a pre-built docker image:
120120
//!
121121
//! ```text
122-
//! mkdir -p ./storage/database \
122+
//! cd /tmp \
123+
//! && mkdir torrust-index \
124+
//! && cd torrust-index \
125+
//! && mkdir -p ./storage/index/lib/database \
126+
//! && mkdir -p ./storage/index/log \
127+
//! && mkdir -p ./storage/index/etc \
128+
//! && sqlite3 "./storage/index/lib/database/sqlite3.db" "VACUUM;" \
123129
//! && export USER_ID=1000 \
124130
//! && docker run -it \
125-
//! --user="$USER_ID" \
131+
//! --env USER_ID="$USER_ID" \
126132
//! --publish 3001:3001/tcp \
127-
//! --volume "$(pwd)/storage":"/app/storage" \
128-
//! torrust/index
133+
//! --volume "$(pwd)/storage/index/lib":"/var/lib/torrust/index" \
134+
//! --volume "$(pwd)/storage/index/log":"/var/log/torrust/index" \
135+
//! --volume "$(pwd)/storage/index/etc":"/etc/torrust/index" \
136+
//! torrust/index:develop
129137
//! ```
130138
//!
131139
//! For more information about using docker visit the [tracker docker documentation](https://github.com/torrust/torrust-index/tree/develop/docker).

src/services/authorization.rs

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ impl Service {
7474
///
7575
/// Will return an error if:
7676
/// - The user is not authorized to perform the action.
77-
7877
pub async fn authorize(&self, action: ACTION, maybe_user_id: Option<UserId>) -> std::result::Result<(), ServiceError> {
7978
let role = self.get_role(maybe_user_id).await;
8079

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

+81-47
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,
@@ -34,29 +33,6 @@ mod for_guests {
3433
use crate::e2e::web::api::v1::contexts::torrent::steps::{upload_random_torrent_to_index, upload_test_torrent};
3534
use crate::e2e::web::api::v1::contexts::user::steps::new_logged_in_user;
3635

37-
#[tokio::test]
38-
async fn it_should_allow_guests_to_get_torrents() {
39-
let mut env = TestEnv::new();
40-
env.start(api::Version::V1).await;
41-
42-
if !env.provides_a_tracker() {
43-
println!("test skipped. It requires a tracker to be running.");
44-
return;
45-
}
46-
47-
let client = Client::unauthenticated(&env.server_socket_addr().unwrap());
48-
49-
let uploader = new_logged_in_user(&env).await;
50-
let (_test_torrent, _indexed_torrent) = upload_random_torrent_to_index(&uploader, &env).await;
51-
52-
let response = client.get_torrents(Query::empty()).await;
53-
54-
let torrent_list_response: TorrentListResponse = serde_json::from_str(&response.body).unwrap();
55-
56-
assert!(torrent_list_response.data.total > 0);
57-
assert!(response.is_json_and_ok());
58-
}
59-
6036
#[tokio::test]
6137
async fn it_should_allow_to_get_torrents_with_pagination() {
6238
let mut env = TestEnv::new();
@@ -429,40 +405,98 @@ mod for_guests {
429405
assert_eq!(response.status, 404);
430406
}
431407

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;
408+
mod authorization {
409+
use torrust_index::web::api;
436410

437-
let client = Client::unauthenticated(&env.server_socket_addr().unwrap());
411+
use crate::common::client::Client;
412+
use crate::common::contexts::torrent::fixtures::random_torrent;
413+
use crate::common::contexts::torrent::forms::UploadTorrentMultipartForm;
414+
use crate::common::contexts::torrent::responses::TorrentListResponse;
415+
use crate::common::http::Query;
416+
use crate::e2e::environment::TestEnv;
417+
use crate::e2e::web::api::v1::contexts::torrent::steps::upload_random_torrent_to_index;
418+
use crate::e2e::web::api::v1::contexts::user::steps::new_logged_in_user;
438419

439-
let test_torrent = random_torrent();
420+
#[tokio::test]
421+
async fn it_should_not_allow_guests_to_upload_torrents() {
422+
let mut env = TestEnv::new();
423+
env.start(api::Version::V1).await;
440424

441-
let form: UploadTorrentMultipartForm = test_torrent.index_info.into();
425+
let client = Client::unauthenticated(&env.server_socket_addr().unwrap());
442426

443-
let response = client.upload_torrent(form.into()).await;
427+
let test_torrent = random_torrent();
444428

445-
assert_eq!(response.status, 401);
446-
}
429+
let form: UploadTorrentMultipartForm = test_torrent.index_info.into();
447430

448-
#[tokio::test]
449-
async fn it_should_not_allow_guests_to_delete_torrents() {
450-
let mut env = TestEnv::new();
451-
env.start(api::Version::V1).await;
431+
let response = client.upload_torrent(form.into()).await;
452432

453-
if !env.provides_a_tracker() {
454-
println!("test skipped. It requires a tracker to be running.");
455-
return;
433+
assert_eq!(response.status, 401);
456434
}
457435

458-
let client = Client::unauthenticated(&env.server_socket_addr().unwrap());
436+
#[tokio::test]
437+
async fn it_should_not_allow_guests_to_delete_torrents() {
438+
let mut env = TestEnv::new();
439+
env.start(api::Version::V1).await;
459440

460-
let uploader = new_logged_in_user(&env).await;
461-
let (test_torrent, _uploaded_torrent) = upload_random_torrent_to_index(&uploader, &env).await;
441+
if !env.provides_a_tracker() {
442+
println!("test skipped. It requires a tracker to be running.");
443+
return;
444+
}
445+
446+
let client = Client::unauthenticated(&env.server_socket_addr().unwrap());
447+
448+
let uploader = new_logged_in_user(&env).await;
449+
let (test_torrent, _uploaded_torrent) = upload_random_torrent_to_index(&uploader, &env).await;
450+
451+
let response = client.delete_torrent(&test_torrent.file_info_hash()).await;
452+
453+
assert_eq!(response.status, 401);
454+
}
455+
456+
#[tokio::test]
457+
async fn it_should_allow_guests_to_download_a_torrent_file_searching_by_info_hash() {
458+
let mut env = TestEnv::new();
459+
env.start(api::Version::V1).await;
460+
461+
if !env.provides_a_tracker() {
462+
println!("test skipped. It requires a tracker to be running.");
463+
return;
464+
}
465+
466+
let client = Client::unauthenticated(&env.server_socket_addr().unwrap());
467+
let uploader = new_logged_in_user(&env).await;
462468

463-
let response = client.delete_torrent(&test_torrent.file_info_hash()).await;
469+
// Upload
470+
let (test_torrent, _torrent_listed_in_index) = upload_random_torrent_to_index(&uploader, &env).await;
471+
472+
// Download
473+
let response = client.download_torrent(&test_torrent.file_info_hash()).await;
474+
475+
assert_eq!(response.status, 200);
476+
}
464477

465-
assert_eq!(response.status, 401);
478+
#[tokio::test]
479+
async fn it_should_allow_guests_to_get_torrents() {
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 client = Client::unauthenticated(&env.server_socket_addr().unwrap());
489+
490+
let uploader = new_logged_in_user(&env).await;
491+
let (_test_torrent, _indexed_torrent) = upload_random_torrent_to_index(&uploader, &env).await;
492+
493+
let response = client.get_torrents(Query::empty()).await;
494+
495+
let torrent_list_response: TorrentListResponse = serde_json::from_str(&response.body).unwrap();
496+
497+
assert!(torrent_list_response.data.total > 0);
498+
assert!(response.is_json_and_ok());
499+
}
466500
}
467501
}
468502

0 commit comments

Comments
 (0)