Skip to content

Commit

Permalink
Fixed issue with serializing and added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cobward committed Oct 30, 2024
1 parent 6c2a766 commit d064aec
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion crates/jwk/src/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ macro_rules! algorithms {
///
/// Per the specs it should only be `none` but `None` is kept for backwards
/// compatibility.
#[serde(alias = "none")]
#[serde(alias = "None", rename = "none")]
None
}

Expand Down Expand Up @@ -292,3 +292,28 @@ impl From<ES256OrES384> for Algorithm {
}
}
}

#[cfg(test)]
mod tests {
use super::Algorithm;

#[test]
fn none_serializes() {
assert_eq!(
serde_json::to_string(&Algorithm::None).unwrap(),
r#""none""#
)
}

#[test]
fn none_deserializes() {
assert_eq!(
serde_json::from_str::<Algorithm>(r#""none""#).unwrap(),
Algorithm::None
);
assert_eq!(
serde_json::from_str::<Algorithm>(r#""None""#).unwrap(),
Algorithm::None
)
}
}

0 comments on commit d064aec

Please sign in to comment.