-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #734: Release Version 3.0.0-rc.1
867a1f5 release: version 3.0.0-rc.1 (Jose Celano) cdf2fe3 fix: chedck error (Jose Celano) 5e0226d chore(deps): update dependencies (Jose Celano) 7d82eb2 feat: [#730] add CMS content to configration (Jose Celano) 0f3d122 chore(deps): update dependencies (Jose Celano) 69a463a chore(deps): udpate dependencies (Jose Celano) 8246f07 feat: min and max password length should be also valid (Jose Celano) 2e67cc1 fix: [#613] wrong error message for password too long error (Jose Celano) bc28ac7 develop: bump to version 3.0.0-rc.1-develop (Jose Celano) Pull request description: Release Version 3.0.0-rc.1 ACKs for top commit: josecelano: ACK 867a1f5 Tree-SHA512: f304ae58451017faf56b285562bb445894637a43fb64bf6ec8f61cbd9fb34e28faa59b9023f4e0cff0d38c373383e0fb6222a534ac02fecda81c54f72560f383
- Loading branch information
Showing
10 changed files
with
838 additions
and
322 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,11 @@ pub type Logging = v2::logging::Logging; | |
pub type Threshold = v2::logging::Threshold; | ||
|
||
pub type Website = v2::website::Website; | ||
pub type Demo = v2::website::Demo; | ||
pub type Terms = v2::website::Terms; | ||
pub type TermsPage = v2::website::TermsPage; | ||
pub type TermsUpload = v2::website::TermsUpload; | ||
pub type Markdown = v2::website::Markdown; | ||
|
||
/// Configuration version | ||
const VERSION_2: &str = "2.0.0"; | ||
|
@@ -193,6 +198,14 @@ impl Info { | |
config_toml_path, | ||
}) | ||
} | ||
|
||
#[must_use] | ||
pub fn from_toml(config_toml: &str) -> Self { | ||
Self { | ||
config_toml: Some(config_toml.to_owned()), | ||
config_toml_path: String::new(), | ||
} | ||
} | ||
} | ||
|
||
/// Errors that can occur when loading the configuration. | ||
|
@@ -385,88 +398,44 @@ mod tests { | |
|
||
#[cfg(test)] | ||
fn default_config_toml() -> String { | ||
let config = r#"[metadata] | ||
app = "torrust-index" | ||
purpose = "configuration" | ||
schema_version = "2.0.0" | ||
[logging] | ||
threshold = "info" | ||
[website] | ||
name = "Torrust" | ||
[tracker] | ||
api_url = "http://localhost:1212/" | ||
listed = false | ||
private = false | ||
token = "MyAccessToken" | ||
token_valid_seconds = 7257600 | ||
url = "udp://localhost:6969" | ||
[net] | ||
bind_address = "0.0.0.0:3001" | ||
[auth] | ||
user_claim_token_pepper = "MaxVerstappenWC2021" | ||
[auth.password_constraints] | ||
max_password_length = 64 | ||
min_password_length = 6 | ||
[database] | ||
connect_url = "sqlite://data.db?mode=rwc" | ||
[mail] | ||
from = "[email protected]" | ||
reply_to = "[email protected]" | ||
[mail.smtp] | ||
port = 25 | ||
server = "" | ||
[mail.smtp.credentials] | ||
password = "" | ||
username = "" | ||
[image_cache] | ||
capacity = 128000000 | ||
entry_size_limit = 4000000 | ||
max_request_timeout_ms = 1000 | ||
user_quota_bytes = 64000000 | ||
user_quota_period_seconds = 3600 | ||
[api] | ||
default_torrent_page_size = 10 | ||
max_torrent_page_size = 30 | ||
[tracker_statistics_importer] | ||
port = 3002 | ||
torrent_info_update_interval = 3600 | ||
"# | ||
.lines() | ||
.map(str::trim_start) | ||
.collect::<Vec<&str>>() | ||
.join("\n"); | ||
use std::fs; | ||
use std::path::PathBuf; | ||
|
||
// Get the path to the current Cargo.toml directory | ||
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR environment variable not set"); | ||
|
||
// Construct the path to the default configuration file relative to the Cargo.toml directory | ||
let mut path = PathBuf::from(manifest_dir); | ||
path.push("tests/fixtures/default_configuration.toml"); | ||
|
||
let config = fs::read_to_string(path) | ||
.expect("Could not read default configuration TOML file: tests/fixtures/default_configuration.toml"); | ||
|
||
config.lines().map(str::trim_start).collect::<Vec<&str>>().join("\n"); | ||
|
||
config | ||
} | ||
|
||
#[tokio::test] | ||
async fn configuration_should_build_settings_with_default_values() { | ||
let configuration = Configuration::default().get_all().await; | ||
/// Build settings from default configuration fixture in TOML. | ||
/// | ||
/// We just want to load that file without overriding with env var or other | ||
/// configuration loading behavior. | ||
#[cfg(test)] | ||
fn default_settings() -> Settings { | ||
use figment::providers::{Format, Toml}; | ||
use figment::Figment; | ||
|
||
let toml = toml::to_string(&configuration).expect("Could not encode TOML value for configuration"); | ||
let figment = Figment::from(Toml::string(&default_config_toml())); | ||
let settings: Settings = figment.extract().expect("Invalid configuration"); | ||
|
||
assert_eq!(toml, default_config_toml()); | ||
settings | ||
} | ||
|
||
#[tokio::test] | ||
async fn configuration_should_return_all_settings() { | ||
let configuration = Configuration::default().get_all().await; | ||
|
||
let toml = toml::to_string(&configuration).expect("Could not encode TOML value for configuration"); | ||
async fn configuration_should_have_a_default_constructor() { | ||
let settings = Configuration::default().get_all().await; | ||
|
||
assert_eq!(toml, default_config_toml()); | ||
assert_eq!(settings, default_settings()); | ||
} | ||
|
||
#[tokio::test] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.