diff --git a/src/client.rs b/src/client.rs index 41215dc..336d5c2 100644 --- a/src/client.rs +++ b/src/client.rs @@ -231,7 +231,9 @@ impl VaultClientSettingsBuilder { fn default_verify(&self) -> bool { info!("Checking TLS verification using $VAULT_SKIP_VERIFY"); match env::var("VAULT_SKIP_VERIFY") { - Ok(value) => !matches!(value.to_lowercase().as_str(), "0" | "f" | "false"), + // If VAULT_SKIP_VERIFY is set to '0', 'f' or 'false', verify is enabled + // Any other value will skip verification + Ok(value) => matches!(value.to_lowercase().as_str(), "0" | "f" | "false"), Err(_) => true, } } diff --git a/tests/client.rs b/tests/client.rs index 8614cc3..e923800 100644 --- a/tests/client.rs +++ b/tests/client.rs @@ -63,7 +63,8 @@ fn test_should_verify_tls() { for value in ["", "1", "t", "T", "true", "True", "TRUE"] { env::set_var(VAULT_SKIP_VERIFY, value); let client = build_client(); - assert!(client.settings.verify); + // Setting truthy value for SKIP_VERIFY should disable verify + assert_eq!(client.settings.verify, false); } } @@ -71,16 +72,18 @@ fn test_should_verify_tls() { #[serial_test::serial] fn test_should_not_verify_tls() { for value in ["0", "f", "F", "false", "False", "FALSE"] { + // Setting falsy value for SKIP_VERIFY should enable verify env::set_var(VAULT_SKIP_VERIFY, value); let client = build_client(); - assert!(!client.settings.verify); + assert_eq!(client.settings.verify, true); } } #[test] #[serial_test::serial] fn test_should_verify_tls_if_variable_is_not_set() { + // Not setting SKIP_VERIFY should enable verify env::remove_var(VAULT_SKIP_VERIFY); let client = build_client(); - assert!(client.settings.verify); + assert_eq!(client.settings.verify, true); }