From c24f15c18f02319be83af4f3c1951dc220b52c5e Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Thu, 14 Jan 2021 15:14:40 -0800 Subject: [PATCH] Add regression test for #1503. Closes #1503. --- core/lib/Cargo.toml | 2 +- core/lib/tests/tls-config-from-source-1503.rs | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 core/lib/tests/tls-config-from-source-1503.rs diff --git a/core/lib/Cargo.toml b/core/lib/Cargo.toml index de6cced3..c9efc336 100644 --- a/core/lib/Cargo.toml +++ b/core/lib/Cargo.toml @@ -41,7 +41,7 @@ atomic = "0.5" parking_lot = "0.11" ubyte = {version = "0.10", features = ["serde"] } serde = { version = "1.0", features = ["derive"] } -figment = { version = "0.10", features = ["toml", "env"] } +figment = { version = "0.10.2", features = ["toml", "env"] } rand = "0.7" either = "1" diff --git a/core/lib/tests/tls-config-from-source-1503.rs b/core/lib/tests/tls-config-from-source-1503.rs new file mode 100644 index 00000000..1aaaee37 --- /dev/null +++ b/core/lib/tests/tls-config-from-source-1503.rs @@ -0,0 +1,24 @@ +macro_rules! crate_relative { + ($path:expr) => { + std::path::Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/", $path)) + }; +} + +#[test] +fn tls_config_from_soruce() { + use rocket::config::{Config, TlsConfig}; + use rocket::figment::Figment; + + let cert_path = crate_relative!("examples/tls/private/cert.pem"); + let key_path = crate_relative!("examples/tls/private/key.pem"); + + let rocket_config = Config { + tls: Some(TlsConfig::from_paths(cert_path, key_path)), + ..Default::default() + }; + + let config: Config = Figment::from(rocket_config).extract().unwrap(); + let tls = config.tls.expect("have TLS config"); + assert_eq!(tls.certs().unwrap_left(), cert_path); + assert_eq!(tls.key().unwrap_left(), key_path); +}