diff --git a/generate/src/main.rs b/generate/src/main.rs index 9dde1d3..84d5673 100644 --- a/generate/src/main.rs +++ b/generate/src/main.rs @@ -82,8 +82,6 @@ fn generate_and_check( let strategy = ClaimsForSelectiveDisclosureStrategy::Custom(sd_claims_jsonpaths.iter().map(String::as_str).collect()); - dbg!(&strategy); - let jwk: Option = if specs.key_binding.unwrap_or(false) { let jwk: Jwk = serde_yaml::from_value(settings.key_settings.holder_key.clone()).unwrap(); Some(jwk) @@ -253,17 +251,12 @@ fn load_salts(path: &PathBuf) -> Result<()> { .map_err(|e| Error::from_msg(ErrorKind::IOError, e.to_string()))?; let salts: Vec = serde_json::from_str(&json_data)?; - - dbg!(&salts); - { - let mut map = SALTS.lock().unwrap(); + let mut s = SALTS.lock().unwrap(); for salt in salts.iter() { - map.push_back(salt.clone()); + s.push_back(salt.clone()); } - - dbg!(&map); } } diff --git a/src/disclosure.rs b/src/disclosure.rs index b0dfcb7..bad6476 100644 --- a/src/disclosure.rs +++ b/src/disclosure.rs @@ -45,10 +45,10 @@ impl SDJWTDisclosure { } } -fn escape_unicode_chars(sss: &str) -> String { +fn escape_unicode_chars(s: &str) -> String { let mut result = String::new(); - for c in sss.chars() { + for c in s.chars() { if c.is_ascii() { result.push(c); } else { diff --git a/src/utils.rs b/src/utils.rs index 3211420..d21985e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -16,7 +16,7 @@ use std::{collections::VecDeque, sync::Mutex}; #[cfg(feature = "mock_salts")] lazy_static! { - pub static ref SALTS: Mutex> = Mutex::new(VecDeque::with_capacity(100)); + pub static ref SALTS: Mutex> = Mutex::new(VecDeque::new()); } pub(crate) fn base64_hash(data: &[u8]) -> String { @@ -43,19 +43,10 @@ pub(crate) fn generate_salt(_key_for_predefined_salt: Option) -> String base64url_encode(&buf) } +#[cfg(feature = "mock_salts")] pub(crate) fn generate_salt_mock(_key_for_predefined_salt: Option) -> String { - - #[cfg(feature = "mock_salts")] - { - let mut salts = SALTS.lock().unwrap(); - - if let Some(salt) = salts.pop_front() { - //FIXME better mock approach - return salt.clone() - } - - panic!("salts is empty"); - } + let mut salts = SALTS.lock().unwrap(); + return salts.pop_front().expect("SALTS is empty"); } pub(crate) fn jwt_payload_decode(b64data: &str) -> Result> {