niom-turn/tests/config/integration.rs

30 lines
1.0 KiB
Rust

//! Config-driven integration scaffolding testing startup paths.
#[path = "../support/mod.rs"]
mod support;
mod helpers;
use serde_json::json;
#[tokio::test(flavor = "current_thread")]
async fn config_file_round_trip_populates_auth_manager() {
let cfg_json = json!({
"server": { "bind": "127.0.0.1:3478", "tls_cert": null, "tls_key": null },
"credentials": [ { "username": "alice", "password": "secret" } ],
"auth": { "realm": "niom-turn.integration", "nonce_ttl_seconds": 120 }
})
.to_string();
let temp = helpers::write_temp_config(&cfg_json);
let cfg = niom_turn::config::Config::from_file(temp.path()).expect("config load");
assert_eq!(cfg.server.bind, "127.0.0.1:3478");
assert_eq!(cfg.credentials.len(), 1);
let store = niom_turn::auth::InMemoryStore::new();
for cred in &cfg.credentials {
store.insert(&cred.username, &cred.password);
}
let auth = niom_turn::auth::AuthManager::new(store, &cfg.auth);
assert_eq!(auth.realm(), "niom-turn.integration");
}