From 74d1bc02daa5aabe053bd470e865d9db72c6ffeb Mon Sep 17 00:00:00 2001 From: mnovak Date: Sat, 7 Nov 2026 18:16:14 +0100 Subject: [PATCH] [edge] Options: credentials directory override, so tests can run several edges in one process --- crates/edge/src/lib.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/edge/src/lib.rs b/crates/edge/src/lib.rs index 23a3ee5..66d4ea5 100644 --- a/crates/edge/src/lib.rs +++ b/crates/edge/src/lib.rs @@ -54,6 +54,8 @@ pub struct Options { pub share_revocations: Option, /// Extra trust root for the ACME directory's TLS (Pebble in tests). pub acme_root: Option, + /// Overrides `$CREDENTIALS_DIRECTORY` (tests running several edges in one process). + pub credentials_dir: Option, } impl Options { @@ -71,13 +73,15 @@ pub fn default_trial_path(config: &Path) -> PathBuf { config.with_file_name(name) } -fn credentials_dir() -> Option { - std::env::var_os("CREDENTIALS_DIRECTORY").map(PathBuf::from) +fn credentials_dir(opts: &Options) -> Option { + opts.credentials_dir + .clone() + .or_else(|| std::env::var_os("CREDENTIALS_DIRECTORY").map(PathBuf::from)) } /// Read the config, load secrets from `$CREDENTIALS_DIRECTORY`, load certificates. pub fn prepare(opts: &Options) -> Result, EdgeError> { - let creds = credentials_dir(); + let creds = credentials_dir(opts); let rt = runtime::build_file(&opts.config, creds.as_deref())?; Ok(shared_for(rt, opts)) } @@ -91,7 +95,7 @@ pub fn shared_for(rt: Runtime, opts: &Options) -> Arc { trial: opts.trial_path(), revocations: opts.share_revocations.clone(), }, - credentials_dir(), + credentials_dir(opts), ) }