Skip to content

Commit

Permalink
fix(app): Bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
schoenenberg committed Aug 6, 2024
1 parent 3c34b8a commit a144d17
Show file tree
Hide file tree
Showing 8 changed files with 812 additions and 181 deletions.
877 changes: 739 additions & 138 deletions clearing-house-app/Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions clearing-house-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ chrono = { version = "0.4.26", features = ["serde", "clock", "std"], default-fea
# Encryption and hashing
ring = "0.16.20"
# Config reader
config = { version = "0.13.3", default-features = false, features = ["toml"] }
config = { version = "0.14.0", default-features = false, features = ["toml"] }
# Logging/Tracing
tracing = "0.1"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
Expand All @@ -52,8 +52,8 @@ futures = "0.3.29"
# Helper for creating custom error types
thiserror = "1.0.48"
# Optional: Sentry integration
sentry = { version = "0.32.1", optional = true }
sqlx = { version = "0.7.3", features = ["runtime-tokio-rustls", "postgres", "chrono", "uuid"], optional = true }
sentry = { version = "0.34.0", optional = true }
sqlx = { version = "0.8.0", features = ["runtime-tokio-rustls", "postgres", "chrono", "uuid"], optional = true }

[dev-dependencies]
# Controlling execution of unit test cases, which could interfere with each other
Expand All @@ -62,8 +62,8 @@ serial_test = "3"
tempfile = "3.8"
tower = { version = "0.4", features = ["util"] }
hyper = { version = "1", features = ["full"] }
testcontainers = "0.15.0"
testcontainers-modules = { version = "0.3.4", features = ["postgres"] }
testcontainers = "0.21.1"
testcontainers-modules = { version = "0.9.0", features = ["postgres"] }

[features]
default = ["postgres"]
Expand Down
27 changes: 18 additions & 9 deletions clearing-house-app/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ pub(crate) fn read_config(config_file_override: Option<&std::path::Path>) -> CHC
pub(crate) fn configure_logging(config: &CHConfig) {
if std::env::var("RUST_LOG").is_err() {
if let Some(level) = &config.log_level {
std::env::set_var("RUST_LOG", level.to_string());
#[allow(unsafe_code)] // Deprecated safe from rust edition 2024
unsafe {
std::env::set_var("RUST_LOG", level.to_string());
}
}
}

Expand All @@ -104,10 +107,13 @@ mod test {
#[test]
#[serial]
fn test_read_config_from_env() {
std::env::set_var("CH_APP_DATABASE_URL", "mongodb://localhost:27117");
std::env::set_var("CH_APP_CLEAR_DB", "true");
std::env::set_var("CH_APP_LOG_LEVEL", "INFO");
std::env::set_var("CH_APP_STATIC_PROCESS_OWNER", "ABC");
#[allow(unsafe_code)] // Deprecated safe from rust edition 2024
unsafe {
std::env::set_var("CH_APP_DATABASE_URL", "mongodb://localhost:27117");
std::env::set_var("CH_APP_CLEAR_DB", "true");
std::env::set_var("CH_APP_LOG_LEVEL", "INFO");
std::env::set_var("CH_APP_STATIC_PROCESS_OWNER", "ABC");
}

let conf = super::read_config(None);
assert_eq!(conf.database_url, "mongodb://localhost:27117");
Expand All @@ -116,10 +122,13 @@ mod test {
assert_eq!(conf.static_process_owner, Some("ABC".to_string()));

// Cleanup
std::env::remove_var("CH_APP_DATABASE_URL");
std::env::remove_var("CH_APP_CLEAR_DB");
std::env::remove_var("CH_APP_LOG_LEVEL");
std::env::remove_var("CH_APP_STATIC_PROCESS_OWNER");
#[allow(unsafe_code)] // Deprecated safe from rust edition 2024
unsafe {
std::env::remove_var("CH_APP_DATABASE_URL");
std::env::remove_var("CH_APP_CLEAR_DB");
std::env::remove_var("CH_APP_LOG_LEVEL");
std::env::remove_var("CH_APP_STATIC_PROCESS_OWNER");
}
}

/// Test reading config from toml file
Expand Down
4 changes: 2 additions & 2 deletions clearing-house-app/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![forbid(unsafe_code)]
#![warn(clippy::all, clippy::pedantic, clippy::unwrap_used)]
#![deny(unsafe_code)]
#![warn(clippy::all, clippy::pedantic, clippy::unwrap_used, rust_2018_idioms, rust_2024_compatibility)]
#![allow(clippy::module_name_repetitions)]

#[macro_use]
Expand Down
4 changes: 2 additions & 2 deletions clearing-house-app/src/model/ids/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl InfoModelId {
}

impl std::fmt::Display for InfoModelId {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
InfoModelId::SimpleId(id) => fmt.write_str(id)?,
InfoModelId::ComplexId(id) => fmt.write_str(&id.to_string())?,
Expand Down Expand Up @@ -85,7 +85,7 @@ impl Default for InfoModelDateTime {
}

impl std::fmt::Display for InfoModelDateTime {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
InfoModelDateTime::Time(value) => fmt.write_str(&value.to_string())?,
InfoModelDateTime::ComplexTime(value) => fmt.write_str(&value.to_string())?,
Expand Down
27 changes: 17 additions & 10 deletions clearing-house-app/tests/create_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use axum::http::{Request, StatusCode};
use biscuit::jwa::SignatureAlgorithm::PS512;
use biscuit::jwk::JWKSet;
use testcontainers::runners::AsyncRunner;
use clearing_house_app::model::claims::{get_fingerprint, ChClaims};
use clearing_house_app::model::ids::message::IdsMessage;
use clearing_house_app::model::ids::request::ClearingHouseMessage;
Expand All @@ -17,19 +18,25 @@ async fn log_message() {
const CLIENT_ID: &str = "69:F5:9D:B0:DD:A6:9D:30:5F:58:AA:2D:20:4D:B2:39:F0:54:FC:3B:keyid:4F:66:7D:BD:08:EE:C6:4A:D1:96:D8:7C:6C:A2:32:8A:EC:A6:AD:49";

// Start testcontainer: Postgres
let docker = testcontainers::clients::Cli::default();
let postgres_instance = docker.run(testcontainers_modules::postgres::Postgres::default());
let postgres_instance = testcontainers_modules::postgres::Postgres::default()
.start()
.await
.expect("Failed to start Postgres container");
let connection_string = format!(
"postgres://postgres:[email protected]:{}/postgres",
postgres_instance.get_host_port_ipv4(5432)
"postgres://postgres:postgres@{}:{}/postgres",
postgres_instance.get_host().await.expect("Failed to get host"),
postgres_instance.get_host_port_ipv4(5432).await.expect("Failed to get port")
);

std::env::set_var("SERVICE_ID_LOG", "test");
std::env::set_var("SHARED_SECRET", "test");
std::env::set_var("CH_APP_LOG_LEVEL", "TRACE");
std::env::set_var("CH_APP_CLEAR_DB", "false");
std::env::set_var("CH_APP_STATIC_PROCESS_OWNER", "MDS_EDC_CONNECTOR");
std::env::set_var("CH_APP_DATABASE_URL", connection_string);
#[allow(unsafe_code)] // Deprecated safe from rust edition 2024
unsafe {
std::env::set_var("SERVICE_ID_LOG", "test");
std::env::set_var("SHARED_SECRET", "test");
std::env::set_var("CH_APP_LOG_LEVEL", "TRACE");
std::env::set_var("CH_APP_CLEAR_DB", "false");
std::env::set_var("CH_APP_STATIC_PROCESS_OWNER", "MDS_EDC_CONNECTOR");
std::env::set_var("CH_APP_DATABASE_URL", connection_string);
}

let app = clearing_house_app::app().await.unwrap();

Expand Down
25 changes: 16 additions & 9 deletions clearing-house-app/tests/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use axum::http::{Request, StatusCode};
use biscuit::jwa::SignatureAlgorithm::PS512;
use biscuit::jwk::JWKSet;
use testcontainers::runners::AsyncRunner;
use clearing_house_app::model::claims::{get_fingerprint, ChClaims};
use clearing_house_app::model::ids::message::IdsMessage;
use clearing_house_app::model::ids::request::ClearingHouseMessage;
Expand All @@ -15,18 +16,24 @@ use tower::ServiceExt;
#[tokio::test]
async fn log_message() {
// Start testcontainer: Postgres
let docker = testcontainers::clients::Cli::default();
let postgres_instance = docker.run(testcontainers_modules::postgres::Postgres::default());
let postgres_instance = testcontainers_modules::postgres::Postgres::default()
.start()
.await
.expect("Failed to start Postgres container");
let connection_string = format!(
"postgres://postgres:[email protected]:{}/postgres",
postgres_instance.get_host_port_ipv4(5432)
"postgres://postgres:postgres@{}:{}/postgres",
postgres_instance.get_host().await.expect("Failed to get host"),
postgres_instance.get_host_port_ipv4(5432).await.expect("Failed to get port")
);

std::env::set_var("SERVICE_ID_LOG", "test");
std::env::set_var("SHARED_SECRET", "test");
std::env::set_var("CH_APP_LOG_LEVEL", "TRACE");
std::env::set_var("CH_APP_CLEAR_DB", "false");
std::env::set_var("CH_APP_DATABASE_URL", connection_string);
#[allow(unsafe_code)] // Deprecated safe from rust edition 2024
unsafe {
std::env::set_var("SERVICE_ID_LOG", "test");
std::env::set_var("SHARED_SECRET", "test");
std::env::set_var("CH_APP_LOG_LEVEL", "TRACE");
std::env::set_var("CH_APP_CLEAR_DB", "false");
std::env::set_var("CH_APP_DATABASE_URL", connection_string);
}

let app = clearing_house_app::app().await.unwrap();

Expand Down
19 changes: 13 additions & 6 deletions clearing-house-app/tests/public_key.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
use axum::body::Body;
use axum::http::{Request, StatusCode};
use biscuit::jwk::JWKSet;
use testcontainers::runners::AsyncRunner;
use tower::ServiceExt;

#[tokio::test]
async fn retrieve_public_key() {
// Start testcontainer: Postgres
let docker = testcontainers::clients::Cli::default();
let postgres_instance = docker.run(testcontainers_modules::postgres::Postgres::default());
let postgres_instance = testcontainers_modules::postgres::Postgres::default()
.start()
.await
.expect("Failed to start Postgres container");
let connection_string = format!(
"postgres://postgres:[email protected]:{}/postgres",
postgres_instance.get_host_port_ipv4(5432)
"postgres://postgres:postgres@{}:{}/postgres",
postgres_instance.get_host().await.expect("Failed to get host"),
postgres_instance.get_host_port_ipv4(5432).await.expect("Failed to get port")
);

std::env::set_var("SERVICE_ID_LOG", "test");
std::env::set_var("CH_APP_DATABASE_URL", connection_string);
#[allow(unsafe_code)] // Deprecated safe from rust edition 2024
unsafe {
std::env::set_var("SERVICE_ID_LOG", "test");
std::env::set_var("CH_APP_DATABASE_URL", connection_string);
}

let app = clearing_house_app::app().await.unwrap();

Expand Down

0 comments on commit a144d17

Please sign in to comment.