Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unknown variant to KeyAlgorithm #400

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
ThatNerdUKnow marked this conversation as resolved.
Show resolved Hide resolved
#[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);
}
ThatNerdUKnow marked this conversation as resolved.
Show resolved Hide resolved
}
Loading