From 40aa9d6735243e13a20346f75c794f75f74385a3 Mon Sep 17 00:00:00 2001 From: John Baublitz Date: Wed, 8 May 2024 15:24:35 -0400 Subject: [PATCH] Tang tests for Clevis config validation (cherry picked from commit 524efe0024c2ddfea0f4288a9eafecbc5e2b7a42) --- .../strat_engine/backstore/crypt/mod.rs | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/engine/strat_engine/backstore/crypt/mod.rs b/src/engine/strat_engine/backstore/crypt/mod.rs index 19c81e4537..1c0164bc6b 100644 --- a/src/engine/strat_engine/backstore/crypt/mod.rs +++ b/src/engine/strat_engine/backstore/crypt/mod.rs @@ -485,4 +485,53 @@ mod tests { test_clevis_initialize, ); } + + fn test_clevis_tang_configs(paths: &[&Path]) { + let path = paths[0]; + let pool_name = Name::new("pool_name".to_string()); + + assert!(CryptHandle::initialize( + path, + PoolUuid::new_v4(), + DevUuid::new_v4(), + pool_name.clone(), + &EncryptionInfo::ClevisInfo(( + "tang".to_string(), + json!({"url": env::var("TANG_URL").expect("TANG_URL env var required")}), + )), + None, + ) + .is_err()); + CryptHandle::initialize( + path, + PoolUuid::new_v4(), + DevUuid::new_v4(), + pool_name, + &EncryptionInfo::ClevisInfo(( + "tang".to_string(), + json!({ + "stratis:tang:trust_url": true, + "url": env::var("TANG_URL").expect("TANG_URL env var required"), + }), + )), + None, + ) + .unwrap(); + } + + #[test] + fn clevis_real_test_clevis_tang_configs() { + real::test_with_spec( + &real::DeviceLimits::Exactly(1, None, None), + test_clevis_tang_configs, + ); + } + + #[test] + fn clevis_loop_test_clevis_tang_configs() { + loopbacked::test_with_spec( + &loopbacked::DeviceLimits::Exactly(1, None), + test_clevis_tang_configs, + ); + } }