Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/jwk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ pub enum KeyAlgorithm {
/// RSAES-OAEP-256 using SHA-2
#[serde(rename = "RSA-OAEP-256")]
RSA_OAEP_256,

/// Catch-All for when the key algorithm can not be determined
#[serde(other)]
UNKNOWN_ALGORITHM
}

impl FromStr for KeyAlgorithm {
Expand Down Expand Up @@ -435,7 +439,7 @@ impl JwkSet {

#[cfg(test)]
mod tests {
use crate::jwk::{AlgorithmParameters, JwkSet, OctetKeyType};
use crate::jwk::{AlgorithmParameters, JwkSet, KeyAlgorithm, OctetKeyType};
use crate::serialization::b64_encode;
use crate::Algorithm;
use serde_json::json;
Expand Down Expand Up @@ -471,4 +475,11 @@ mod tests {
_ => panic!("Unexpected key algorithm"),
}
}

#[test]
fn deserialize_unknown_key_algorithm(){
let key_alg_json = json!("");
let key_alg_result: KeyAlgorithm = serde_json::from_value(key_alg_json).expect("Could not deserialize json");
assert_eq!(key_alg_result,KeyAlgorithm::UNKNOWN_ALGORITHM);
}
}
Loading